Package org.apache.ws.jaxme.js

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


      return jm;
  }

  public JavaMethod getXMLSetMethod(PropertySG pController, JavaSource pSource) throws SAXException {
      JavaMethod jm = pSource.newJavaMethod(pController.getXMLSetMethodName(), void.class, JavaSource.PUBLIC);
      JavaComment jc = jm.newComment();
      jc.addLine("<p>Sets the 'anyAttribute' named <code>pName</code> to the value <code>pValue</code>.</p>");
      if (!namespaceList.isAny()) {
          jc.addLine("@throws IllegalArgumentException The namespace <code>pName.getNamespaceURI()</code> is invalid.");
      }
      jc.addLine("@throws NullPointerException Either of the arguments <code>pName</code> or <code>pValue</code> is null.");
      Parameter pName = jm.addParam(QName.class, "pName");
      Parameter pValue = jm.addParam(String.class, "pValue");
      if (!pSource.isInterface()) {
        jm.addIf(pName, " == null");
        jm.addThrowNew(NullPointerException.class, JavaSource.getQuoted("The pName argument must not be null."));
View Full Code Here


      return jm;
  }

  public JavaMethod getXMLUnsetMethod(PropertySG pController, JavaSource pSource) throws SAXException {
      JavaMethod jm = pSource.newJavaMethod("un" + pController.getXMLSetMethodName(), boolean.class, JavaSource.PUBLIC);
      JavaComment jc = jm.newComment();
      jc.addLine("<p>Removes the 'anyAttribute' named <code>pName</code>.</p>");
      if (!namespaceList.isAny()) {
          jc.addLine("@throws IllegalArgumentException The namespace <code>pName.getNamespaceURI()</code> is invalid.");
      }
      jc.addLine("@throws NullPointerException Either of the arguments <code>pName</code> or <code>pValue</code> is null.");
      jc.addLine("@return True, if the attribute was set, otherwise false.");
      Parameter pName = jm.addParam(QName.class, "pName");
      if (!pSource.isInterface()) {
        jm.addIf(pName, " == null");
        jm.addThrowNew(NullPointerException.class, JavaSource.getQuoted("The pName argument must not be null."));
        jm.addEndIf();
View Full Code Here

      return jm;
  }

  public JavaMethod getXMLGetArrayMethod(PropertySG pController, JavaSource pSource) throws SAXException {
      JavaMethod jm = pSource.newJavaMethod(pController.getXMLGetMethodName() + "Array", WildcardAttribute[].class, JavaSource.PUBLIC);
      JavaComment jc = jm.newComment();
      jc.addLine("<p>Returns the array of 'anyAttributes'.</p>");
      LocalJavaField size = jm.newJavaField(int.class);
      size.addLine(pController.getXMLFieldName(), ".size()");
      LocalJavaField result = jm.newJavaField(jm.getType());
      result.addLine("new ", WildcardAttribute.class, "[", size, "]");
      DirectAccessible iter = jm.addForCollection(new Object[]{pController.getXMLFieldName(), ".entrySet()"});
View Full Code Here

  private JavaField getXMLHandlersStateField(GroupSG pController, JavaSource pSource) throws SAXException {
    ParticleSG[] myParticles = pController.getParticles();
    if (myParticles.length > 0) {
      JavaField jf = pSource.newJavaField("__state", int.class, JavaSource.PRIVATE);
      JavaComment jc = jf.newComment();
      jc.addLine("The current state. The following values are valid states:");
      jc.addLine(" 0 = Before parsing the element");
      jc.addLine(" 1 = Parsing an unknown element");
      jc.addLine(" 2 = After parsing the element");
      for (int i = 0;  i < myParticles.length;  i++) {
          ParticleSG particle = myParticles[i];
          if (particle.isGroup()) {
              // TODO: process group case properly.
              continue;
          } else if (particle.isElement()) {
              jc.addLine(" " + (3+i) + " = While parsing the child element " + myParticles[i].getObjectSG().getName());
          } else if (particle.isWildcard()) {
              jc.addLine(" " + (3+i) + " = While parsing the wildcard");
          } else {
              throw new IllegalStateException("Invalid particle type.");
          }
      }
View Full Code Here

   JavaMethod getInstanceByName = pSource.newJavaMethod("getInstanceByName",
                                                       pSource.getQName(),
                                                       JavaSource.PUBLIC);
    getInstanceByName.setStatic(true);
   getInstanceByName.addParam(String.class, "pName");
   JavaComment jc = getInstanceByName.newComment();
   jc.addLine("Returns the item with the given name.</p>");
   jc.addThrows(IllegalArgumentException.class.getName() +
               " The name <code>pName</code> is invalid and no such item exists.");
   getInstanceByName.addLine(String.class, " s = pName.intern();");
   boolean first = true;
   for (int i = 0;  i < pItems.length;  i++) {
    Item item = pItems[i];
    Object[] args = new Object[]{JavaSource.getQuoted(item.getName()), " == s"};
     getInstanceByName.addIf(first, args);
     getInstanceByName.addLine("return ", item.getName(), ";");
     first = false;
   }
   getInstanceByName.addElse();
   getInstanceByName.addLine("throw new ", IllegalArgumentException.class, "(",
                             JavaSource.getQuoted("Invalid name: "),
                              " + pName);");
   getInstanceByName.addEndIf();

   JavaMethod getInstanceByValue = pSource.newJavaMethod("getInstanceByValue",
                                       pSource.getQName(),
                                       JavaSource.PUBLIC);
   getInstanceByValue.setStatic(true);
   getInstanceByValue.addParam(String.class, "pValue");
   jc = getInstanceByValue.newComment();
   jc.addLine("Returns the item with the given value.</p>");
   jc.addThrows(IllegalArgumentException.class.getName() +
            " The name <code>pValue</code> is invalid and no such item exists.");
   getInstanceByValue.addLine(String.class, " s = pValue.intern();");
   first = true;
   for (int i = 0;  i < pItems.length;  i++) {
    Item item = pItems[i];
View Full Code Here

    JavaQName type = f.getType();
    if(type.getPackageName().startsWith("java")) {
      try {
        // we suppose java types are good boys, willing to work quietly
        JavaMethod method = js.newJavaMethod(getMethodName(f), getFieldInformerType(type));
        JavaComment comment = method.newComment();
        comment.addLine("");
        comment.addLine("Gets the FieldInformer associated to "+f.getName()+
            ". its type has been defined according to FieldInformerLocator current implementation code.");
        comment.addSee(f.getJavaSource().getQName().toString()+"#"+f.getName());
      } catch(NoInformerForThisType e) {
        logger.log(Level.FINE, "unable to find an informer for field "+f.toString()+" of class "+sourceClass.getClassName(), e);
      }
    }
  }
View Full Code Here

    factory.setOverwriteForced(true);
    // Let the factory create a Java source class
    // "com.mycompany.demo.Parser"
    JavaQName className = getBusinessInformer(sourceClass.getQName());
    JavaSource js = factory.newJavaSource(className, "public");
    JavaComment comment = js.newComment();
    comment.addLine("");
    comment.addLine("Define improved Informer for "+sourceClass.getClassName()+".");
    comment.addLine("Elements of this method allows easier usage of improved gaedo finders.");
    comment.addLine("The instances of FieldInformer used for that class various fields have been chosen according to FieldInformerLocator current implementation.");
    comment.addLine("As a consequence, the behaviour of this method has guaranteed comaptibilty with most of gaedo code");
    comment.addLine("");
    comment.addLine("@see "+sourceClass.getQName().toString());
    comment.addSee(JavaQNameImpl.getInstance(FieldInformer.class).toString());
    comment.addSee(JavaQNameImpl.getInstance(FieldInformerLocator.class).toString());
    comment.addAuthor("created by gaedo-informer generator on "+format.format(new Date()));
    js.setDynamicImports(true);
    js.setType(js.INTERFACE);
    js.setProtection(js.PUBLIC);
    js.addExtends(Informer.class);
    JavaField[] fields = sourceClass.getFields();
View Full Code Here

    return pState-1;
  }

  protected JavaField newStateField() throws SAXException {
    JavaField jf = getJavaSource().newJavaField("__state", int.class, JavaSource.PRIVATE);
    JavaComment jc = jf.newComment();
    jc.addLine("The current state. The following values are valid states:");
    jc.addLine(" 0 = Before parsing the element");
    for (int i = 0;  i < particles.length;  i++) {
      ParticleSG particle = particles[i];
      if (particle.isGroup()) {
        GroupSG group = particle.getGroupSG();
        if (group.isGlobal()) {
          jc.addLine(" " + getState(i) + " = While parsing the nested group " + group.getName());
        } else {
          jc.addLine(" " + getState(i) + " = While parsing the nested group " + GroupUtil.getGroupName(group));
        }
      } else if (particle.isElement()) {
        jc.addLine(" " + getState(i) + " = While or after parsing the child element " + particle.getObjectSG().getName());
      } else if (particle.isWildcard()) {
        throw new IllegalStateException("TODO: Add support for wildcards.");
      } else {
        throw new IllegalStateException("Invalid particle type.");
      }
View Full Code Here

  }

  private JavaField getChildNumField() {
    if (childNumField == null) {
      childNumField = getJavaSource().newJavaField("__childNum", int.class, JavaSource.PRIVATE);
      JavaComment jc = childNumField.newComment();
      jc.addLine("Index of the particle being currently parsed");
    }
    return childNumField;
  }
View Full Code Here

    return result;
  }

  protected JavaField newStateField() throws SAXException {
    JavaField jf = getJavaSource().newJavaField("__state", boolean.class, JavaSource.PRIVATE);
    JavaComment jc = jf.newComment();
    jc.addLine("Will be set to true, if the first child is parsed.");
    jc.addLine("It is an error, if another child is parsed, and the");
    jc.addLine("fields value is true.");
    return jf;
  }
View Full Code Here

TOP

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

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.