Package org.apache.ws.jaxme.js

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


    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");
View Full Code Here


   * The default implementation generates code creating an instance of
   * {@link org.apache.ws.jaxme.logging.Logger}.</p>
   */
  protected void initLogging(JavaSource pSource) {
    if (isGeneratingLogging()) {
      JavaField jf = pSource.newJavaField("logger", Logger.class, JavaSource.PRIVATE);
      jf.setFinal(true);
      jf.setStatic(true);
      jf.addLine(LoggerAccess.class, ".getLogger(", pSource.getQName(), ".class)");
    }
  }
View Full Code Here

  /** <p>Generates the innner class CacheData.</p>
   */
  protected JavaInnerClass getCacheDataClass(JavaSource pSource) {
     JavaInnerClass jic = pSource.newJavaInnerClass("CacheData", JavaSource.PRIVATE);

     JavaField name = jic.newJavaField("name", String.class, JavaSource.PRIVATE);
     name.setFinal(true);
     JavaField values = jic.newJavaField("values", Object[].class, JavaSource.PRIVATE);
     values.setFinal(true);

     JavaConstructor jcon = jic.newJavaConstructor(JavaSource.PRIVATE);
     DirectAccessible pName = jcon.addParam(String.class, "pName");
     DirectAccessible pValues = jcon.addParam(Object[].class, "pValues");
     jcon.addLine(name, " = ", pName, ";");
View Full Code Here

    names.add(itemName);
    names.add(itemValue);
   }

   pSource.addImplements(Serializable.class);
   JavaField name = pSource.newJavaField("name", String.class, JavaSource.PRIVATE);
   name.setFinal(true);
   JavaField value = pSource.newJavaField("value", String.class, JavaSource.PRIVATE);
   name.setFinal(true);
   JavaConstructor jcon = pSource.newJavaConstructor(JavaSource.PRIVATE);
   jcon.addParam(String.class, "pName");
   jcon.addParam(String.class, "pValue");
   jcon.addLine("name = pName;");
   jcon.addLine("value = pValue;");
    List instanceList = new ArrayList();
   for (int i = 0;  i < pItems.length;  i++) {
      Item item = pItems[i];
    String itemName = item.getName();
    String itemValue = item.getValue();
    JavaField instance = pSource.newJavaField(itemName, pSource.getQName(),
                                             JavaSource.PUBLIC);
    instance.newComment().addLine("The enumeration item with name " + itemName +
                                 " and value " + itemValue + ".");
    instance.setStatic(true);
    instance.setFinal(true);
    instance.addLine("new ", pSource.getQName(), "(", JavaSource.getQuoted(itemName),
                     ", ", JavaSource.getQuoted(itemValue), ")");

    if (i > 0) instanceList.add(", ");
     instanceList.add(instance);
    }

   JavaQName arrayType = JavaQNameImpl.getArray(pSource.getQName());
   JavaField allInstances = pSource.newJavaField("allInstances", arrayType,
                                                  JavaSource.PRIVATE);
   allInstances.setStatic(true);
   allInstances.setFinal(true);
   allInstances.addLine("new ", arrayType, "{", instanceList, "}");

   JavaMethod getName = pSource.newJavaMethod("getName", String.class,
                                               JavaSource.PUBLIC);
   getName.newComment().addLine("The enumeration items name.");
   getName.addLine("return ", name, ";");
