Package org.apache.ws.jaxme.js

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


  protected JavaSource getObjectFactory(SchemaSG pController, String pPackageName,
                      List pContextList)
      throws SAXException {
    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);
    Parameter pElementInterface = newInstanceMethod.addParam(Class.class, "pElementInterface");
    newInstanceMethod.addLine("return ", jf, ".getManager(", pElementInterface, ").getElementJ();");

    {
      JavaMethod getPropertyMethod = js.newJavaMethod("getProperty", Object.class, "public");
      Parameter pName = getPropertyMethod.addParam(String.class, "pName");
      getPropertyMethod.addIf(properties, " == null");
      getPropertyMethod.addLine("return null;");
      getPropertyMethod.addEndIf();
      getPropertyMethod.addLine("return ", properties, ".get(", pName, ");");
    }

    {
      JavaMethod setPropertyMethod = js.newJavaMethod("setProperty", void.class, "public");
      Parameter pName = setPropertyMethod.addParam(String.class, "pName");
      Parameter pValue = setPropertyMethod.addParam(Object.class, "pValue");
      setPropertyMethod.addIf(properties, " == null");
      setPropertyMethod.addLine(properties, " = new ", HashMap.class, "();");
      setPropertyMethod.addEndIf();
View Full Code Here


    public Object newObjectSG(SGFactory pFactory, XSElement pElement) throws SAXException {
        ObjectSGChain chain = (ObjectSGChain) super.newObjectSG(pFactory, pElement);
        chain = new ObjectSGChainImpl(chain){
            public JavaSource getXMLImplementation(ObjectSG pController) throws SAXException {
                JavaSource result = super.getXMLImplementation(pController);
                if (result == null) {
                  return null;
                }
                JavaQName[] interfaces = result.getImplements();
                boolean done = false;
                result.clearImplements();
                for (int i = 0;  i < interfaces.length;  i++) {
                    JavaQName interfaceName = interfaces[i];
                    if (interfaceName.equals(JMELEMENT_TYPE||
                        interfaceName.equals(INO_OBJECT_TYPE)) {
                        if (!done) {
                            result.addImplements(INO_OBJECT_TYPE);
                            done = true;
                        }
                    } else {
                        result.addImplements(interfaceName);
                    }
                }
                if (!done) {
                    result.addImplements(INO_OBJECT_TYPE);
                }
                return result;
            }
        };
        return chain;
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

    final JavaSourceFactory jsf = new JavaSourceFactory();
    JavaParser parser = new JavaParser(jsf);
    for (int i = 0;  i < sources.length;  i++) {
      List list = parser.parse(new StringReader(sources[i]));
      for (int j = 0;  j < list.size();  j++) {
        JavaSource js = (JavaSource) list.get(i);
        register(sourcesByName, js);
      }
    }
    return new JavaSourceResolver(){
      public JavaSource getJavaSource(JavaQName pQName) {
        String key = asKey(pQName);
        JavaSource js = (JavaSource) sourcesByName.get(key);
        if (js != null) {
          return js;
        }
        Class c;
        try {
View Full Code Here

    /** Creates a new client class, which is invoking the given
     * server side class <code>pSource</code>.
     */
    public JavaSource addClass(JavaSource pSource, JavaSourceResolver pResolver)
            throws SecurityException, NoSuchMethodException {
        JavaSource js = getFactory().newJavaSource(JavaQNameImpl.getInstance(getTargetPackage(), pSource.getQName().getClassName()), JavaSource.PUBLIC);
        JavaField jf = getXmlRpcCaller(js);
        getConstructor(js, jf);
        Map keys = new HashMap();
        addMethods(js, pSource, keys, jf, pResolver);
        return js;
View Full Code Here

            }
        }
        if (pResolver != null) {
            JavaQName[] qNames = pSource.getExtends();
            for (int i = 0;  i < qNames.length;  i++) {
              JavaSource js = pResolver.getJavaSource(qNames[i]);
                if (js != null) {
                  addMethods(pResult, js, pKeys, pField, pResolver);
                }
            }
        }
View Full Code Here

        int num = 0;
        for (Iterator iter = methods.entrySet().iterator();  iter.hasNext()) {
            Map.Entry entry = (Map.Entry) iter.next();
            String name = (String) entry.getKey();
            JavaMethod method = (JavaMethod) entry.getValue();
            JavaSource innerClass = getInvoker(pSource, method, pInvoker, num++);
            con.addLine(pMap, ".put(", JavaSource.getQuoted(name), ", new ", innerClass.getQName(), "());");
        }
        return con;
    }
View Full Code Here

    /** Creates the dispatcher class. Make sure, that this method
     * is invoked <em>after</em> {@link #addClass(JavaSource, JavaSourceResolver)}!
     * @param pQName Fully qualified class name of the dispatcher class.
     */
    public JavaSource getDispatcher(JavaQName pQName) {
      JavaSource js = getFactory().newJavaSource(pQName, JavaSource.PUBLIC);
        if (isDispatcherImplementsXmlRpcHandler()) {
          js.addImport(JavaQNameImpl.getInstance("org.apache.xmlrpc.XmlRpcHandler"));
        }
      JavaComment comment = js.newComment();
        comment.addLine("The dispatcher is being used by the XmlRpcServer.");
        comment.addLine("It delegates incoming XML-RPC calls to the classes");
        comment.addLine("and methods, for which client classes have been");
        comment.addLine("created by the " +
                        XmlRpcClientGenerator.class.getName() + ".");
        JavaSource invoker = getInvokerClass(js);
        JavaField map = getInvokerMap(js);
        getDispatcherConstructor(js, map, invoker.getQName());
        getGetInvokerMethod(js, invoker.getQName(), map);
        getDispatcherInvokeMethod(js, invoker.getQName());
        return js;
    }
View Full Code Here

  }
 
  public TypedValue getCastFromString(SimpleTypeSG pController, JavaMethod pMethod, Object pValue, Object pData) throws SAXException {
  Object value;
  if (pData == null) {
      JavaSource js = pMethod.getJavaSource();
      while (js.isInnerClass()) {
        js = ((JavaInnerClass) js).getOuterClass();
      }
      JavaField[] fields = js.getFields();
      JavaQName qName = JavaQNameImpl.getInstance(DatatypeConverterInterface.class);
      JavaField converter = null;
      for (int i = 0;  i < fields.length;  i++) {
        if (qName.equals(fields[i].getType())  &&  JavaSource.DEFAULT_PROTECTION.equals(fields[i].getProtection())  &&
            fields[i].isStatic()  &&  fields[i].isFinal()) {
          converter = fields[i];
          break;
        }
      }
      if (converter == null) {
        converter = js.newJavaField("__dataTypeConverter", qName);
        converter.setStatic(true);
        converter.setFinal(true);
        converter.addLine("new ", DatatypeConverterImpl.class, "()");
      }
      value = new Object[]{converter, ".parse" + getDatatypeName() + "(", pValue, ")"};
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

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.