|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--openjava.mop.OJClass
The OJClass
class represents a class metaobject. If
the class has its valid .class file in CLASSPATH, the metaobject can
behave like java.lang.Class
. If the class has its
valid .oj file in the packages where some classes are being compiled
by OpenJava system, or in the packages explicitly specified by
something like OpenJava compiler option or environment variable, the
metaobject can have information about source code just as
stamements, expressions, and etc.
Additionaly, you can overrides the methods for introspection.
OJClass[] getDeclaredClasses() OJMethod[] getDeclaredMethods() OJField[] getDeclaredFields() OJConstructor[] getDeclaredConstructors() OJMethod getAcceptableMethod(OJClass,String,OJClass[]) OJMethod getAcceptableConstructor(OJClass,String,OJClass[])
Class
,
OJMethod
,
OJField
,
OJConstructor
Field Summary | |
private OJClassImp |
substance
|
Fields inherited from interface openjava.mop.OJMember |
DECLARED, PUBLIC |
Constructor Summary | |
(package private) |
OJClass()
For dummy type of null object. |
|
OJClass(Class java_class,
MetaInfo metainfo)
Generates a metaobject from byte code. |
|
OJClass(Environment outer_env,
OJClass declarer,
ClassDeclaration ptree)
Generates a metaobject from source code. |
private |
OJClass(OJClass componentType)
For arrays |
Method Summary | |
OJClass |
addClass(OJClass clazz)
|
protected OJConstructor |
addConstructor(OJConstructor constr)
|
OJField |
addField(OJField field)
|
protected void |
addInterface(OJClass clazz)
|
protected OJMethod |
addMethod(OJMethod method)
|
(package private) static OJClass[] |
arrayForClasses(Class[] jclasses)
|
static OJClass |
arrayOf(OJClass componentType)
|
Expression |
expandAllocation(Environment env,
AllocationExpression expr)
|
Expression |
expandArrayAccess(Environment env,
ArrayAccess expr)
|
Expression |
expandArrayAllocation(Environment env,
ArrayAllocationExpression expr)
|
Expression |
expandAssignmentExpression(Environment env,
AssignmentExpression expr)
|
Expression |
expandCastedExpression(Environment env,
CastExpression decl)
|
Expression |
expandCastExpression(Environment env,
CastExpression decl)
|
Expression |
expandExpression(Environment env,
Expression expr)
|
Expression |
expandFieldRead(Environment env,
FieldAccess expr)
|
Expression |
expandFieldWrite(Environment env,
AssignmentExpression expr)
|
Expression |
expandMethodCall(Environment env,
MethodCall expr)
|
TypeName |
expandTypeName(Environment env,
TypeName expr)
|
Statement |
expandVariableDeclaration(Environment env,
VariableDeclaration decl)
|
static OJClass |
forClass(Class javaClass)
Converts a OJClass object to an OJClass
object. |
static OJClass |
forName(String name)
Returns the OJClass object associated with the class
with the given string name. |
static OJClass |
forObject(Object obj)
|
static OJClass |
forParseTree(Environment env,
OJClass declaringClass,
ClassDeclaration ptree)
Converts ParseTree objects to an OJClass
object. |
OJConstructor |
getAcceptableConstructor(OJClass[] parameterTypes,
OJClass situation)
Can be overriden |
OJMethod |
getAcceptableMethod(String name,
OJClass[] parameterTypes,
OJClass situation)
Can be overriden |
OJClass[] |
getAllClasses()
|
OJField |
getAllField(String name)
Deprecated. |
OJField[] |
getAllFields()
|
OJMethod |
getAllMethod(String name,
OJClass[] parameterTypes)
Deprecated. |
OJMethod[] |
getAllMethods()
|
OJMethod[] |
getAllMethods(String name)
Deprecated. |
Class |
getByteCode()
|
OJClass[] |
getClasses()
Returns an array containing OJClass objects
representing all the public classes and interfaces
that are members of the class represented by this
OJClass object. |
OJClass[] |
getClasses(OJClass situation)
Returns an array containing OJClass objects
representing all the classes and interfaces which are members
of the class represented by this OJClass object,
accessible from the situation represented by the given
OJClass object. |
ClassLoader |
getClassLoader()
|
Class |
getCompatibleJavaClass()
|
OJClass |
getComponentType()
Returns the OJClass representing the component type of an
array. |
OJConstructor |
getConstructor(OJClass[] parameterTypes)
Returns a OJConstructor object that reflects the
specified public constructor of the class represented by this
OJClass object. |
OJConstructor |
getConstructor(OJClass[] parameterTypes,
OJClass situation)
Returns a OJConstructor object that reflects the
specified constructor accesible from the situation represented
by the given OJClass object. |
OJConstructor[] |
getConstructors()
Returns an array containing OJConstructor objects
reflecting all the public constructors of the class
represented by this OJClass object. |
OJConstructor[] |
getConstructors(OJClass situation)
Returns an array containing OJConstructor objects
reflecting all the constructors of the class represented by
this OJClass object, accesible from the situation
represented by the given OJClass object. |
OJClass[] |
getDeclaredClasses()
Returns an array of OJClass objects reflecting all
the classes and interfaces declared as members of the class
represented by this OJClass object. |
OJConstructor |
getDeclaredConstructor(OJClass[] parameterTypes)
Returns a OJConstructor object that reflects the
specified constructor of the class or interface represented by
this OJClass object. |
OJConstructor[] |
getDeclaredConstructors()
Returns an array of OJConstructor objects reflecting
all the constructors declared by the class represented by this
OJClass object. |
OJField |
getDeclaredField(String name)
Returns a OJField object that reflects the specified
declared field of the class or interface represented by this
OJClass object. |
OJField[] |
getDeclaredFields()
Returns an array of OJField objects reflecting all
the fields declared by the class or interface represented by
this OJClass object. |
OJMethod |
getDeclaredMethod(String name,
OJClass[] parameterTypes)
Returns a OJMethod object that reflects the
specified declared method of the class or interface represented
by this OJClass object. |
OJMethod[] |
getDeclaredMethods()
Returns an array of OJMethod objects reflecting all
the methods declared by the class or interface represented by
this OJClass object. |
OJClass |
getDeclaringClass()
If the class or interface represented by this OJClass object is a member of another class,
returns the OJClass object representing the class
in which it was declared. |
static SyntaxRule |
getDeclSuffixRule(String keyword)
|
Environment |
getEnvironment()
Obtains an environment of this class object. |
OJField |
getField(String name)
Returns a OJField object that reflects the
specified public member field of the class or
interface represented by this OJClass object. |
OJField |
getField(String name,
OJClass situation)
Returns a OJField object that reflects the
specified member field accesible from the situation represented
by the given OJClass object. |
OJField[] |
getFields()
Returns an array containing OJField objects
reflecting all the accessible public fields of the
class or interface represented by this OJClass
object. |
OJField[] |
getFields(OJClass situation)
Returns an array containing OJField objects
reflecting all the fields of the class or interface represented
by this OJClass object, accessible from the
situation represented by the given OJClass object. |
OJClass[] |
getInheritableClasses()
Deprecated. |
OJClass[] |
getInheritableClasses(OJClass situation)
|
OJConstructor[] |
getInheritableConstructors(OJClass situation)
|
OJField[] |
getInheritableFields()
Deprecated. |
OJField[] |
getInheritableFields(OJClass situation)
|
OJMethod[] |
getInheritableMethods()
Deprecated. |
OJMethod[] |
getInheritableMethods(OJClass situation)
|
OJClass[] |
getInheritedClasses()
|
OJField[] |
getInheritedFields()
|
OJMethod[] |
getInheritedMethods()
|
OJClass[] |
getInterfaces()
Determines the interfaces implemented by the class or interface represented by this object. |
String |
getMetaInfo(String key)
|
Enumeration |
getMetaInfoElements()
|
Enumeration |
getMetaInfoKeys()
|
OJMethod |
getMethod(String name,
OJClass[] parameterTypes)
Returns a OJMethod object that reflects the
specified public member method of the class or interface
represented by this OJClass object. |
OJMethod |
getMethod(String name,
OJClass[] parameterTypes,
OJClass situation)
Returns a OJMethod object that reflects the
specified member method accesible from the situation
represented by the given OJClass object. |
OJMethod[] |
getMethods()
Returns an array containing OJMethod objects
reflecting all the public member methods of the class
or interface represented by this OJClass object,
including those declared by the class or interface and and
those inherited from superclasses and superinterfaces. |
OJMethod[] |
getMethods(OJClass situation)
Returns an array containing OJMethod objects
reflecting all the member methods of the class or interface
represented by this OJClass object, accesible from
the situation represented by the given OJClass
object. |
OJModifier |
getModifiers()
Returns the Java language modifiers and the user defined modifiers for this class or interface, as a OJModifier object. |
String |
getName()
Returns the fully-qualified name of the entity (class, interface, array class, primitive type, or void) represented by this OJClass object, as a String . |
String |
getPackage()
Gets the package name for this class as a String . |
URL |
getResource(String name)
|
InputStream |
getResourceAsStream(String name)
|
Object[] |
getSigners()
|
String |
getSimpleName()
Returns the simple name of the class, interface or array class represented by this OJClass object, as a
String . |
ClassDeclaration |
getSourceCode()
|
ParseTree |
getSuffix(String keyword)
Obtains an parse tree of suffix in extended syntax starting with the specified keyword. |
OJClass |
getSuperclass()
Returns the OJClass representing the superclass of
the entity (class, interface, primitive type or void)
represented by this OJClass . |
static SyntaxRule |
getTypeSuffixRule(String keyword)
|
boolean |
isAlterable()
|
boolean |
isArray()
Determines if this OJClass object represents an
array class. |
private static boolean |
isArrayName(String name)
|
boolean |
isAssignableFrom(OJClass clazz)
Determines if the class or interface represented by this OJClass object is either the same as, or is a
superclass or superinterface of, the class or interface
represented by the specified OJClass parameter. |
boolean |
isExecutable()
|
boolean |
isInSamePackage(OJClass c)
Determines if the specified class object is in the same package as this class object. |
boolean |
isInstance(Object obj)
|
boolean |
isInterface()
Determines if the specified OJClass object represents
an interface type. |
boolean |
isPrimitive()
Determines if the specified OJClass object represents a
primitive type. |
boolean |
isPrimitiveWrapper()
Determines if the specified OJClass object represents a
wrapper class for a primitive type. |
static boolean |
isRegisteredKeyword(String keyword)
|
static boolean |
isRegisteredModifier(String keyword)
|
private static OJClass |
lookupFromByteCode(String name)
|
private static OJClass |
lookupFromMetaInfo(Class javaClass)
|
OJClass |
makeCopy(String qname)
Generate a copy of this class object with the specified name. |
protected static Expression |
makeExpression(Environment env,
String str)
Generates a expression parse tree from a given String object under the given environment. |
protected Expression |
makeExpression(String str)
Generates an expression parse tree from a given String object under the environment of
this class object. |
protected static Statement |
makeStatement(Environment env,
String str)
Generates a statement parse tree from a given String object under the given environment. |
protected Statement |
makeStatement(String str)
Generates a statement parse tree from a given String object under the environment of
this class object. |
protected static StatementList |
makeStatementList(Environment env,
String str)
Generates a statement list parse tree from a given String object under the given environment. |
protected StatementList |
makeStatementList(String str)
Generates a statement list parse tree from a given String object under the environment of
this class object. |
private static String |
nameForJavaClassName(String jcname)
|
private static String |
nameToJavaClassName(String ojcname)
|
Object |
newInstance()
|
private static OJClass[] |
overridesOn(OJClass[] declareds,
OJClass[] bases)
|
private static OJField[] |
overridesOn(OJField[] declareds,
OJField[] bases)
|
private static OJMethod[] |
overridesOn(OJMethod[] declareds,
OJMethod[] bases)
|
private static OJConstructor |
pickupAcceptableConstructor(OJConstructor[] src_constrs,
OJClass[] parameterTypes)
|
private static OJMethod |
pickupAcceptableMethod(OJMethod[] src_methods,
String name,
OJClass[] parameterTypes)
|
private static OJConstructor |
pickupConstructor(OJConstructor[] src_constrs,
OJClass[] parameterTypes)
|
private static OJField |
pickupField(OJField[] src_fields,
String name)
|
private static OJMethod |
pickupMethod(OJMethod[] src_methods,
String name,
OJClass[] parameterTypes)
|
private static OJMethod[] |
pickupMethodsByName(OJMethod[] src_methods,
String name)
|
private static int |
primitiveTypeWidth(OJClass ptype)
|
OJClass |
primitiveWrapper()
Obtains the wrapper class if this class represents a primitive type. |
protected String |
putMetaInfo(String key,
String value)
|
protected OJClass |
removeClass(OJClass clazz)
|
protected OJConstructor |
removeConstructor(OJConstructor constr)
|
OJField |
removeField(OJField field)
|
protected OJMethod |
removeMethod(OJMethod method)
|
private static OJClass[] |
removeTheDefaults(OJClass[] src_classes)
|
private static OJConstructor[] |
removeTheDefaults(OJConstructor[] src_constrs)
|
private static OJField[] |
removeTheDefaults(OJField[] src_fields)
|
private static OJMethod[] |
removeTheDefaults(OJMethod[] src_methods)
|
private static OJClass[] |
removeTheNonPublics(OJClass[] src_classes)
|
private static OJConstructor[] |
removeTheNonPublics(OJConstructor[] src_constrs)
|
private static OJField[] |
removeTheNonPublics(OJField[] src_fields)
|
private static OJMethod[] |
removeTheNonPublics(OJMethod[] src_methods)
|
private static OJClass[] |
removeThePrivates(OJClass[] src_classes)
|
private static OJConstructor[] |
removeThePrivates(OJConstructor[] src_constrs)
|
private static OJField[] |
removeThePrivates(OJField[] src_fields)
|
private static OJMethod[] |
removeThePrivates(OJMethod[] src_methods)
|
static String |
replaceDotWithDollar(String base,
int i)
|
OJField |
resolveException(NoSuchMemberException e,
String name)
|
OJMethod |
resolveException(NoSuchMemberException e,
String name,
OJClass[] argtypes)
|
(package private) void |
setDeclaringClass(OJClass parent)
|
protected OJClass[] |
setInterfaces(OJClass[] classes)
|
protected String |
setName(String simple_name)
not implemented yet |
protected OJClass |
setSuperclass(OJClass clazz)
|
Signature |
signature()
|
private static String |
stripBrackets(String ojcname)
|
(package private) static Class[] |
toClasses(OJClass[] classes)
|
String |
toString()
Converts the object to a string. |
void |
translateDefinition()
|
ClassDeclaration |
translateDefinition(Environment env,
ClassDeclaration decl)
|
OJClass |
unwrappedPrimitive()
Obtains the real type class if this class represents a primitive wrapper type. |
void |
waitTranslation(OJClass clazz)
Waits a callee-side translation on another class metaobject to be done. |
void |
writeMetaInfo(Writer out)
inner use only |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private OJClassImp substance
Constructor Detail |
public OJClass(Environment outer_env, OJClass declarer, ClassDeclaration ptree)
This constructor will be invoked by the OpenJava system. In inheriting this class, you must call this consturctor from a constructor with the same signature in your class.
For example, in defining a subclass YourClass
derived from this class, at least you have to write as follows:
public YourClass( Environment outer_env, OJClass declarer, ClassDeclaration ptree ) { super( outer_env, declarer, ptree ); }
outer_env
- environment of this class metaobjectdeclarer
- the class metaobject declaring this
class metaobject.ptree
- the parse tree representing this class metaobject.public OJClass(Class java_class, MetaInfo metainfo)
This constructor will be invoked only by the OpenJava system. In inheriting this class, you must call this consturctor from a constructor with the same signature in your class.
For example, in defining a subclass YourClass
derived from this class, at least you have to write as follows:
public YourClass( Class java_class, MetaInfo metainfo ) { super( java_class, metainfo ); }
private OJClass(OJClass componentType)
OJClass()
Method Detail |
public static OJClass arrayOf(OJClass componentType)
public static OJClass forName(String name) throws OJClassNotFoundException
OJClass
object associated with the class
with the given string name.
Given the fully-qualified name for a class or interface, this
method attempts to locate, load and link the class. If it
succeeds, returns the Class object representing the class. If
it fails, the method throws a OJClassNotFoundException.
For example, the following code fragment returns the runtime
OJClass
descriptor for the class named
java.lang.Thread
:
OJClass t = OJClass.forName( "java.lang.Thread" );
OJClass
descriptor for the class with
the specified name.
OJClassNotFoundException
- if the class could not be found.private static final OJClass lookupFromByteCode(String name)
public static final String replaceDotWithDollar(String base, int i)
private static final boolean isArrayName(String name)
private static final String stripBrackets(String ojcname)
private static final String nameForJavaClassName(String jcname)
private static final String nameToJavaClassName(String ojcname)
static OJClass[] arrayForClasses(Class[] jclasses)
static Class[] toClasses(OJClass[] classes)
public static OJClass forClass(Class javaClass)
OJClass
object to an OJClass
object.
This method returns the same OJClass
object
whenever it is invoked for the same Class
object.
It gurantees one-to-one correspondence between Class
and OJClass
.
private static final OJClass lookupFromMetaInfo(Class javaClass)
public static OJClass forParseTree(Environment env, OJClass declaringClass, ClassDeclaration ptree) throws AmbiguousClassesException, ClassNotFoundException
ParseTree
objects to an OJClass
object. The generated OJClass
object is to be
registered as globally asscessible class but not to appear as
generated source code.
AmbiguousClassesException
ClassNotFoundException
public static OJClass forObject(Object obj)
protected static final Expression makeExpression(Environment env, String str) throws MOPException
String
object under the given environment.
env
- an environment for the source code.str
- a fragment of source code representing an expression.
MOPException
protected final Expression makeExpression(String str) throws MOPException
String
object under the environment of
this class object.
str
- a fragment of source code representing an expression.
MOPException
protected static final Statement makeStatement(Environment env, String str) throws MOPException
String
object under the given environment.
env
- an environment for the source code.str
- a fragment of source code representing a statement.
MOPException
protected final Statement makeStatement(String str) throws MOPException
String
object under the environment of
this class object.
str
- a fragment of source code representing a statement.
MOPException
protected static final StatementList makeStatementList(Environment env, String str) throws MOPException
String
object under the given environment.
env
- an environment for the source code.str
- a fragment of source code representing a statement list.
MOPException
protected final StatementList makeStatementList(String str) throws MOPException
String
object under the environment of
this class object.
str
- a fragment of source code representing a statement list.
MOPException
public String toString()
getName
. If this OJClass
object
represents a primitive type, this method returns the name of the
primitive type. If this OJClass
object represents
void this method returns "void".
toString
in class Object
public Environment getEnvironment()
getEnvironment
in interface OJMember
public Object newInstance() throws InstantiationException, IllegalAccessException, CannotExecuteException
InstantiationException
IllegalAccessException
CannotExecuteException
public boolean isInstance(Object obj)
public boolean isAssignableFrom(OJClass clazz)
OJClass
object is either the same as, or is a
superclass or superinterface of, the class or interface
represented by the specified OJClass
parameter. It
returns true
if so; otherwise it returns
false
. If this OJClass
object
represents a primitive type, this method returns
true
if the type represented by this
OJClass
object can accept the type represented by
the specified OJClass
parameter; otherwise it
returns false
.
Specifically, this method tests whether the type
represented by the specified OJClass
parameter can
be converted to the type represented by this
OJClass
object via an identity conversion or via a
widening reference/primitive conversion.
The behavior
about primitive types is different from the method of the same
name of java.lang.Class
.
NullPointerException
- if the specified class parameter is
null.private static int primitiveTypeWidth(OJClass ptype)
public boolean isInterface()
OJClass
object represents
an interface type.
true
if this object represents an interface;
false
otherwise.public boolean isArray()
OJClass
object represents an
array class.
true
if this object represents an array class;
false
otherwise.public boolean isPrimitive()
OJClass
object represents a
primitive type.
There are nine predefined OJClass
objects to represent
the eight primitive types and void. These are created by the Java
Virtual Machine, and have the same names as the primitive types that
they represent, namely boolean
, byte
,
char
, short
, int
,
long
, float
, and double
.
These objects may be accessed via the following public static
final variables, and are the only OJClass
objects for
which this method returns true
.
true
if this object represents a primitive type;
false
otherwise.OJSystem.BOOLEAN
,
OJSystem.CHAR
,
OJSystem.BYTE
,
OJSystem.SHORT
,
OJSystem.INT
,
OJSystem.LONG
,
OJSystem.FLOAT
,
OJSystem.DOUBLE
,
OJSystem.VOID
public boolean isPrimitiveWrapper()
OJClass
object represents a
wrapper class for a primitive type.
true
if this object represents a wrapper class
for a primitive type; false
otherwise.public OJClass primitiveWrapper()
For example this method returns java.lang.Integer for int.
null
for void.public OJClass unwrappedPrimitive()
For example this method returns int for java.lang.Integer.
public String getName()
OJClass
object, as a String
.
If this OJClass
object represents a class of
arrays, then the internal form of the name consists of the name
of the element type in Java signature format, followed by one
or more "[]" characters representing the depth of array
nesting. This representation differs from that of
java.lang.Class.forName()
. Thus:
returns "OJClass.forClass( (new int[3][4]).getClass() ).getName()
java.lang.Object[]
" and:
returns "OJClass.forClass( (new int[3][4]).getClass() ).getName()
int[][]
".
The class or interface name classname is given in fully qualified form as shown in the example above.
getName
in interface OJMember
public String getSimpleName()
OJClass
object, as a
String
. Thus:
returns "OJClass.forClass( (new Object[3]).getClass() ).getName()
Object
".
public String getPackage()
String
.
Null is returned if its package was not specified in source code of
this class.
public boolean isInSamePackage(OJClass c)
If null is given, this method returns alway false.
c
- the class object to test against this class object.
public ClassLoader getClassLoader() throws CannotInspectException
CannotInspectException
public OJClass getSuperclass()
OJClass
representing the superclass of
the entity (class, interface, primitive type or void)
represented by this OJClass
. If this
OJClass
represents either the
java.lang.Object
class, an interface, a primitive
type, or void, then null is returned. If this object
represents an array class then the OJClass
object
representing the java.lang.Object
class is
returned.
public OJClass[] getInterfaces()
If this object represents a class, the return value is an array
containing objects representing all interfaces implemented by the
class. The order of the interface objects in the array corresponds to
the order of the interface names in the implements
clause
of the declaration of the class represented by this object. For
example, given the declaration:
suppose the value ofclass Shimmer implements FloorWax, DessertTopping { ... }
clazz
is an class object for
the class Shimmer
; the value of the expression:
is theclazz.getInterfaces()[0]
OJClass
object that represents interface
FloorWax
; and the value of:
is theclazz.getInterfaces()[1]
OJClass
object that represents interface
DessertTopping
.
If this object represents an interface, the array contains
objects representing all interfaces extended by the
interface. The order of the interface objects in the array
corresponds to the order of the interface names in the
extends
clause of the declaration of the interface
represented by this object.
If this object represents a class or interface that implements no interfaces, the method returns an array of length 0.
If this object represents a primitive type or void, the method returns an array of length 0.
To be
getDeclaredInterfaces()
.
public OJClass getComponentType()
OJClass
representing the component type of an
array. If this class does not represent an array class this method
returns null.
public OJModifier getModifiers()
OJModifier
object.
If the underlying class is an array class, then its
public
, private
and protected
modifiers are the same as those of its component type. If this
OJClass
represents a primitive type or void, its
public
modifier is always true
, and its
protected
and private
modifers are always
false
. If this object represents an array class, a
primitive type or void, then its final
modifier is always
true
and its interface modifer is always
false
. The values of its other modifiers are not determined
by this specification.
getModifiers
in interface OJMember
OJModifier
public ParseTree getSuffix(String keyword)
openjava.ptree.ParseTree
object has a structure
built by an openjava.syntax.SyntaxRule
object
returned via the method getDeclSuffixRule(String)
.
getDeclSuffixRule(String)
,
SyntaxRule
public Object[] getSigners() throws CannotExecuteException
CannotExecuteException
public OJClass getDeclaringClass()
OJClass
object is a member of another class,
returns the OJClass
object representing the class
in which it was declared. This method returns null if this
class or interface is not a member of any other class. If this
OJClass
object represents an array class, a
primitive type, or void, then this method returns null.
getDeclaringClass
in interface OJMember
public final OJClass[] getAllClasses()
public final OJField[] getAllFields()
public final OJMethod[] getAllMethods()
public OJClass[] getInheritedClasses()
public OJField[] getInheritedFields()
public final OJMethod[] getInheritedMethods()
public final OJClass[] getInheritableClasses()
getInheritableClasses(OJClass)
getInheritableClasses(OJClass)
public final OJField[] getInheritableFields()
getInheritableFields(OJClass)
getInheritableFields(OJClass)
public final OJMethod[] getInheritableMethods()
getInheritableMethods(OJClass)
getInheritableMethods(OJClass)
public OJClass[] getInheritableClasses(OJClass situation)
public OJField[] getInheritableFields(OJClass situation)
public OJMethod[] getInheritableMethods(OJClass situation)
public OJConstructor[] getInheritableConstructors(OJClass situation)
private static final OJClass[] overridesOn(OJClass[] declareds, OJClass[] bases)
private static final OJField[] overridesOn(OJField[] declareds, OJField[] bases)
private static final OJMethod[] overridesOn(OJMethod[] declareds, OJMethod[] bases)
private static final OJClass[] removeThePrivates(OJClass[] src_classes)
private static final OJField[] removeThePrivates(OJField[] src_fields)
private static final OJMethod[] removeThePrivates(OJMethod[] src_methods)
private static final OJConstructor[] removeThePrivates(OJConstructor[] src_constrs)
private static final OJClass[] removeTheDefaults(OJClass[] src_classes)
private static final OJField[] removeTheDefaults(OJField[] src_fields)
private static final OJMethod[] removeTheDefaults(OJMethod[] src_methods)
private static final OJConstructor[] removeTheDefaults(OJConstructor[] src_constrs)
private static final OJClass[] removeTheNonPublics(OJClass[] src_classes)
private static final OJField[] removeTheNonPublics(OJField[] src_fields)
private static final OJMethod[] removeTheNonPublics(OJMethod[] src_methods)
private static final OJConstructor[] removeTheNonPublics(OJConstructor[] src_constrs)
private static final OJMethod[] pickupMethodsByName(OJMethod[] src_methods, String name)
private static final OJField pickupField(OJField[] src_fields, String name)
private static final OJMethod pickupMethod(OJMethod[] src_methods, String name, OJClass[] parameterTypes)
private static final OJConstructor pickupConstructor(OJConstructor[] src_constrs, OJClass[] parameterTypes)
private static final OJMethod pickupAcceptableMethod(OJMethod[] src_methods, String name, OJClass[] parameterTypes)
private static final OJConstructor pickupAcceptableConstructor(OJConstructor[] src_constrs, OJClass[] parameterTypes)
public OJClass[] getClasses()
OJClass
objects
representing all the public classes and interfaces
that are members of the class represented by this
OJClass
object. This includes public class and
interface members inherited from superclasses and public class
and interface members declared by the class. This method
returns an array of length 0 if this OJClass
object has no public member classes or interfaces. This method
also returns an array of length 0 if this OJClass
object represents a primitive type, an array class, or void.
public OJField[] getFields()
OJField
objects
reflecting all the accessible public fields of the
class or interface represented by this OJClass
object. The elements in the array returned are not sorted and
are not in any particular order. This method returns an array
of length 0 if the class or interface has no accessible public
fields, or if it represents an array class, a primitive type,
or void.
Specifically, if this OJClass
object
represents a class, this method returns the public fields of
this class and of all its superclasses. If this
OJClass
object represents an interface, this
method returns the fields of this interface and of all its
superinterfaces.
The implicit length field for array classs is reflected by this method.
OJField
public OJMethod[] getMethods()
OJMethod
objects
reflecting all the public member methods of the class
or interface represented by this OJClass
object,
including those declared by the class or interface and and
those inherited from superclasses and superinterfaces. The
elements in the array returned are not sorted and are not in
any particular order. This method returns an array of length 0
if this OJClass
object represents a class or
interface that has no public member methods, or if this
OJClass
object represents an array class, primitive
type, or void.
OJMethod
public OJConstructor[] getConstructors()
OJConstructor
objects
reflecting all the public constructors of the class
represented by this OJClass
object. An array of
length 0 is returned if the class has no public constructors,
or if the class is an array class, or if the class reflects a
primitive type or void.
OJConstructor
public OJField getField(String name) throws NoSuchMemberException
OJField
object that reflects the
specified public member field of the class or
interface represented by this OJClass
object. The
name
parameter is a String
specifying
the simple name of the desired field.
NoSuchMemberException
- if a field with the specified name is
not found.OJField
public OJMethod getMethod(String name, OJClass[] parameterTypes) throws NoSuchMemberException
OJMethod
object that reflects the
specified public member method of the class or interface
represented by this OJClass
object. The
name
parameter is a String
specifying
the simple name the desired method. The
parameterTypes
parameter is an array of
OJClass
objects that identify the method's formal
parameter types, in declared order. If
parameterTypes
is null
, it is treated
as if it were an empty array.
NoSuchMemberException
- if a matching method is not found
or if then name is "<init>"or "<clinit>".OJMethod
public OJConstructor getConstructor(OJClass[] parameterTypes) throws NoSuchMemberException
OJConstructor
object that reflects the
specified public constructor of the class represented by this
OJClass
object. The parameterTypes
parameter is an array of OJClass
objects that
identify the constructor's formal parameter types, in declared
order.
The constructor to reflect is the public constructor of the
class represented by this OJClass
object whose
formal parameter types match those specified by
parameterTypes
.
NoSuchMemberException
- if a matching method is not found.OJConstructor
public final OJClass[] getClasses(OJClass situation)
OJClass
objects
representing all the classes and interfaces which are members
of the class represented by this OJClass
object,
accessible from the situation represented by the given
OJClass
object. This includes class and interface
members inherited from superclasses and declared class and
interface members accessible from the given situation. This
method returns an array of length 0 if this
OJClass
object has no public member classes or
interfaces. This method also returns an array of length 0 if
this OJClass
object represents a primitive type,
an array class, or void.
The accessiblity depends on the package of the class, modifiers of each members, and the package of the situation.
public final OJField[] getFields(OJClass situation)
OJField
objects
reflecting all the fields of the class or interface represented
by this OJClass
object, accessible from the
situation represented by the given OJClass
object.
The elements in the array returned are not sorted and
are not in any particular order. This method returns an array
of length 0 if the class or interface has no accessible public
fields, or if it represents an array class, a primitive type,
or void.
Specifically, if this OJClass
object
represents a class, this method returns the public fields of
this class and of all its superclasses. If this
OJClass
object represents an interface, this
method returns the fields of this interface and of all its
superinterfaces.
The accessiblity depends on the package of the class, modifiers of each members, and the package of the situation.
The implicit length field for array classs is reflected by this method.
OJField
public final OJMethod[] getMethods(OJClass situation)
OJMethod
objects
reflecting all the member methods of the class or interface
represented by this OJClass
object, accesible from
the situation represented by the given OJClass
object. Returned methods include those declared by the class
or interface and and those inherited from superclasses and
superinterfaces. The elements in the array returned are not
sorted and are not in any particular order. This method
returns an array of length 0 if this OJClass
object represents a class or interface that has no public
member methods, or if this OJClass
object
represents an array class, primitive type, or void.
The accessiblity depends on the package of the class, modifiers of each members, and the package of the situation.
OJMethod
public final OJConstructor[] getConstructors(OJClass situation)
OJConstructor
objects
reflecting all the constructors of the class represented by
this OJClass
object, accesible from the situation
represented by the given OJClass
object. An array
of length 0 is returned if the class has no public
constructors, or if the class is an array class, or if the
class reflects a primitive type or void.
The accessiblity depends on the package of the class, modifiers of each members, and the package of the situation.
OJConstructor
public OJField getField(String name, OJClass situation) throws NoSuchMemberException
OJField
object that reflects the
specified member field accesible from the situation represented
by the given OJClass
object. The
name
parameter is a String
specifying
the simple name of the desired field.
NoSuchMemberException
- if a field with the specified name is
not found.OJField
public OJMethod getMethod(String name, OJClass[] parameterTypes, OJClass situation) throws NoSuchMemberException
OJMethod
object that reflects the
specified member method accesible from the situation
represented by the given OJClass
object. The
name
parameter is a String
specifying
the simple name the desired method. The
parameterTypes
parameter is an array of
OJClass
objects that identify the method's formal
parameter types, in declared order. If
parameterTypes
is null
, it is treated
as if it were an empty array.
NoSuchMemberException
- if a matching method is not found.OJMethod
public OJConstructor getConstructor(OJClass[] parameterTypes, OJClass situation) throws NoSuchMemberException
OJConstructor
object that reflects the
specified constructor accesible from the situation represented
by the given OJClass
object. The
parameterTypes
parameter is an array of
OJClass
objects that identify the constructor's
formal parameter types, in declared order.
The constructor to reflect is the constructor of the
class represented by this OJClass
object whose
formal parameter types match those specified by
parameterTypes
.
NoSuchMemberException
- if a matching method is not found.OJConstructor
public final OJField getAllField(String name) throws NoSuchMemberException
c.getField(name,c)
NoSuchMemberException
getField(String,OJClass)
public final OJMethod[] getAllMethods(String name)
public final OJMethod getAllMethod(String name, OJClass[] parameterTypes) throws NoSuchMemberException
c.getMethod(name,ptypes,c)
NoSuchMemberException
getMethod(String,OJClass[],OJClass)
public OJMethod getAcceptableMethod(String name, OJClass[] parameterTypes, OJClass situation) throws NoSuchMemberException
NoSuchMemberException
public OJConstructor getAcceptableConstructor(OJClass[] parameterTypes, OJClass situation) throws NoSuchMemberException
NoSuchMemberException
public OJClass[] getDeclaredClasses()
OJClass
objects reflecting all
the classes and interfaces declared as members of the class
represented by this OJClass
object. This includes
public, protected, default (package) access, and private
classes and interfaces declared by the class, but excludes
inherited classes and interfaces. This method returns an array
of length 0 if the class declares no classes or interfaces as
members, or if this OJClass
object represents a
primitive type, an array class, or void.
This method may be overriden to provide proper information in the extended language.
public OJField[] getDeclaredFields()
OJField
objects reflecting all
the fields declared by the class or interface represented by
this OJClass
object. This includes public,
protected, default (package) access, and private fields, but
excludes inherited fields. The elements in the array returned
are not sorted and are not in any particular order. This
method returns an array of length 0 if the class or interface
declares no fields, or if this OJClass
object
represents a primitive type, an array class, or void.
This method may be overriden to provide proper information in the extended language.
OJField
public OJMethod[] getDeclaredMethods()
OJMethod
objects reflecting all
the methods declared by the class or interface represented by
this OJClass
object. This includes public,
protected, default (package) access, and private methods, but
excludes inherited methods. The elements in the array returned
are not sorted and are not in any particular order. This
method returns an array of length 0 if the class or interface
declares no methods, or if this OJClass
object
represents a primitive type, an array class, or void. The
class initialization method <clinit>
is not
included in the returned array. If the class declares multiple
public member methods with the same parameter types, they are
all included in the returned array.
This method may be overriden to provide proper information in the extended language.
OJMethod
public OJConstructor[] getDeclaredConstructors()
OJConstructor
objects reflecting
all the constructors declared by the class represented by this
OJClass
object. These are public, protected, default
(package) access, and private constructors. The elements in
the array returned are not sorted and are not in any particular
order. If the class has a default constructor, it is included
in the returned array. This method returns an array of length
0 if this OJClass
object represents an interface, a
primitive type, an array class, or void.
This method may be overriden to provide proper information in the extended language.
OJConstructor
public final OJField getDeclaredField(String name) throws NoSuchMemberException
OJField
object that reflects the specified
declared field of the class or interface represented by this
OJClass
object. The name
parameter is a
String
that specifies the simple name of the
desired field. Note that this method will reflect the
length
field of an array class.
NoSuchMemberException
- if a field with the specified name is
not found.OJField
public final OJMethod getDeclaredMethod(String name, OJClass[] parameterTypes) throws NoSuchMemberException
OJMethod
object that reflects the
specified declared method of the class or interface represented
by this OJClass
object. The name
parameter is a String
that specifies the simple
name of the desired method, and the parameterTypes
parameter is an array of OJClass
objects that
identify the method's formal parameter types, in declared
order. If more than one method with the same parameter types
is declared in a class, and one of these methods has a return
type that is more specific than any of the others, that method
is returned; otherwise one of the methods is chosen
arbitrarily.
NoSuchMemberException
- if a matching method is not found.OJMethod
public final OJConstructor getDeclaredConstructor(OJClass[] parameterTypes) throws NoSuchMemberException
OJConstructor
object that reflects the
specified constructor of the class or interface represented by
this OJClass
object. The
parameterTypes
parameter is an array of
OJClass
objects that identify the constructor's
formal parameter types, in declared order.
NoSuchMemberException
- if a matching method is not found.OJConstructor
public InputStream getResourceAsStream(String name) throws CannotInspectException
CannotInspectException
public URL getResource(String name) throws CannotInspectException
CannotInspectException
public OJClass makeCopy(String qname) throws MOPException
qname
- a qualified name for the new copy.
MOPException
public boolean isExecutable()
public boolean isAlterable()
public Class getByteCode() throws CannotExecuteException
CannotExecuteException
public ClassDeclaration getSourceCode() throws CannotAlterException
CannotAlterException
public Class getCompatibleJavaClass()
public Signature signature()
signature
in interface OJMember
void setDeclaringClass(OJClass parent) throws CannotAlterException
CannotAlterException
public final void waitTranslation(OJClass clazz) throws MOPException
clazz
- a class metaobject to wait
MOPException
protected String setName(String simple_name) throws CannotAlterException
CannotAlterException
protected OJClass setSuperclass(OJClass clazz) throws CannotAlterException
CannotAlterException
protected OJClass[] setInterfaces(OJClass[] classes) throws CannotAlterException
CannotAlterException
protected void addInterface(OJClass clazz) throws CannotAlterException
CannotAlterException
public OJClass addClass(OJClass clazz) throws CannotAlterException
CannotAlterException
protected OJClass removeClass(OJClass clazz) throws CannotAlterException
CannotAlterException
public OJField addField(OJField field) throws CannotAlterException
CannotAlterException
public OJField removeField(OJField field) throws CannotAlterException
CannotAlterException
protected OJMethod addMethod(OJMethod method) throws CannotAlterException
CannotAlterException
protected OJMethod removeMethod(OJMethod method) throws CannotAlterException
CannotAlterException
protected OJConstructor addConstructor(OJConstructor constr) throws CannotAlterException
CannotAlterException
protected OJConstructor removeConstructor(OJConstructor constr) throws CannotAlterException
CannotAlterException
public void translateDefinition() throws MOPException
MOPException
public ClassDeclaration translateDefinition(Environment env, ClassDeclaration decl) throws MOPException
MOPException
public Expression expandFieldRead(Environment env, FieldAccess expr)
public Expression expandFieldWrite(Environment env, AssignmentExpression expr)
public Expression expandMethodCall(Environment env, MethodCall expr)
public TypeName expandTypeName(Environment env, TypeName expr)
public Expression expandAllocation(Environment env, AllocationExpression expr)
public Expression expandArrayAllocation(Environment env, ArrayAllocationExpression expr)
public Expression expandArrayAccess(Environment env, ArrayAccess expr)
public Expression expandAssignmentExpression(Environment env, AssignmentExpression expr)
public Expression expandExpression(Environment env, Expression expr)
public Statement expandVariableDeclaration(Environment env, VariableDeclaration decl)
public Expression expandCastExpression(Environment env, CastExpression decl)
public Expression expandCastedExpression(Environment env, CastExpression decl)
public OJField resolveException(NoSuchMemberException e, String name) throws NoSuchMemberException
NoSuchMemberException
public OJMethod resolveException(NoSuchMemberException e, String name, OJClass[] argtypes) throws NoSuchMemberException
NoSuchMemberException
public static boolean isRegisteredKeyword(String keyword)
public static SyntaxRule getDeclSuffixRule(String keyword)
public static SyntaxRule getTypeSuffixRule(String keyword)
public static boolean isRegisteredModifier(String keyword)
public final String getMetaInfo(String key)
public final Enumeration getMetaInfoKeys()
public final Enumeration getMetaInfoElements()
protected final String putMetaInfo(String key, String value) throws CannotAlterException
CannotAlterException
public final void writeMetaInfo(Writer out) throws IOException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |