Package org.apache.ws.jaxme.js

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


   * the backing object.</p>
   */
  protected JavaConstructor getConstructor(JavaSource pJs,
                                       InterfaceDescription[] pInterfaces)
            throws Exception{
    JavaConstructor jcon = pJs.newJavaConstructor(JavaSource.PROTECTED);
    jcon.addParam(Object.class, "o");
    jcon.addIf("o == null");
    jcon.addThrowNew(NullPointerException.class,
                 JavaSource.getQuoted("The supplied object must not be null."));
    jcon.addEndIf();
    for (int i = 0;  i < pInterfaces.length;  i++) {
      if (pInterfaces[i].isMandatory()) {
                JavaSource js = pInterfaces[i].getJavaSource();
        jcon.addIf("!(o instanceof ", js.getQName(), ")");
        jcon.addThrowNew(ClassCastException.class,
                     JavaSource.getQuoted("The supplied instance of "),
                 " + o.getClass().getName() + ",
                 JavaSource.getQuoted(" is not implementing "),
                 " + ", js.getQName(), ".class.getName()");
        jcon.addEndIf();
      }
    }
    jcon.addLine("backingObject = o;");
    return jcon;
  }
View Full Code Here


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

    JavaConstructor[] constructors = pJs.getConstructors();
    if (constructors.length == 0) {
      return;
    }
    for (int i = 0;  i < constructors.length;  i++) {
      JavaConstructor jc = constructors[i];
      if (jc.getProtection().equals(JavaSource.PUBLIC&&
        jc.getParams().length == 0) {
        return;
      }
    }
    throw new BeanReaderException("The class " + pJs.getType()
        + " doesn't have a default constructor.");
View Full Code Here

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

    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(",
                 JavaSource.getQuoted(pPackageName), ");");

    JavaMethod newInstanceMethod = js.newJavaMethod("newInstance", Object.class, "public");
    newInstanceMethod.addThrows(JAXBException.class);
View Full Code Here

    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(",
                 JavaSource.getQuoted(pPackageName), ");");

    JavaMethod newInstanceMethod = js.newJavaMethod("newInstance", Object.class, "public");
    newInstanceMethod.addThrows(JAXBException.class);
View Full Code Here

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

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

        if (sb.length() > 0) {
            sb.append(':');
        }
        sb.append(iter.next());
    }
    JavaConstructor jcon = js.newJavaConstructor("public");
    jcon.addThrows(JAXBException.class);
    jcon.addLine(jf, " = (", JAXBContextImpl.class, ") ",
            JAXBContext.class, ".newInstance(",
            JavaSource.getQuoted(sb.toString()), ");");
    return js;
  }
View Full Code Here

     protected JavaField getBackingObjectField(JavaSource pJs, InterfaceDescription[] pInterfaces) {
       return pJs.newJavaField("backingObject", getChainInterface(), JavaSource.PRIVATE);
     }
     protected JavaConstructor getConstructor(JavaSource pJs,
                       InterfaceDescription[] pInterfaces) {
       JavaConstructor jcon = pJs.newJavaConstructor(JavaSource.PROTECTED);
       jcon.addParam(getChainInterface(), "o");
       jcon.addIf("o == null");
       jcon.addThrowNew(NullPointerException.class,
           JavaSource.getQuoted("The supplied object must not be null."));
       jcon.addEndIf();
       jcon.addLine("backingObject = o;");
       return jcon;
     }
View Full Code Here

TOP

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

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.