Package org.apache.ws.jaxme.js

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


      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

      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

  * @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

           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

      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

          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

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

      JavaSource js = pFactory.newJavaSource(pTargetClass);
      versionGenerator.getCloneMethod(js);
    }
View Full Code Here

     super(pName);
  }

   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);
        jcon = js.newJavaConstructor();
        jm = js.newJavaMethod("test", void.class);
        lfj = jm.newJavaField(String.class, "localTest");
      } else {
        js = factory.newJavaSource(JavaQNameImpl.getInstance(PACKAGE_NAME, CLASS_NAME), pProtection);
        js.newJavaInnerClass("Bof", pProtection);
        jf = js.newJavaField("someField", int.class, pProtection);
        jcon = js.newJavaConstructor(pProtection);
        jm = js.newJavaMethod("test", void.class, pProtection);
        lfj = jm.newJavaField(String.class, "localTest");
      }
      lfj.setFinal(true);
      lfj.addLine(JavaSource.getQuoted("abc"));
View Full Code Here

      }
      Assert.assertEquals(s1, s2);
   }

   public void testNull() {
      JavaSource js = getSource(null);
      assertStringEquals(getResult(null), js.toString());
   }
View Full Code Here

TOP

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

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.