You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlbeans-cvs@xml.apache.org by pc...@apache.org on 2004/02/14 03:11:07 UTC

cvs commit: xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal JServiceParamsImpl.java

pcal        2004/02/13 18:11:07

  Modified:    v2/src/jam/org/apache/xmlbeans/impl/jam JServiceParams.java
               v2/src/jam/org/apache/xmlbeans/impl/jam/internal
                        JServiceParamsImpl.java
  Log:
  jam: new methods on JServiceParams
  
  Revision  Changes    Path
  1.3       +71 -2     xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/JServiceParams.java
  
  Index: JServiceParams.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/JServiceParams.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JServiceParams.java	12 Feb 2004 20:06:09 -0000	1.2
  +++ JServiceParams.java	14 Feb 2004 02:11:07 -0000	1.3
  @@ -30,8 +30,9 @@
   
     /**
      * Specifies a set of java source files to be included in the JService.
  -   * Note that calling this method implicitly includes the 'root' in
  -   * the sourcepath (as in a call to addSourcepath(root)).
  +   *
  +   * <p>Note that calling this method implicitly includes the 'root' in
  +   * the sourcepath (exactly as if addSourcepath(root) had been called).</p>
      *
      * @param root Root directory of the source files.
      * @param pattern A relative file pattern (as described above under
  @@ -52,6 +53,7 @@
      */
     public void excludeSourceFiles(File root, String pattern);
   
  +
     /**
      * Specifies a set of java class files to be excluded in the JService.
      * Note that calling this method implicitly includes the 'root' in
  @@ -77,6 +79,59 @@
     public void excludeClassFiles(File root, String pattern);
   
     /**
  +   * <p>Includes a single source File in the JService.  The root parameter
  +   * should identify the source root of the java source file; the sourceFile
  +   * parameter must be under the root subtree.</p>
  +   *
  +   * <p>For example, if a class "foo.bar.MyClass" is stored in a file
  +   * "c:/myproject/src/foo/bar/MyClass.java", that class could be included in
  +   * the service by calling</p>
  +   *
  +   * <pre>
  +   *  includeSourceFile(new File("c:/myproject/src"),
  +   *                    new File("c:/myproject/src/foo/bar/MyClass.java"));
  +   * </pre>
  +   *
  +   * <p>Note that this equivalent to calling</p>
  +   *
  +   * <pre>
  +   *  includeSourceFiles(new File("c:/myproject/src"),"foo/bar/MyClass.java");
  +   * </pre>
  +   *
  +   * <p>If you are calling this method and have more than one root directory,
  +   * and do not readily know which is the correct root for a given source
  +   * File, you can use the getRootForFile() utility method to determine the
  +   * correct root to use.</p>
  +   *
  +   * <p>Note that calling this method implicitly includes the 'root' in
  +   * the sourcepath (exactly as if addSourcepath(root) had been called).</p>
  +   *
  +   * @param root source root for the java source file
  +   * @param sourceFile the java source file
  +   * @throws IllegalArgumentException if either argument is null or if
  +   * root is not an ancestor of sourceFile in the file system.
  +   */
  +  public void includeSourceFile(File root, File sourceFile);
  +
  +  /**
  +   * <p>Excludes a single source File in the JService in exactly the same
  +   * way theat includeSourceFile() includes a source file.
  +   */
  +  public void excludeSourceFile(File root, File sourceFile);
  +
  +  /**
  +   * <p>Includes a single class File in the JService in exactly the same
  +   * way theat includeSourceFile() includes a source file.
  +   */
  +  public void includeClassFile(File root, File sourceFile);
  +
  +  /**
  +   * <p>Excludes a single class File in the JService in exactly the same
  +   * way theat includeSourceFile() includes a source file.
  +   */
  +  public void excludeClassFile(File root, File sourceFile);
  +
  +  /**
      * Names a specific class to be included in the JService.  Note that
      * this will return an 'unresolved' JClass unless a source or class file
      * for the named class is available in the classpath or sourcepath.
  @@ -87,6 +142,7 @@
      */
     public void includeClass(String qualifiedClassname);
   
  +
     /**
      * Names a specific class to be excluded in the JService.  Note that
      * this will have no affect if the named class cannot be found in the
  @@ -176,4 +232,17 @@
      */
     public void setProperty(String name, String value);
   
  +  /**
  +   * <p>Utility method which, given an array of Files representing a series of
  +   * java source roots, returns the first one in array order which is an
  +   * ancestor of the given sourceFile in the file hierarchy.  Returns null if
  +   * the sourceFile is not under any of the given sourceRoots</p>
  +   *
  +   * @param sourceRoots roots to check
  +   * @param sourceFile source file
  +   * @return the sourceRoot that contains the sourceFile, or null if none
  +   * does.
  +   * @throws IllegalArgumentException if either argument is null.
  +   */
  +  public File getRootForFile(File[] sourceRoots, File sourceFile);
   }
  
  
  
  1.4       +40 -0     xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/JServiceParamsImpl.java
  
  Index: JServiceParamsImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/JServiceParamsImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JServiceParamsImpl.java	13 Feb 2004 19:22:31 -0000	1.3
  +++ JServiceParamsImpl.java	14 Feb 2004 02:11:07 -0000	1.4
  @@ -140,6 +140,22 @@
       getClassScanner(srcRoot).exclude(pattern);
     }
   
  +  public void includeSourceFile(File root, File sourceFile) {
  +    includeSourceFiles(root,source2pattern(root,sourceFile));
  +  }
  +
  +  public void excludeSourceFile(File root, File sourceFile) {
  +    excludeSourceFiles(root,source2pattern(root,sourceFile));
  +  }
  +
  +  public void includeClassFile(File root, File classFile) {
  +    includeClassFiles(root,source2pattern(root,classFile));
  +  }
  +
  +  public void excludeClassFile(File root, File classFile) {
  +    excludeClassFiles(root,source2pattern(root,classFile));
  +  }
  +
     public void includeClass(String qualifiedClassname) {
       if (mIncludeClasses == null) mIncludeClasses = new ArrayList();
       mIncludeClasses.add(qualifiedClassname);
  @@ -213,8 +229,32 @@
       return null;
     }
   
  +  public File getRootForFile(File[] sourceRoots, File sourceFile) {
  +    if (sourceRoots == null) throw new IllegalArgumentException("null roots");
  +    if (sourceFile == null) throw new IllegalArgumentException("null file");
  +    String f = sourceFile.getAbsolutePath();
  +    for(int i=0; i<sourceRoots.length; i++) {
  +      if (f.startsWith(sourceRoots[i].getAbsolutePath())) {//cheesy?
  +        return sourceRoots[i];
  +      }
  +    }
  +    return null;
  +  }
  +
  +
     // ========================================================================
     // Private methods
  +
  +  /**
  +   * Converts the sourceFile to a pattern expression relative to the
  +   * given root.
  +   */
  +  private String source2pattern(File root, File sourceFile) {
  +    //REVIEW this is a bit cheesy
  +    String r = root.getAbsolutePath();
  +    String s = sourceFile.getAbsolutePath();
  +    return s.substring(r.length());
  +  }
   
     /**
      * Converts the given java source or class filename into a qualified
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org