Examples of JavaSourceFactory


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

   * @param sourceClass
   * @param output
   * @throws IOException
   */
  private void createInformerFor(JavaSource sourceClass, File output) throws Exception {
    JavaSourceFactory factory = new JavaSourceFactory();
    factory.setOverwriteForced(true);
    // Let the factory create a Java source class
    // "com.mycompany.demo.Parser"
    JavaQName className = getBusinessInformer(sourceClass.getQName());
    JavaSource js = factory.newJavaSource(className, "public");
    JavaComment comment = js.newComment();
    comment.addLine("");
    comment.addLine("Define improved Informer for "+sourceClass.getClassName()+".");
    comment.addLine("Elements of this method allows easier usage of improved gaedo finders.");
    comment.addLine("The instances of FieldInformer used for that class various fields have been chosen according to FieldInformerLocator current implementation.");
    comment.addLine("As a consequence, the behaviour of this method has guaranteed comaptibilty with most of gaedo code");
    comment.addLine("");
    comment.addLine("@see "+sourceClass.getQName().toString());
    comment.addSee(JavaQNameImpl.getInstance(FieldInformer.class).toString());
    comment.addSee(JavaQNameImpl.getInstance(FieldInformerLocator.class).toString());
    comment.addAuthor("created by gaedo-informer generator on "+format.format(new Date()));
    js.setDynamicImports(true);
    js.setType(js.INTERFACE);
    js.setProtection(js.PUBLIC);
    js.addExtends(Informer.class);
    JavaField[] fields = sourceClass.getFields();
    for(JavaField f : fields) {
      if(isWritable(f))
        createDeclaration(js, sourceClass, f);
    }
    factory.write(output);
  }
View Full Code Here

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

    public abstract void generate(JavaSourceFactory pFactory, JavaQName pTargetClass)
        throws Exception;
    public void doExecute() {
       finish();
       try {
        JavaSourceFactory factory = new JavaSourceFactory();
        generate(factory, targetClass);
        factory.write(getDestDir());
       } catch (Exception e) {
         throw new BuildException(e, getLocation());
       }
    }
View Full Code Here

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

           throw new BuildException("At least one nested 'chain' element must be given.",
                                     getLocation());
        }
     }
     public void doExecute() {
        JavaSourceFactory pFactory = new JavaSourceFactory();
        for (Iterator iter = chains.iterator();  iter.hasNext()) {
           ChainGenerator chain = (ChainGenerator) iter.next();
           try {
               chain.generate(pFactory);
           } catch (Exception e) {
               throw new BuildException(e, getLocation());
           }
        }
        try {
           pFactory.write(getDestDir());
        } catch (IOException e) {
           throw new BuildException(e, getLocation());
        }
     }
View Full Code Here

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

                                         getLocation());
            }
        }

    public void doExecute() throws Exception {
            JavaSourceFactory jsf = new JavaSourceFactory();
            JavaSourceFactory inputs = new JavaSourceFactory();
            XmlRpcClientGenerator gen = new XmlRpcClientGenerator(jsf, getTargetPackage());
            List sources = new ArrayList();
            for (int i = 0;  i < serverClasses.size();  i++) {
              FileSet fs = (FileSet) serverClasses.get(i);
                DirectoryScanner ds = fs.getDirectoryScanner(getProject());
View Full Code Here

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

    /** For tests
     */
    public static void main(String[] args) throws Exception {
      for (int i = 0;  i < args.length;  i++) {
        new JavaParser(new JavaSourceFactory()).parse(new File(args[i]));
        }
    }
View Full Code Here

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

      for (int i = 0;  i < schemaFiles.length;  i++) {
        log("Reading schema file " + schemaFiles[i], Project.MSG_VERBOSE);
        try {
      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();
              File f = jsf.getLocation(targetDirectory, tf).getAbsoluteFile();
              producesFilesSet.remove(f);
            }
          }
        } catch (SAXParseException e) {
            String msg = LocSAXException.formatMsg(e.getMessage() == null ? e.getClass().getName() : e.getMessage(),
View Full Code Here

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

  }

  private JavaSourceResolver getResolver()
      throws TokenStreamException, RecognitionException {
    final Map sourcesByName = new HashMap();
    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);
View Full Code Here

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

    File targetDir = getTargetDirectory();
    File resourceTargetDir = getResourceTargetDirectory();
    if (resourceTargetDir == null) {
      resourceTargetDir = targetDir;
    }
    JavaSourceFactory jsf = s.getJavaSourceFactory();
    for (Iterator iter = jsf.getJavaSources();  iter.hasNext()) {
      ((JavaSource) iter.next()).setForcingFullyQualifiedName(true);
    }
    s.getJavaSourceFactory().write(targetDir, resourceTargetDir);
   
    return s;
View Full Code Here

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

  public BasicTest(String pName) {
     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");
View Full Code Here

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

      JavaSource js = getSource(JavaSource.PUBLIC);
      assertStringEquals(getResult(JavaSource.PUBLIC), js.toString());
   }

   public void testAbstract() {
     JavaSourceFactory factory = new JavaSourceFactory();
     JavaSource js = factory.newJavaSource(JavaQNameImpl.getInstance("com.foo", "Bar"), JavaSource.PUBLIC);
     js.setAbstract(true);
     JavaMethod jm = js.newJavaMethod("test", JavaQNameImpl.VOID, JavaSource.PUBLIC);
     jm.setAbstract(true);
     assertStringEquals("public abstract void test();\n", jm.asString());
     assertStringEquals("package com.foo;\n" +
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.