org.jtool.jxplatform.query
Class QueryFile

java.lang.Object
  extended byorg.jtool.jxplatform.query.QueryFile

public class QueryFile
extends java.lang.Object

A utility class which provides quaries about files. Do not pass null to any parameter in methods in this class.

Author:
katsuhisa Maruayma

Constructor Summary
QueryFile()
           
 
Method Summary
 boolean containsClassesWithName(JxFile jfile, java.lang.String cname)
          Tests if a given file contains a class with a given name.
static boolean definesClass(JxFile jfile, JxClass jclass)
          Tests if a given file defines a given class.
static boolean definesClass(JxFile jfile, java.lang.String cname)
          Tests if a given file defines a class with a given name.
static JxFileList getAllFilesInTheSamePackage(JxFile jfile)
          Obtains all files in a package where a given file exists.
static JxClass getClassWithName(JxFile jfile, java.lang.String cname)
          Obtains a class with a given name which a given file can access.
static java.util.ArrayList getJxAccessesUsingField(JxFile jfile, JxField jfield)
          Obtains all field access wrappers in a given file that access a given field.
static java.util.ArrayList getJxCallsUsingMethod(JxFile jfile, JxMethod jmethod)
          Obtains all method call wrappers in a given file tha call a given method.
static java.util.ArrayList getTypesOfClass(JxFile jfile, JxClass jclass)
          Obtains all types in a given file which indicate a given class.
static boolean imports(JxFile jfile, JxClass jclass)
          Tests if a given file imports a given class.
static boolean usesJxClassExceptSelf(JxFile jfile, JxClass jclass)
          Tests if a given file uses a given class exception the class itself.
static boolean usesType(JxFile jfile, java.lang.String fqn)
          Tests if a given file uses a type with a given fully-qualified name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryFile

public QueryFile()
Method Detail

definesClass

public static boolean definesClass(JxFile jfile,
                                   JxClass jclass)
Tests if a given file defines a given class.

Parameters:
jfile - A file wrapper.
jclass - A class wrapper.
Returns:
true if the file defines the class, otherwise false.

definesClass

public static boolean definesClass(JxFile jfile,
                                   java.lang.String cname)
Tests if a given file defines a class with a given name.

Parameters:
jfile - A file wrapper.
cname - A class name.
Returns:
true if the file defines the class, otherwise false.

usesType

public static boolean usesType(JxFile jfile,
                               java.lang.String fqn)
                        throws JxUnknownResultException
Tests if a given file uses a type with a given fully-qualified name.

Parameters:
jfile - A file wrapper.
fqn - The fully qualified name of a type.
Returns:
true if the file uses the type, otherwise false.
Throws:
JxUnknownResultException - if the result is unknown.

getTypesOfClass

public static java.util.ArrayList getTypesOfClass(JxFile jfile,
                                                  JxClass jclass)
                                           throws JxUnknownResultException
Obtains all types in a given file which indicate a given class.

Parameters:
jfile - a file wrapper.
jclass - a class wrapper.
Returns:
The collection of JxType objects.
Throws:
JxUnknownResultException - if the result is unknown.

usesJxClassExceptSelf

public static boolean usesJxClassExceptSelf(JxFile jfile,
                                            JxClass jclass)
                                     throws JxUnknownResultException
Tests if a given file uses a given class exception the class itself.

Parameters:
jfile - a file wrapper.
jclass - a class warpper.
Returns:
true if the file uses the class, otherwise false.
Throws:
JxUnknownResultException - if the result is unknown.

getJxCallsUsingMethod

public static java.util.ArrayList getJxCallsUsingMethod(JxFile jfile,
                                                        JxMethod jmethod)
                                                 throws JxUnknownResultException
Obtains all method call wrappers in a given file tha call a given method.

Parameters:
jfile - a file wrapper.
jmethod - a method wrapper.
Returns:
The collection of JxMethodCall objects.
Throws:
JxUnknownResultException - if the result is unknown.

getJxAccessesUsingField

public static java.util.ArrayList getJxAccessesUsingField(JxFile jfile,
                                                          JxField jfield)
                                                   throws JxUnknownResultException
Obtains all field access wrappers in a given file that access a given field.

Parameters:
jfile - a file wrapper.
jfield - a field wrapper.
Returns:
The collection of JxFieldAccess objects.
Throws:
JxUnknownResultException - if the result is unknown.

containsClassesWithName

public boolean containsClassesWithName(JxFile jfile,
                                       java.lang.String cname)
                                throws JxUnknownResultException
Tests if a given file contains a class with a given name.

Parameters:
jfile - a file wrapper.
cname - a class name.
Returns:
true if the file contains the class.
Throws:
JxUnknownResultException - if the result is unknown.

getClassWithName

public static JxClass getClassWithName(JxFile jfile,
                                       java.lang.String cname)
                                throws JxUnknownResultException
Obtains a class with a given name which a given file can access.

Parameters:
jfile - a file wrapper.
cname - a class name.
Returns:
The class wrapper, null if no class was found.
Throws:
JxUnknownResultException - if the result is unknown.

getAllFilesInTheSamePackage

public static JxFileList getAllFilesInTheSamePackage(JxFile jfile)
                                              throws JxUnknownResultException
Obtains all files in a package where a given file exists.

Parameters:
jfile - a file wrapper.
Returns:
The collection of files in the package.
Throws:
JxUnknownResultException - if the result is unknown.

imports

public static boolean imports(JxFile jfile,
                              JxClass jclass)
                       throws JxUnknownResultException
Tests if a given file imports a given class.

Parameters:
jfile - a file wrapper.
jclass - a class wrapper.
Returns:
true if the file imports the class.
Throws:
JxUnknownResultException - if the result is unknown.