Package org.apache.ws.jaxme.js

Examples of org.apache.ws.jaxme.js.JavaSource


  private void elementParticle(GroupSG pGroupSG, ParticleSG pParticle) throws SAXException {
    if (isInheritedParticle(pParticle)) {
      return;
    }
    final JavaSource pJs = this.js;
    final PropertySG elementSG = pParticle.getPropertySG();
    if (isMixed) {
      JavaQName qName = GroupUtil.getContentClass(pGroupSG, pParticle, pJs.getQName());
      JavaSource js;
      if (qName.isInnerClass()) {
        js = pJs.newJavaInnerClass(qName.getInnerClassName(), JavaSource.PUBLIC);
        if (!pJs.isInterface()) {
          js.setStatic(true);
        }
      } else {
        js = pJs.getFactory().newJavaSource(qName, JavaSource.PUBLIC);
      }
      if (pJs.isInterface()) {
        js.setType(JavaSource.INTERFACE);
      } else {
        js.addImplements(GroupUtil.getContentClass(pGroupSG, pParticle, ct.getClassContext().getXMLInterfaceName()));
      }
      PropertySGChain chain = ((PropertySGImpl) elementSG).getHeadOfChain();
      PropertySGChain head = new PropertySGChainImpl(chain){
        public String getXMLFieldName(PropertySG pController) throws SAXException {
          return "_value";
View Full Code Here


  protected GroupHandlerSG getGroupHandlerSG(GroupSG pGroup) {
    return (GroupHandlerSG) groups.get(pGroup);
  }

  private GroupHandlerSG newGroupHandlerSG(GroupSG pGroup, String pName) throws SAXException {
    JavaSource js = getJavaSource();
    JavaInnerClass jic = js.newJavaInnerClass(pName, JavaSource.PUBLIC);
    jic.addExtends(JMSAXGroupParser.class);
    if (pGroup.isSequence()) {
      return new SequenceHandlerSG(outerHandler, ctSG, pGroup, jic);
    } else if (pGroup.isChoice()) {
      return new ChoiceHandlerSG(outerHandler, ctSG, pGroup, jic);
View Full Code Here

      throw new IllegalStateException("Invalid group type");
    }
  }

  private GroupHandlerSG newGroupHandlerSG(GroupSG pGroup) throws SAXException {
    JavaSource js = getJavaSource();
    String name = GroupUtil.getGroupName(pGroup);
    for (int i = 0;  ;  i++) {
      String n = name;
      if (i > 0) {
        name += i;
      }
      n += "Handler";
      if (js.getInnerClass(n) == null) {
        GroupHandlerSG result = newGroupHandlerSG(pGroup, n);
        result.newGetHandlerMethod(js);
        return result;
      }
    }
View Full Code Here

          columnUpdater = new IdIncrementer(pkColumns);
        }
        versionGenerator.addTable(table, columnUpdater);
      }

      JavaSource js = pFactory.newJavaSource(pTargetClass);
      versionGenerator.getCloneMethod(js);
    }
View Full Code Here

                    } else {
                      throw new BuildException("Unknown extension in file name: " + s
                                                 + ", expected .class or .java",
                                                 getLocation());
                    }
                    JavaSource js = r.getJavaSource(inputs);
                    sources.add(js);
                }
            }
            for (int i = 0;  i < sources.size();  i++) {
                JavaSource js = (JavaSource) sources.get(i);
                if (js.isAbstract()) {
                  getProject().log("Ignoring abstract class " + js.getQName(), Project.MSG_VERBOSE);
                } else {
                  getProject().log("Generating XML-RPC client for " + js.getQName(), Project.MSG_DEBUG);
                  gen.addClass(js, inputs);
                }
            }

            Dispatcher disp = getDispatcher();
View Full Code Here

        }
        String className = classNameAST.getText();
        if (pOuterClass == null) {
            String packageName = getPackageName();
            JavaQName qName = JavaQNameImpl.getInstance(packageName, className);
            JavaSource js = factory.newJavaSource(qName, JavaSource.DEFAULT_PROTECTION);
            generatedClasses.add(js);
            return js;
        } else {
            return pOuterClass.newJavaInnerClass(className, JavaSource.DEFAULT_PROTECTION);
        }
