com.togethersoft.openapi.sci
Class SciUtil


public class SciUtil

This class contains a set of useful static methods for finding members in classes, checking the
relationship between classes (interfaces), and getting a function call expression from a reference to a
function.

Author:
TogetherSoft
Since: Together 3.0

Method Summary
 private static voidaddAllMembers(Vector membersVector, SciClass sciClass, boolean filterOverriden, Vector scannedClasses)
           
 static EnumerationallMembers(SciClass sciClass, boolean filterOverriden)
          Returns an enumeration of all the members this class has, including inherited members.
 static SciAttributefindAttributeByName(SciClass sciClass, String name)
          Finds an attribute by its name and containing class.
 static SciClassfindClassByName(SciContainer container, String name)
           
 static SciClassfindClassByName(SciContainer container, SciClass aClass)
           
 static SciMemberfindMemberBySignature(SciClass sciClass, String signature)
          Finds SciMember by its containing class and the signature.
 static SciMemberfindMemberBySignature(SciClass sciClass, SciMember patternMember)
          Finds SciMember by its containing class and another member having the same
signature.
 static SciMemberfindMemberBySignature(SciClass sciClass, String signature, boolean searchInBaseClasses)
          Finds SciMember by the signature in the specified class(interface), or in its parents.
 private static SciMemberfindMemberBySignature(SciClass sciClass, String signature, Vector scannedClasses)
           
 static SciMemberfindMemberBySignature(SciClass sciClass, SciMember patternMember, boolean searchInBaseClasses)
          Finds SciMember by another member having the same
signature, in the specified class(interface), or in its parents.
 private static SciMemberfindMemberBySignature(SciClass sciClass, SciMember patternMember, Vector scannedClasses)
           
 static SciFunctionCallExpressiongetFunctionCallFromReference(SciReferenceExpression referenceExpression)
          Returns a SciFunctionCallExpression for the specified reference to a function.
 static booleanisInheritor(SciClass aClass, SciClass base, boolean checkDeepInheritance)
          Checks whether the specified class(interface) is a descendant of another class or interface.
 private static booleanisInheritor(SciClass aClass, SciClass base, Vector baseClasses)
           

Method Detail

addAllMembers

private static void addAllMembers(Vector membersVector, SciClass sciClass, boolean filterOverriden, Vector scannedClasses)

allMembers

public static Enumeration allMembers(SciClass sciClass, boolean filterOverriden)
Returns an enumeration of all the members this class has, including inherited members.
Parameters:
sciClass the SciClass in which members are being searched for
filterOverriden The boolena flag. If true then this method will
not return overriden members in superclasses.
Returns: Enumeration

findAttributeByName

public static SciAttribute findAttributeByName(SciClass sciClass, String name)
Finds an attribute by its name and containing class.
Parameters:
sciClass the SciClass in which an attribute is being searched for
name the string containing a name of an attribute
Returns: SciAttribute contained in the specified class and having the specified name,
null otherwise

findClassByName

public static SciClass findClassByName(SciContainer container, String name)

findClassByName

public static SciClass findClassByName(SciContainer container, SciClass aClass)

findMemberBySignature

public static SciMember findMemberBySignature(SciClass sciClass, String signature)
Finds SciMember by its containing class and the signature.
Parameters:
sciClass SciClass in which a member is being searched
signature the string containing the signature of a member
Returns: SciMember having the specified signature and contained in the specified class;
null otherwise.
See Also:
findMemberBySignature(com.togethersoft.openapi.sci.SciClass,java.lang.String), SciMember.getSignature()

findMemberBySignature

public static SciMember findMemberBySignature(SciClass sciClass, SciMember patternMember)
Finds SciMember by its containing class and another member having the same
signature. This method works faster than
findMemberBySignature(SciClass,String),
because it calculates and compares signatures only if the names match for the members
being compared.
Parameters:
sciClass SciClass in which a member is being searched
patternMember SciMember having the same signature as the target member
Returns: SciMember containing in the specified class and having the same signature
as the specified member, null otherwise.
See Also:
SciMember.getSignature()

findMemberBySignature

public static SciMember findMemberBySignature(SciClass sciClass, String signature, boolean searchInBaseClasses)
Finds SciMember by the signature in the specified class(interface), or in its parents.
Parameters:
sciClass the starting SciClass in which a member is being searched
signature the string containing the signature of a member
searchInBaseClasses The boolean flag. If true then a member will be searched for
in the classes and interfaces which sciClass extends and/or implements (classes are searched first).
If false then it will be searched for in the sciClass only.
Returns: SciMember having the specified signature and contained in the specified class(interface),
or in its parents,
null otherwise.
See Also:
findMemberBySignature(com.togethersoft.openapi.sci.SciClass,java.lang.String), SciMember.getSignature()

findMemberBySignature

private static SciMember findMemberBySignature(SciClass sciClass, String signature, Vector scannedClasses)

findMemberBySignature

public static SciMember findMemberBySignature(SciClass sciClass, SciMember patternMember, boolean searchInBaseClasses)
Finds SciMember by another member having the same
signature, in the specified class(interface), or in its parents. This method works faster
than findMemberBySignature(SciClass, String, boolean),

because it calculates and compares signatures only if the names match for the members
being compared.
Parameters:
sciClass the starting SciClass in which a member is being searched
patternMember SciMember having the same signature as the target member
searchInBaseClasses The boolean flag. If true then a member will be searched for
in the classes and interfaces which sciClass extends and/or implements (classes are searched first).
If false then it will be searched in the sciClass only.
Returns: SciMember having the same signature
as the specified member, and contained in the specified class(interface),
or in its parents;
null otherwise.
See Also:
findMemberBySignature(com.togethersoft.openapi.sci.SciClass,java.lang.String), SciMember.getSignature()

findMemberBySignature

private static SciMember findMemberBySignature(SciClass sciClass, SciMember patternMember, Vector scannedClasses)

getFunctionCallFromReference

public static SciFunctionCallExpression getFunctionCallFromReference(SciReferenceExpression referenceExpression)
Returns a SciFunctionCallExpression for the specified reference to a function. For references
not to the functions this method returns null. This is a very convenient method, because
once you've got a reference (for example, in a
SciReferenceVisitor),
you can
check if it appears in the function call expression, and get this expression if it does.


Let us suppose we have a line in the source code:



someObject.someMethod();

For SciReference representing a reference to someMethod this method will return
SciFuncionCallExpression for the original source code line.

For SciReference representing a reference to someObject this method will return
null.


Note that since in Java (unlike C++) any usage of a method's name may
appear only in the function call expressions,
this method won't return null for references to methods.

Parameters:
referenceExpression the SciReferenceExpression
Returns: SciFunctionCallExpression, or null
See Also:
SciFunctionCallExpression, SciReferenceExpression

isInheritor

public static boolean isInheritor(SciClass aClass, SciClass base, boolean checkDeepInheritance)
Checks whether the specified class(interface) is a descendant of another class or interface.
Parameters:
aClass the child SciClass
base the target SciClass
checkDeepInheritance The boolean flag. If true then this method
will analyze not only direct inheritances, but will scan the whole hierarchy of
parents of aClass.
Returns: true if aClass is a descendant of base, false
otherwise

isInheritor

private static boolean isInheritor(SciClass aClass, SciClass base, Vector baseClasses)