adavid.reflect
Class JavaFinder

java.lang.Object
  |
  +--adavid.reflect.JavaFinder

public class JavaFinder
extends java.lang.Object

JavaFinder a java source finder: works on the class path and the property java.source.path which contains path to java source like CLASSPATH The property is given to the program via the command line with the option -Djava.source.path=... Something strange is that if we change dynamically java.class.path, the virtual machine does not take it into account! Zip files may be given in argument, with a special clause [sub directory] which says to search into the given sub directory ; this clause is ignored for normal directories.


Field Summary
static java.lang.String JAVA_PROPERTY_DEF
          the property definition
 
Constructor Summary
JavaFinder()
           
 
Method Summary
static int countDimensions(java.lang.String name)
          returns the number of dimensions of the given name, i.e.
static int endOf(int pos, java.lang.String string)
          finds the end of a token
static java.lang.String getFile(java.lang.String filename, java.lang.String extension)
          returns the string content of the given filename ; null if error
static java.lang.String getjjSource(java.lang.Class aClass)
           
static java.lang.String getjjSource(java.lang.String className)
          returns the jj source of a class; by absolute name ; null if not found, or error
static java.lang.String getSource(java.lang.Class aClass)
          returns the source of a class:java or jj
static java.lang.String getSource(java.lang.String className)
          returns the source of a class; by absolute name ; null if not found, or error
static Interval getSourcePos(java.lang.String name, java.lang.String[] args, java.lang.String source)
          returns the interval where the source of the constructor/method can be found ; arguments are the name(short) and the arguments(long) not supported: type / comment / []...
static int goBack(java.lang.String source, int pos)
          go back, jumps comments
static void initJavaResource()
          initializes the java source resource This may be useful if the user changes the value of java.source.path and wants a dynamic update.
static int jump(int pos, java.lang.String string)
          jump until the next token, ignoring comments, blanks and , if we are on a token, then jump first to the end of this token
static void main(java.lang.String[] args)
          test
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JAVA_PROPERTY_DEF

public static final java.lang.String JAVA_PROPERTY_DEF
the property definition
Constructor Detail

JavaFinder

public JavaFinder()
Method Detail

initJavaResource

public static void initJavaResource()
initializes the java source resource This may be useful if the user changes the value of java.source.path and wants a dynamic update.

getSource

public static java.lang.String getSource(java.lang.Class aClass)
returns the source of a class:java or jj

getjjSource

public static java.lang.String getjjSource(java.lang.Class aClass)

getFile

public static java.lang.String getFile(java.lang.String filename,
                                       java.lang.String extension)
returns the string content of the given filename ; null if error
Parameters:
filename - : absolute class name
extension: - extension of the file

getSource

public static java.lang.String getSource(java.lang.String className)
returns the source of a class; by absolute name ; null if not found, or error

getjjSource

public static java.lang.String getjjSource(java.lang.String className)
returns the jj source of a class; by absolute name ; null if not found, or error

countDimensions

public static int countDimensions(java.lang.String name)
returns the number of dimensions of the given name, i.e. occurences of '['

goBack

public static int goBack(java.lang.String source,
                         int pos)
go back, jumps comments

getSourcePos

public static Interval getSourcePos(java.lang.String name,
                                    java.lang.String[] args,
                                    java.lang.String source)
returns the interval where the source of the constructor/method can be found ; arguments are the name(short) and the arguments(long) not supported: type / comment / []... name / comment / []...

jump

public static int jump(int pos,
                       java.lang.String string)
jump until the next token, ignoring comments, blanks and , if we are on a token, then jump first to the end of this token

endOf

public static int endOf(int pos,
                        java.lang.String string)
finds the end of a token

main

public static void main(java.lang.String[] args)
test