Package org.apache.ws.jaxme.js

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


  }
 
  /** <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, ";");
    jcon.addLine(values, " = ", pValues, ";");
   
    JavaMethod getNameMethod = jic.newJavaMethod("getName", String.class, JavaSource.PUBLIC);
    getNameMethod.addLine("return ", name, ";");
   
    JavaMethod getValuesMethod = jic.newJavaMethod("getValues", Object[].class, JavaSource.PUBLIC);
    getValuesMethod.addLine("return ", values, ";");
   
    {
      JavaMethod jm = jic.newJavaMethod("toString", String.class, JavaSource.PUBLIC);
      LocalJavaField sb = jm.newJavaField(StringBuffer.class, "sb");
      sb.addLine("new ", StringBuffer.class, "(", name, ")");
      DirectAccessible loopVar = jm.addForArray(values);
      jm.addLine(sb, ".append(", JavaSource.getQuoted(", "), ").append(",
          values, "[", loopVar, "]);");
      jm.addEndFor();
      jm.addLine("return ", sb, ".toString();");
     
    }
   
    {
      JavaMethod jm = jic.newJavaMethod("hashCode", int.class, JavaSource.PUBLIC);
      LocalJavaField hashCodeResult = jm.newJavaField(int.class, "result");
      hashCodeResult.addLine(name, ".hashCode() + ", values, ".length;");
      DirectAccessible loopVar = jm.addForArray(values);
      LocalJavaField o = jm.newJavaField(Object.class, "o");
      o.addLine(values, "[", loopVar, "]");
      jm.addIf(o, " != null");
      jm.addLine(hashCodeResult, " += ", o, ".hashCode();");
      jm.addEndIf();
      jm.addEndFor();
      jm.addLine("return ", hashCodeResult, ";");
    }
   
    {
      JavaMethod jm = jic.newJavaMethod("equals", boolean.class, JavaSource.PUBLIC);
      DirectAccessible o = jm.addParam(Object.class, "o");
      jm.addIf(o, " == null  ||  !(", o, " instanceof ", jic.getQName(), ")");
      jm.addLine("return false;");
      jm.addEndIf();
      LocalJavaField other = jm.newJavaField(jic.getQName(), "other");
      other.addLine("(", jic.getQName(), ") ", o);
      jm.addIf("!", name, ".equals(", other, ".name)  ||  ", values, ".length != ",
          other, ".values.length");
      jm.addLine("return false;");
      jm.addEndIf();
      DirectAccessible loopVar = jm.addForArray(values);
View Full Code Here


  * @param pName Name of the inner class
  * @param pItems The enumeration items; a public, static, final instance
  *   will be generated for any element in the array
  */
  public JavaInnerClass generate(JavaSource pSource, String pName, Item[] pItems) {
   JavaInnerClass result = pSource.newJavaInnerClass(pName, JavaSource.PUBLIC);
   result.setStatic(true);
   doGenerate(result, pItems);
   return result;
  }
View Full Code Here

    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);
    } else if (pGroup.isAll()) {
View Full Code Here

TOP

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

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.