org.jtool.jxplatform.query
Class QueryField

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

public class QueryField
extends java.lang.Object

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

Author:
katsuhisa Maruayma

Constructor Summary
QueryField()
           
 
Method Summary
static boolean callsMethod(JxField jfield)
          Tests if a given field calls any method.
static boolean callsMethodInAncestorsOfClass(JxField jfield, JxClass jclass)
          Tests if a given field calls any method in ancestors of a given class.
static boolean callsMethodInClass(JxField jfield, JxClass jclass)
          Tests if a given field calls any method in a given class.
static boolean callsPrivateMethodsInClass(JxField jfield, JxClass jclass)
          Tests if a given field calls any private method in a given class.
static JxMethodList getCalledMethodsInClass(JxField jfield, JxClass jclass)
          Obtains all methods which are called by a given field and which are in a given class.
static JxFieldList getFieldsWithTheSameName(JxField jfield, JxClassList jclasses)
          Obtains all fields in a given collection with the same name as a given field.
static JxFieldList getHiddenFields(JxField jfield)
          Obtains all fields hidden by a given field.
static JxFieldList getHiddenFields(JxField jfield, JxClassList ancestors)
          Obtains all fields hidden by a given field.
static JxFieldList getHidingFields(JxField jfield)
          Obtains all fields hiding a given field.
static JxFieldList getHidingFields(JxField jfield, JxClassList descendants)
          Obtains all fields hiding a given field.
static java.lang.String getSuffixName(java.lang.String name)
          Returns the suffix name of a getter and setter of a field.
static JxFieldList getUsedFieldsInAncestorsOfClass(JxField jfield, JxClass jclass)
          Obtains all fields which are used by a given field and which are in ancestors of a given class.
static JxFieldList getUsedFieldsInClass(JxField jfield, JxClass jclass)
          Obtains all fields which are used by a given field and which are in a given class.
static JxMethod guessGettter(JxField jfield)
          Guesses and returns the getter of a given field.
static JxMethod guessSettter(JxField jfield)
          Guesses and returns the setter of a given field.
static boolean hides(JxField jf1, JxField jf2)
          Tests if a given field hides a given field.
static boolean inSimpleAssignments(JxField jfield, JxClass jclass)
          Tests if all accesses to a given field in a given class are contained in simple assignments.
static boolean usesField(JxField jfield)
          Tests if a given field uses another field.
static boolean usesFieldInAncestorsOfClass(JxField jfield, JxClass jclass)
          Tests if a given field uses any field in ancestors of a given class.
static boolean usesFieldInClass(JxField jfield, JxClass jclass)
          Tests if a given field uses another field in a given class.
static boolean usesPrivateFieldInClass(JxField jfield, JxClass jclass)
          Tests if a given field uses any private field in a given class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryField

public QueryField()
Method Detail

usesField

public static boolean usesField(JxField jfield)
                         throws JxUnknownResultException
Tests if a given field uses another field.

Parameters:
jfield - A field wrapper.
Returns:
true if the field uses another field, otherwise false.
Throws:
JxUnknownResultException - if the result is unknown.

callsMethod

public static boolean callsMethod(JxField jfield)
                           throws JxUnknownResultException
Tests if a given field calls any method.

Parameters:
jfield - A field wrapper.
Returns:
true if the field calls any method, otherwise false.
Throws:
JxUnknownResultException - if the result is unknown.

usesFieldInClass

public static boolean usesFieldInClass(JxField jfield,
                                       JxClass jclass)
                                throws JxUnknownResultException
Tests if a given field uses another field in a given class.

Parameters:
jfield - A field wrapper.
jclass - A class wrapper.
Returns:
true if the field uses another field, otherwise false.
Throws:
JxUnknownResultException - if the result is unknown.

usesFieldInAncestorsOfClass

public static boolean usesFieldInAncestorsOfClass(JxField jfield,
                                                  JxClass jclass)
                                           throws JxUnknownResultException
Tests if a given field uses any field in ancestors of a given class.

Parameters:
jfield - A field wrapper.
jclass - A class wrapper.
Returns:
true if the field uses another field, otherwise false.
Throws:
JxUnknownResultException - if the result is unknown.

getUsedFieldsInClass

public static JxFieldList getUsedFieldsInClass(JxField jfield,
                                               JxClass jclass)
                                        throws JxUnknownResultException
Obtains all fields which are used by a given field and which are in a given class.

Parameters:
jfield - A field wrapper.
jclass - A class wrapper.
Returns:
The collection of the used fields in the class.
Throws:
JxUnknownResultException - if the result is unknown.

callsMethodInClass

public static boolean callsMethodInClass(JxField jfield,
                                         JxClass jclass)
                                  throws JxUnknownResultException
Tests if a given field calls any method in a given class.

Parameters:
jfield - A fiels wrapper.
jclass - A class wrapper.
Returns:
true if the field calls any method, otherwise false.
Throws:
JxUnknownResultException - if the result is unknown.

callsMethodInAncestorsOfClass

public static boolean callsMethodInAncestorsOfClass(JxField jfield,
                                                    JxClass jclass)
                                             throws JxUnknownResultException
