Examples of JavaSource


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

  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

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

      return null;
    }

    JavaQName xmlInterfaceName = pController.getClassContext().getXMLInterfaceName();
    JavaSourceFactory jsf = getSchema().getJavaSourceFactory();
    JavaSource js = jsf.newJavaSource(xmlInterfaceName, JavaSource.PUBLIC);
    js.setType(JavaSource.INTERFACE);
    js.addExtends(Element.class);

    TypeSG myTypeSG = pController.getTypeSG();
    ComplexTypeSG complexTypeSG = myTypeSG.getComplexTypeSG();
    if (myTypeSG.isGlobalClass()) {
      js.addExtends(complexTypeSG.getClassContext().getXMLInterfaceName());
      // No need to generate the types XML interface; this is done by the schema
    } else {
      complexTypeSG.generateXMLInterfaceMethods(js);
    }
    log.finest(mName, "<-", xmlInterfaceName);
View Full Code Here

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

      return null;
    }

    JavaQName xmlImplementationName = pController.getClassContext().getXMLImplementationName();
    JavaSourceFactory jsf = getSchema().getJavaSourceFactory();
    JavaSource js = jsf.newJavaSource(xmlImplementationName, JavaSource.PUBLIC);
    js.addImplements(pController.getClassContext().getXMLInterfaceName());
    js.addImplements(JMElement.class);

    TypeSG myTypeSG = pController.getTypeSG();
    ComplexTypeSG complexTypeSG = myTypeSG.getComplexTypeSG();
    if (myTypeSG.isGlobalClass()) {
      js.addExtends(complexTypeSG.getClassContext().getXMLImplementationName());
      // No need to generate the types XML implementation; this is done by the schema.
    } else {
      complexTypeSG.generateXMLImplementationMethods(js);
    }

    JavaField myName = js.newJavaField("__qName", QName.class, JavaSource.PRIVATE);
    myName.setStatic(true);
    myName.setFinal(true);
    XsQName qName = pController.getName();
    myName.addLine("new ", QName.class, "(", JavaSource.getQuoted(qName.getNamespaceURI()),
                   ", ", JavaSource.getQuoted(qName.getLocalName()), ")");

    JavaMethod getQName = js.newJavaMethod("getQName", QName.class, JavaSource.PUBLIC);
    getQName.addLine("return ", myName, ";");

    return js;
  }
View Full Code Here

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

      return null;
    }

    JavaQName xmlSerializerName = pController.getClassContext().getXMLSerializerName();
    JavaSourceFactory jsf = getSchema().getJavaSourceFactory();
    JavaSource js = jsf.newJavaSource(xmlSerializerName, JavaSource.PUBLIC);
    js.addImplements(JMXmlSerializer.class);
    myTypeSG.getComplexTypeSG().generateXMLSerializerMethods(js);
    return js;
  }