View Full Code Here

        }
    }

    private void parseClassDefinition(JavaSource pOuterClass,
                                      JavaSource.Type pType, AST pAST) {
      JavaSource currentClass = getJavaSource(pOuterClass, pAST);
        currentClass.setType(pType);
        parseModifiers(currentClass, pAST);
        parseImplementsOrExtends(currentClass, pAST, JavaRecognizer.EXTENDS_CLAUSE);
        if (!JavaSource.INTERFACE.equals(pType)) {
          parseImplementsOrExtends(currentClass, pAST, JavaRecognizer.IMPLEMENTS_CLAUSE);
        }
View Full Code Here

  public JavaSource getEnumClass(SimpleTypeSG pController) throws SAXException {
    JavaQName valueType = super.getRuntimeType(pController);
    JavaQName qNameArray = JavaQNameImpl.getArray(qName);

    JavaSource js = pController.getSchema().getJavaSourceFactory().newJavaSource(qName, JavaSource.PUBLIC);
    js.addImplements(Serializable.class);

    JavaField name = js.newJavaField("name", String.class, JavaSource.PRIVATE);
    name.setFinal(true);
    JavaField value = js.newJavaField("value", valueType, JavaSource.PRIVATE);
    value.setFinal(true);
    JavaField lexicalValue = js.newJavaField("lexicalValue", String.class, JavaSource.PRIVATE);
    lexicalValue.setFinal(true);

    List instanceParams = new ArrayList();
    for (int i = 0;  i < values.length;  i++) {
      JavaField _f = js.newJavaField("_" + values[i].getName(), String.class, JavaSource.PUBLIC);
      _f.setStatic(true);
      _f.setFinal(true);
      _f.addLine(JavaSource.getQuoted(values[i].getName()));

      JavaField f = js.newJavaField(values[i].getName(), qName, JavaSource.PUBLIC);
      f.addLine("new ", qName, "(", JavaSource.getQuoted(values[i].getName()), ", ",
                super.getCastFromString(pController, values[i].getValue()), ", ",
                JavaSource.getQuoted(values[i].getValue()), ");");
      f.setStatic(true);
      f.setFinal(true);
      if (!instanceParams.isEmpty()) instanceParams.add(", ");
      instanceParams.add(f);
    }
    JavaField instances = js.newJavaField("instances", qNameArray, JavaSource.PRIVATE);
    instances.addLine(new Object[]{"new ", qNameArray, "{", instanceParams, "}"});
    instances.setStatic(true);
    instances.setFinal(true);

    JavaConstructor con = js.newJavaConstructor(JavaSource.PRIVATE);
    DirectAccessible pName = con.addParam(String.class, "pName");
    DirectAccessible pValue = con.addParam(super.getRuntimeType(pController), "pValue");
    DirectAccessible pLexicalValue = con.addParam(String.class, "pLexicalValue");
    con.addLine(name, " = ", pName, ";");
    con.addLine(value, " = ", pValue, ";");
    con.addLine(lexicalValue, " = ", pLexicalValue, ";");

    JavaMethod toStringMethod = js.newJavaMethod("toString", String.class, JavaSource.PUBLIC);
    toStringMethod.addLine("return ", lexicalValue, ";");

    JavaMethod getValueMethod = js.newJavaMethod("getValue", valueType, JavaSource.PUBLIC);
    getValueMethod.addLine("return ", value, ";");

    JavaMethod getNameMethod = js.newJavaMethod("getName", String.class, JavaSource.PUBLIC);
    getNameMethod.addLine("return ", name, ";");

    JavaMethod getInstancesMethod = js.newJavaMethod("getInstances", qNameArray, JavaSource.PUBLIC);
    getInstancesMethod.setStatic(true);
    getInstancesMethod.addLine("return ", instances, ";");

    JavaMethod fromValueMethod = js.newJavaMethod("fromValue", qName, JavaSource.PUBLIC);
    pValue = fromValueMethod.addParam(valueType, "pValue");
    fromValueMethod.setStatic(true);
    DirectAccessible i = fromValueMethod.addForArray(instances);
    fromValueMethod.addIf(pController.getEqualsCheck(fromValueMethod, new Object[]{instances, "[", i, "].value"}, pValue));
    fromValueMethod.addLine("return ", instances, "[", i, "];");
    fromValueMethod.addEndIf();
    fromValueMethod.addEndFor();
    fromValueMethod.addThrowNew(IllegalArgumentException.class, JavaSource.getQuoted("Invalid value: "),
                                " + ", pValue);

    JavaMethod fromNameMethod = js.newJavaMethod("fromName", qName, JavaSource.PUBLIC);
    pName = fromNameMethod.addParam(String.class, "pName");
    fromNameMethod.setStatic(true);
    i = fromNameMethod.addForArray(instances);
    fromNameMethod.addIf(instances, "[", i, "].name.equals(", pName, ")");
    fromNameMethod.addLine("return ", instances, "[", i, "];");
    fromNameMethod.addEndIf();
    fromNameMethod.addEndFor();
    fromNameMethod.addThrowNew(IllegalArgumentException.class, JavaSource.getQuoted("Invalid name: "),
                                " + ", pName);

    JavaMethod fromStringMethod = js.newJavaMethod("fromString", qName, JavaSource.PUBLIC);
    pValue = fromStringMethod.addParam(String.class, "pValue");
    fromStringMethod.setStatic(true);
    fromStringMethod.addLine("return ", fromValueMethod, "(",
                             super.getCastFromString(pController, fromStringMethod, pValue, null), ");");

    if (js.isImplementing(Serializable.class)) {
      JavaMethod readResolveMethod = js.newJavaMethod("readResolve", Object.class, JavaSource.PRIVATE);
      readResolveMethod.addLine("return ", fromValueMethod, "(", value, ");");
    }
    return js;
  }
View Full Code Here

  protected GroupHandlerSG getGroupHandlerSG(GroupSG pGroup) {
    return (GroupHandlerSG) groups.get(pGroup);
  }

  private GroupHandlerSG newGroupHandlerSG(GroupSG pGroup, String pName) throws SAXException {
    JavaSource js = getJavaSource();
    JavaInnerClass jic = js.newJavaInnerClass(pName, JavaSource.PUBLIC);
    jic.addExtends(JMSAXGroupParser.class);
    if (pGroup.isSequence()) {
      return new SequenceHandlerSG(ctSG, pGroup, jic);
    } else if (pGroup.isChoice()) {
      return new ChoiceHandlerSG(ctSG, pGroup, jic);
View Full Code Here

      throw new IllegalStateException("Invalid group type");
    }
  }

  private GroupHandlerSG newGroupHandlerSG(GroupSG pGroup) throws SAXException {
    JavaSource js = getJavaSource();
    String name = GroupUtil.getGroupName(pGroup);
    for (int i = 0;  ;  i++) {
      String n = name;
      if (i > 0) {
        name += i;
      }
      n += "Handler";
      if (js.getInnerClass(n) == null) {
        GroupHandlerSG result = newGroupHandlerSG(pGroup, n);
        result.newGetHandlerMethod(js);
        return result;
      }
    }
View Full Code Here

TOP

Related Classes of org.apache.ws.jaxme.js.JavaSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.