View Full Code Here

   public JavaSource getSource(JavaSource.Protection pProtection) {
      JavaSourceFactory factory = new JavaSourceFactory();
      JavaSource js;
      JavaConstructor jcon;
      JavaMethod jm;
      JavaField jf;
      LocalJavaField lfj;
      if (pProtection == null) {
        js = factory.newJavaSource(JavaQNameImpl.getInstance(PACKAGE_NAME, CLASS_NAME));
        js.newJavaInnerClass("Bof");
        jf = js.newJavaField("someField", int.class);
View Full Code Here

      fieldName = pFieldName;
    }
    public boolean isCasting() { return !child.getObjectSG().getTypeSG().isComplex(); }
    public void generate(JavaMethod pMethod, Object pValue) throws SAXException {
      ObjectSG objectSG = child.getObjectSG();
      JavaField f = pMethod.getJavaSource().newJavaField(fieldName + "_qname", QName.class);
      f.setStatic(true);
      f.setFinal(true);
      f.addLine("new ", QName.class, "(", JavaSource.getQuoted(objectSG.getName().getNamespaceURI()),
                ", ", JavaSource.getQuoted(objectSG.getName().getLocalName()), ");");
      if (objectSG.getTypeSG().isComplex()) {
          Context myClassContext =
              child.getObjectSG().getTypeSG().getComplexTypeSG().getClassContext();
          JavaQName serializerClass = myClassContext.getXMLSerializerName();
View Full Code Here

  }

  protected JavaSource getObjectFactory(SchemaSG pController, String pPackageName, List pContextList) {
    JavaQName qName = JavaQNameImpl.getInstance(pPackageName, "ObjectFactory");
    JavaSource js = pController.getJavaSourceFactory().newJavaSource(qName, "public");
    JavaField jf = js.newJavaField("jaxbContext", JAXBContextImpl.class, "private");
    JavaField properties = js.newJavaField("properties", Map.class, "private");

    JavaConstructor jcon = js.newJavaConstructor("public");
    jcon.addThrows(JAXBException.class);
    jcon.addLine(jf, " = (", JAXBContextImpl.class, ") ",
                 JAXBContext.class, ".newInstance(",
View Full Code Here

      while (js.isInnerClass()) {
        js = ((JavaInnerClass) js).getOuterClass();
      }
      JavaField[] fields = js.getFields();
      JavaQName qName = JavaQNameImpl.getInstance(DatatypeConverterInterface.class);
      JavaField converter = null;
      for (int i = 0;  i < fields.length;  i++) {
        if (qName.equals(fields[i].getType())  &&  JavaSource.DEFAULT_PROTECTION.equals(fields[i].getProtection())  &&
            fields[i].isStatic()  &&  fields[i].isFinal()) {
          converter = fields[i];
          break;
        }
      }
      if (converter == null) {
        converter = js.newJavaField("__dataTypeConverter", qName);
        converter.setStatic(true);
        converter.setFinal(true);
        converter.addLine("new ", DatatypeConverterImpl.class, "()");
      }
      return new Object[]{converter, ".parse" + getDatatypeName() + "(", pValue, ")"};
    } else {
      return new Object[]{pData, ".getDatatypeConverter().parse" + getDatatypeName() + "(", pValue, ")"};
    }
View Full Code Here

  public JavaField getXMLField(PropertySG pController, JavaSource pSource) throws SAXException {
    if (pSource.isInterface()) {
      return null;
    }
    JavaQName runtimeType = JavaQNameImpl.getInstance(Map.class);
    JavaField jf = pSource.newJavaField(pController.getXMLFieldName(), runtimeType, JavaSource.PRIVATE);
    jf.setFinal(true);
    jf.addLine("new ", HashMap.class, "()");
    return jf;
  }
View Full Code Here

  protected JavaField getNamespaces(PropertySG pController, JavaSource pSource) throws SAXException {
      if (namespaceList.isAny()  ||  namespaceList.isOther()) {
          return null;
      }
      String namespaces = pController.getXMLFieldName() + "Namespaces";
      JavaField jf = pSource.newJavaField(namespaces, Set.class);
      jf.setStatic(true);
      jf.setFinal(true);
      JavaClassInitializer jci = pSource.newJavaClassInitializer();
      LocalJavaField set = jci.newJavaField(Set.class);
      set.addLine("new ", HashSet.class, "()");
      XsAnyURI[] uris = namespaceList.getUris();
      for (int i = 0;  i < uris.length;  i++) {
View Full Code Here

TOP

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

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.