View Full Code Here

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

      log.finest(mName, "<-", null);
      return null;
    } else {
      JavaQName xmlHandlerName = pController.getClassContext().getXMLHandlerName();
      JavaSourceFactory jsf = getSchema().getJavaSourceFactory();
      JavaSource js = jsf.newJavaSource(xmlHandlerName, JavaSource.PUBLIC);
      js.addImplements(JMHandler.class);
      if (myTypeSG.isGlobalClass()) {
        Context typeContext = myTypeSG.getComplexTypeSG().getClassContext();
        js.addExtends(typeContext.getXMLHandlerName());
        JavaQName xmlElementInterface = pController.getClassContext().getXMLInterfaceName();
        JavaQName resultInterface = typeContext.getXMLInterfaceName();
        JavaMethod jm = js.newJavaMethod("newResult", resultInterface, JavaSource.PROTECTED);
        jm.addThrows(SAXException.class);
        jm.addTry();
        jm.addLine("return (", resultInterface, ") getData().getFactory().getElement(",
                   xmlElementInterface, ".class);");
        DirectAccessible e = jm.addCatch(JAXBException.class);
View Full Code Here

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

  * @param pItems The enumeration items; a public, static, final instance
  *   will be generated for any element in the array
  */
  public JavaSource generate(JavaSourceFactory pFactory, JavaQName pTargetClass,
                             Item[] pItems) {
   JavaSource result = pFactory.newJavaSource(pTargetClass, JavaSource.PUBLIC);
    doGenerate(result, pItems);
   return result;
  }
View Full Code Here

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

           return jm;
         }
         public JavaSource generate(JavaSourceFactory pInterfaceFactory,
                                     JavaQName pTargetClass,
                                     ProxyGenerator.InterfaceDescription[] pDescription) {
            JavaSource result = super.generate(pInterfaceFactory, pTargetClass,
                                               pDescription);
            result.clearImplements();
            return result;
         }
      };
      JavaSource proxyInterface = proxyInterfaceGenerator.generate(pFactory, getChainInterface(), interfaces);
      proxyInterface.setType(JavaSource.INTERFACE);

      ProxyGenerator proxyImplementationGenerator = new ProxyGenerator(){
         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;
         }

         public JavaMethod getInterfaceMethod(JavaSource pSource,
                                               ProxyGenerator.InterfaceDescription pDescription,
                                               java.lang.reflect.Method pMethod) {
            JavaMethod jm = pSource.newJavaMethod(pMethod);
            Parameter[] parameters = jm.getParams();
            JavaQName controllerInterfaceQName = JavaQNameImpl.getInstance(getControllerInterface());
            jm.clearParams();
            jm.addParam(controllerInterfaceQName, "pController");
            for (int i = 0;  i < parameters.length;  i++) {
               jm.addParam(parameters[i]);
            }
            List callParameters = new ArrayList();
            callParameters.add("pController");
            for (int i = 0;  i < parameters.length;  i++) {
               Parameter parameter = parameters[i];
                     callParameters.add(", ");
                  callParameters.add(parameter.getName());
               }
            jm.addLine((void.class.equals(pMethod.getReturnType()) ? "" : " return "),
                       "backingObject.",
                       pMethod.getName(), "(", callParameters, ");");
            return jm;
         }
         public JavaSource generate(JavaSourceFactory pImplementationFactory,
                                     JavaQName pTargetClass,
                                     ProxyGenerator.InterfaceDescription[] pDescription) {
            JavaSource result = super.generate(pImplementationFactory, pTargetClass, pDescription);
            result.clearImplements();
            result.addImplements(getChainInterface());
            return result;
         }
      };
      JavaSource proxyImplementation = proxyImplementationGenerator.generate(pFactory, getProxyClass(), interfaces);

      ProxyGenerator controllerImplementationGenerator = new ProxyGenerator(){
         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.PUBLIC);
            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;
         }
         public JavaMethod getInterfaceMethod(JavaSource pSource,
                                               ProxyGenerator.InterfaceDescription pDescription,
                                               java.lang.reflect.Method pMethod) {
            JavaMethod jm = pSource.newJavaMethod(pMethod);
            Parameter[] parameters = jm.getParams();
            List callParameters = new ArrayList();
            callParameters.add("this");
            for (int i = 0;  i < parameters.length;  i++) {
               Parameter parameter = parameters[i];
                     callParameters.add(", ");
                  callParameters.add(parameter.getName());
               }
            jm.addLine((void.class.equals(pMethod.getReturnType()) ? "" : " return "),
                       "backingObject.",
                       pMethod.getName(), "(", callParameters, ");");
            return jm;
         }
         protected JavaMethod getGetHeadOfChainMethod(JavaSource pSource) {
           JavaMethod jm = pSource.newJavaMethod("getHeadOfChain",
                                                 getChainInterface(),
                                                 JavaSource.PUBLIC);
           jm.addLine("return backingObject;");
           return jm;
         }
         public JavaSource generate(JavaSourceFactory pImplementationFactory,
                                    JavaQName pTargetClass,
                                    ProxyGenerator.InterfaceDescription[] pDescription) {
           JavaSource result = super.generate(pImplementationFactory, pTargetClass, pDescription);
           getGetHeadOfChainMethod(result);
           return result;
         }
      };
      JavaSource controllerImplementation = controllerImplementationGenerator.generate(pFactory, getImplementationClass(), interfaces);

      return new JavaSource[]{controllerImplementation, proxyInterface, proxyImplementation};
   }
View Full Code Here

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

      if (pInterfaces[i] == null  ||  pInterfaces[i].interfaceClass == null) {
        throw new NullPointerException("The interfaces being implemented must be non-null");
      }
     }

    JavaSource js = getJavaSource(pFactory, pTargetName);
    if (getExtendedClass() != null) {
      js.addExtends(getExtendedClass());
    }
    for (int i = 0;  i < pInterfaces.length;  i++) {
      js.addImplements(pInterfaces[i].getInterface());
    }

    getBackingObjectField(js, pInterfaces);
    getConstructor(js, pInterfaces);
View Full Code Here

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

          SchemaSG schemaSG = generator.generate(schemaFiles[i]);
          if (producesFilesSet != null) {
            JavaSourceFactory jsf = schemaSG.getJavaSourceFactory();
            File targetDirectory = getTarget();
            for (Iterator iter = jsf.getJavaSources();  iter.hasNext()) {
              JavaSource js = (JavaSource) iter.next();
              File f = jsf.getLocation(targetDirectory, js).getAbsoluteFile();
              producesFilesSet.remove(f);
            }
            for (Iterator iter = jsf.getTextFiles();  iter.hasNext()) {
              TextFile tf = (TextFile) iter.next();
View Full Code Here

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

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

      JavaSource js = pFactory.newJavaSource(pTargetClass);
      versionGenerator.getCloneMethod(js);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.