Tests if a given field calls any method in ancestors of a given class.

Parameters:
jfield - A field wrapper.
jclass - A class wrapper.
Returns:
true if the field calls any method, otherwise false.
Throws:
JxUnknownResultException - if the result is unknown.

getCalledMethodsInClass

public static JxMethodList getCalledMethodsInClass(JxField jfield,
                                                   JxClass jclass)
                                            throws JxUnknownResultException
Obtains all methods which are called by a given field and which are in a given class.

Parameters:
jfield - A field wrapper.
jclass - A class wrapper.
Returns:
The collection of the called methods in the class.
Throws:
JxUnknownResultException - if the result is unknown.

usesPrivateFieldInClass

public static boolean usesPrivateFieldInClass(JxField jfield,
                                              JxClass jclass)
                                       throws JxUnknownResultException
Tests if a given field uses any private field in a given class.

Parameters:
jfield - A field wrapper.
jclass - A class wrapper.
Returns:
true if the field uses any private field, otherwise false.
Throws:
JxUnknownResultException - if the result is unknown.

callsPrivateMethodsInClass

public static boolean callsPrivateMethodsInClass(JxField jfield,
                                                 JxClass jclass)
                                          throws JxUnknownResultException
Tests if a given field calls any private method in a given class.

Parameters:
jfield - A field wrapper.
jclass - A class wrapper.
Returns:
true if the field calls any private method, otherwise false.
Throws:
JxUnknownResultException - if the result is unknown.

getUsedFieldsInAncestorsOfClass

public static JxFieldList getUsedFieldsInAncestorsOfClass(JxField jfield,
                                                          JxClass jclass)
                                                   throws JxUnknownResultException
Obtains all fields which are used by a given field and which are in ancestors of a given class.

Parameters:
jfield - A field wrapper.
jclass - A class wrapper.
Returns:
The collection of the used fields in the ancestors.
Throws:
JxUnknownResultException - if the result is unknown.

getFieldsWithTheSameName

public static JxFieldList getFieldsWithTheSameName(JxField jfield,
                                                   JxClassList jclasses)
Obtains all fields in a given collection with the same name as a given field.

Parameters:
jfield - A field wrapper.
jclasses - The collection of class wrappers.
Returns:
The collection of the fields with the same name.

getHiddenFields

public static JxFieldList getHiddenFields(JxField jfield)
                                   throws JxUnknownResultException
Obtains all fields hidden by a given field. (JLS 8.3.3)

Parameters:
jfield - A field wrapper.
Returns:
The collection of the hidden fields.
Throws:
JxUnknownResultException - if the result is unknown.

getHiddenFields

public static JxFieldList getHiddenFields(JxField jfield,
                                          JxClassList ancestors)
                                   throws JxUnknownResultException
Obtains all fields hidden by a given field.

Parameters:
jfield - A field wrapper.
ancestors - A collection of ancestors to be examined.
Returns:
The collection of the hidden fields.
Throws:
JxUnknownResultException - if the result is unknown.

getHidingFields

public static JxFieldList getHidingFields(JxField jfield)
                                   throws JxUnknownResultException
Obtains all fields hiding a given field. (JLS 8.3.3)

Parameters:
jfield - A field wrapper.
Returns:
The collection of hiding fields.
Throws:
JxUnknownResultException - if the result is unknown.

getHidingFields

public static JxFieldList getHidingFields(JxField jfield,
                                          JxClassList descendants)
                                   throws JxUnknownResultException
Obtains all fields hiding a given field.

Parameters:
jfield - A field wrapper.
descendants - A collection of descendants to be examined.
Returns:
The collection of hiding fields.
Throws:
JxUnknownResultException - if the result is unknown.

hides

public static boolean hides(JxField jf1,
                            JxField jf2)
Tests if a given field hides a given field.

Parameters:
jf1 - A wrapper of a hiding field.
jf2 - A wrapper of a hidden field.
Returns:
true if the first field hides by the second field, otherwise false.

inSimpleAssignments

public static boolean inSimpleAssignments(JxField jfield,
                                          JxClass jclass)
                                   throws JxUnknownResultException
Tests if all accesses to a given field in a given class are contained in simple assignments.

Parameters:
jfield - A field wrapper.
jclass - A class wrapper.
Returns:
true if all the field accesses are contained in simple assigJxWrapperExceptionnments.
Throws:
JxUnknownResultException - if the result is unknown.

guessGettter

public static JxMethod guessGettter(JxField jfield)
                             throws JxUnknownResultException
Guesses and returns the getter of a given field.

Parameters:
jfield - A field wrapper.
Returns:
The getter, null if no getter was detected.
Throws:
JxUnknownResultException - if the result is unknown.

guessSettter

public static JxMethod guessSettter(JxField jfield)
                             throws JxUnknownResultException
Guesses and returns the setter of a given field.

Parameters:
jfield - A field wrapper.
Returns:
The setter, null if no setter was found.
Throws:
JxUnknownResultException - if the result is unknown.

getSuffixName

public static java.lang.String getSuffixName(java.lang.String name)
Returns the suffix name of a getter and setter of a field.

Parameters:
name - A field name.
Returns:
The suffix name of the getter and setter.