|
Extension SDK | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The JotClass
interface represents the JOT model for a
Java class. A JotClass
represents one of four kinds of types:
classes, interfaces, arrays, and primitive types. An instance's kind of
type can be determined by calling the predicates isInterface(),
isArray(), and isPrimitive(): at most one is
true, and if all are false the instance is a class.
Other methods retrieve parts of the type's Java definition. Some methods are not meaningful for all four kinds of types.
JotClass
provides read and write access to a type.
Methods that modify the type may throw a JotException
if
the type cannot be modified. Arrays and primitive types are immutable,
as are class or interface types representing a compiled class file.
Method Summary | |
void |
addBlankLine(JotMember member,
boolean before)
Adds a blank line to this file. |
void |
addComment(JotMember member,
boolean before,
JotComment comment)
Adds a comment to this file. |
JotConstructor |
addConstructor(JotMember member,
boolean before)
Adds a new constructor to this type. |
JotField |
addField(JotMember member,
boolean before,
java.lang.String type,
java.lang.String name)
Adds a new field to this type. |
JotClassInitializer |
addInitializer(JotMember member,
boolean before)
Adds a new initializer to this type. |
JotInnerClass |
addInnerClass(JotMember member,
boolean before,
java.lang.String clsName)
Adds a new member class to this class or interface. |
void |
addInterface(java.lang.String iface)
Adds a superinterface to this instance's type declaration. |
JotMethod |
addMethod(JotMember member,
boolean before,
java.lang.String returnType,
java.lang.String name)
Adds a new method to this type. |
JotComment |
convertMemberToComment(JotMember member)
Converts an existing member to a comment. |
JotComment |
createComment(int type,
java.lang.String text)
Creates a new comment. |
JotComment |
getComment(JotMember member,
boolean before)
Retrieves the nearest comment to a member. |
JotComment[] |
getComments()
Retrieves all the class-level comments. |
JotType |
getComponentType()
Gets the element type, if this is an array type. |
JotConstructor |
getConstructor(JotType[] parameterTypes)
Gets the public constructor that takes parameters of the given types. |
JotConstructor[] |
getConstructors()
Creates an array of the public constructors declared for this type. |
JotConstructor |
getDeclaredConstructor(JotType[] parameterTypes)
Gets the constructor that takes parameters of the given types. |
JotConstructor[] |
getDeclaredConstructors()
Creates an array of all the constructors declared for this type. |
JotField |
getDeclaredField(java.lang.String name)
Gets the declared field member having the given name. |
JotField[] |
getDeclaredFields()
Creates an array of declared field members. |
JotClassInitializer[] |
getDeclaredInitializers()
Retrieves the initializers declared within this class. |
JotInnerClass[] |
getDeclaredInnerClasses()
Creates an array of the inner classes declared for this type. |
JotMethod |
getDeclaredMethod(java.lang.String name,
JotType[] parameterTypes)
Gets the declared method having the given name and parameter types. |
JotMethod[] |
getDeclaredMethods()
Creates an array of all declared method members. |
JotMethod[] |
getDeclaredMethods(java.lang.String name)
Creates an array of all declared methods having a given name. |
JotClass |
getDeclaringClass()
Retrieves the class in which this class is declared. |
JotDocComment |
getDocComment(JotMember member)
Retrieves the current JavaDoc comment for a member. |
JotField |
getField(java.lang.String name)
Gets this type's field member having the given name. |
JotField[] |
getFields()
Creates an array of declared and inherited public field members. |
JotFile |
getFile()
Retrieves the file associated with this JotClass instance. |
JotInnerClass[] |
getInnerClasses()
Creates an array of the public inner classes declared for this type. |
JotType[] |
getInterfaces()
Gets this instance's superinterface declarations. |
JotMethod |
getMethod(java.lang.String name,
JotType[] parameterTypes)
Gets the declared or inherited public method having the given name and parameter types. |
JotMethod[] |
getMethods()
Creates an array of public declared and inherited method members. |
JotMethod[] |
getMethods(java.lang.String methodName)
Creates an array of declared and inherited public methods having a given name. |
java.lang.String |
getPackage()
Retrieves the package name from this class's file's package declaration. |
JotType |
getSuperclass()
Gets the superclass type of this class. |
JotType |
getType()
Gets the JotType instance that contains this
JotClass instance. |
boolean |
isArray()
Tests if the type represented by this JotClass instance is an
array. |
boolean |
isAssignableFrom(JotClass cls)
Tests whether the type represented by this JotClass instance
is either the same as, or is a
superclass or superinterface of, a given class. |
boolean |
isDeprecated()
|
boolean |
isInterface()
Tests if the type represented by this JotClass instance is an
interface. |
boolean |
isPrimitive()
Tests if the type represented by this JotClass instance is
a primitive type; boolean, one of the five integer types
(byte, char, int, short, and
long), or one of the two floating point types (float,
and double). |
boolean |
isSource()
Whether this JotClass represents a class in a source file
or in a compiled class file. |
void |
removeComment(JotComment comment)
Removes an existing comment. |
void |
removeConstructor(JotConstructor ctor)
Removes an existing constructor from this type. |
void |
removeField(JotField fld)
Removes an existing field from this type. |
void |
removeInitializer(JotClassInitializer init)
Removes an existing initializer from this type. |
void |
removeInnerClass(JotClass cls)
Removes a member class from this class or interface. |
void |
removeInterface(JotType iface)
Removes a superinterface from this type declaration. |
void |
removeMethod(JotMethod method)
Removes an existing method from this type. |
JotDocComment |
setDocComment(JotMember member,
java.lang.String text)
Sets the JavaDoc comment for a member. |
void |
setIsInterface(boolean isIface)
Marks whether this JotClass instance represents an interface. |
void |
setSuperclass(java.lang.String sCls)
Sets the superclass type for this class. |
Methods inherited from interface java.lang.Comparable |
compareTo |
Methods inherited from interface oracle.jdeveloper.jot.JotHasModifiers |
getModifiers, setModifiers |
Methods inherited from interface oracle.jdeveloper.jot.JotNameable |
getName, setName |
Methods inherited from interface oracle.jdeveloper.jot.JotElement |
getElementName, getElementType, getEndOffset, getID, getJotWorkArea, getParent, getStartOffset, isExistent, isReadOnly, isStructureKnown, setParent |
Method Detail |
public JotFile getFile()
JotClass
instance.
public JotClass getDeclaringClass()
public boolean isAssignableFrom(JotClass cls)
JotClass
instance
is either the same as, or is a
superclass or superinterface of, a given class.
cls
- the type to be tested.
java.lang.NullPointerException
- if cls is null.public boolean isInterface()
JotClass
instance is an
interface.
true
if this type is an
interface, else false
.public void setIsInterface(boolean isIface) throws JotException
isIface
- true
if this JotClass should represent
an interface, false
if this JotClass should represent a class.
JotException
- if this type represents a primitive or array type;
or this type represents a class or interface obtained from a compiled
class file.public boolean isPrimitive()
JotClass
instance is
a primitive type; boolean, one of the five integer types
(byte, char, int, short, and
long), or one of the two floating point types (float,
and double).
true
if this type is one of the constants defined in
JotPrimitiveClass
, else false
.public boolean isArray()
JotClass
instance is an
array.
true
if this JotClass
instance is an
array, else false
.public boolean isDeprecated()
true
if this JotClass
is deprecated.public JotType getComponentType()
JotClass
instance is an
array, else null
.public JotType getType()
JotType
instance that contains this
JotClass
instance.
JotType
representing this instance.public JotType getSuperclass()
public void setSuperclass(java.lang.String sCls) throws JotException
sCls
- the name of the superclass; if this classname is not fully
qualified, it will be resolved using the import context of the
file containing this class.
JotException
- if this type represents a primitive, array or
interface type; or this type represents a class obtained from a compiled
class file.public JotType[] getInterfaces()
JotType
instances containing this
instance's declared superinterfaces. If this instance is an array or
primitive the array is empty.public void addInterface(java.lang.String iface) throws JotException
iface
- the name of the new interface; if this interface name is not
fully qualified, it will be resolved using the import context of the file
containing this type.
JotException
- if this type represents a primitive or array type;
or the class or interface represented by this type is obtained from
a compiled class file.public void removeInterface(JotType iface) throws JotException
iface
- the interface type to remove.
JotException
- if this type represents a primitive or array type;
or the class or interface represented by this type is obtained from
a compiled class file.public JotField[] getDeclaredFields()
JotClass
instance. Inherited fields are
excluded. The array has length 0 if this type is an array or is primitive,
or if it is a class or interface having no declared fields.public JotField getDeclaredField(java.lang.String name)
name
- the simple (unqualified) name of a declared field.
public JotField[] getFields()
JotClass
instance as well as those
inherited from superclasses or superinterfaces.
The array has length 0 if this type is an array or is primitive,
or if it is a class or interface having no fields.public JotField getField(java.lang.String name)
name
- the simple (unqualified) name of a declared or inherited field.
public JotField addField(JotMember member, boolean before, java.lang.String type, java.lang.String name) throws JotException
member
- an existing member of this type to position relative to, or
null
to position at the beginning or end.before
- whether to position the new field before or after the existing
member; or, if the member is null
, whether to position the new
field at the beginning or the end of the declaration.type
- the type of the field; if the type is not fully qualified (or a
primitive type), the type will resolved using the import context of the
file containing this type.name
- the name of the new field.
JotField
representing the new field.
JotException
- if this type represents a primitive or array type;
or the class or interface represented by this type is obtained from
a compiled class file.public void removeField(JotField fld) throws JotException
fld
- the field to remove. If the field is not a current member of this
class or interface, the remove request is ignored.
JotException
- if this type represents a primitive or array type;
or the class or interface represented by this type is obtained from
a compiled class file.public JotMethod[] getDeclaredMethods()
JotClass
instance. Inherited methods are
excluded. The array has length 0 if this type is an array or is primitive,
or if it is a class or interface having no declared methods.public JotMethod[] getDeclaredMethods(java.lang.String name)
name
- a simple (unqualified) name.
JotClass
instance.
Inherited methods are excluded. The array has length 0 if this type is an
array or is primitive, or if it is a class or interface having no declared
methods of the given name.public JotMethod getDeclaredMethod(java.lang.String name, JotType[] parameterTypes)
name
- the simple (unqualified) name of a method declared for this
type.parameterTypes
- an array of parameter types.
public JotMethod[] getMethods()
JotClass
instance, or in any
superclass or superinterface.
The array has length 0 if this type is an array or is primitive,
or if it is a class or interface having no such methods.public JotMethod[] getMethods(java.lang.String methodName)
JotClass
instance, or
in any superclass or superinterface. The array has length 0 if this type
is an array or is primitive, or if it is a class or interface having no
methods of the given name.public JotMethod getMethod(java.lang.String name, JotType[] parameterTypes)
name
- the simple (unqualified) name of a method declared for this
type, or in any superclass or superinterface.parameterTypes
- an array of parameter types.
public JotMethod addMethod(JotMember member, boolean before, java.lang.String returnType, java.lang.String name) throws JotException
member
- an existing member of this type to position relative to, or
null
to position at the beginning or end.before
- whether to position the new method before or after the existing
member; or, if the member is null
, whether to position the new
method at the beginning or the end of the declaration.returnType
- the return type of the methodname
- the name of the new method.
JotMethod
representing the new method.
JotException
- if this type represents a primitive or array type;
or the class or interface represented by this type is obtained from
a compiled class file.public void removeMethod(JotMethod method) throws JotException
JotException
- if this type represents a primitive or array type;
or the class or interface represented by this type is obtained from
a compiled class file.public JotConstructor[] getDeclaredConstructors()
JotClass
instance.
The array has length 0 if this type is not a class.public JotConstructor getDeclaredConstructor(JotType[] parameterTypes)
parameterTypes
- an array of parameter types.
public JotConstructor[] getConstructors()
JotClass
instance.
The array has length 0 if this type is not a class, or is a class with no
public constructors.public JotConstructor getConstructor(JotType[] parameterTypes)
parameterTypes
- an array of parameter types.
public JotConstructor addConstructor(JotMember member, boolean before) throws JotException
member
- an existing member of this type to position relative to, or
null
to position at the beginning or end.before
- whether to position the new constructor before or after the existing
member; or, if the member is null
, whether to position the new
constructor at the beginning or the end of the declaration.
JotConstructor
representing the new constructor.
JotException
- if this type represents a primitive or array type;
or the class or interface represented by this type is obtained from
a compiled class file.public void removeConstructor(JotConstructor ctor) throws JotException
JotException
- if this type represents a primitive or array type;
or the class or interface represented by this type is obtained from
a compiled class file.public JotClassInitializer[] getDeclaredInitializers()
JotClassInitializer
s representing
this classes initializers. If this type
represents a primitive, array, or interface type, a zero-length
array is returned.public JotClassInitializer addInitializer(JotMember member, boolean before) throws JotException
member
- an existing member of this type to position relative to, or
null
to position at the beginning or end.before
- whether to position the new initializer before or after the existing
member; or, if the member is null
, whether to position the new
initializer at the beginning or the end of the declaration.
JotClassInitializer
representing the new initializer.
JotException
- if this type represents a primitive or array type;
or the class or interface represented by this type is obtained from
a compiled class file.public void removeInitializer(JotClassInitializer init) throws JotException
JotException
- if this type represents a primitive or array type;
or the class or interface represented by this type is obtained from
a compiled class file.public JotInnerClass[] getDeclaredInnerClasses()
JotClass
instance.
The array has length 0 if this type is not a class, or is a class with no
inner classes.public JotInnerClass[] getInnerClasses()
JotClass
instance.
The array has length 0 if this type is not a class, or is a class with no
inner classes.public JotInnerClass addInnerClass(JotMember member, boolean before, java.lang.String clsName) throws JotException
member
- an existing member of this type to position relative to, or
null
to position at the beginning or end.before
- whether to position the new member class before or after the existing
member; or, if the member is null
, whether to position the new
member class at the beginning or the end of the declaration.clsName
- the name of the new member class.
JotInnerClass
representing the new member class.
JotException
- if this type represents a primitive or array type;
or the class or interface represented by this type is obtained from
a compiled class file.public void removeInnerClass(JotClass cls) throws JotException
cls
- the member class to remove.
JotException
- if this type represents a primitive or array type; or
the class or interface represented by this JotClass is
obtained from a compiled class file.
public boolean isSource()
JotClass
represents a class in a source file
or in a compiled class file.
JotClass
is contained in a source file,
or false if this the file is compiled.public JotDocComment setDocComment(JotMember member, java.lang.String text)
text
- the text of the doc comment. The comment start and end
characters should be omitted, as well as the '*' characters at the start
of each line.
public JotDocComment getDocComment(JotMember member)
member
- the member whose doc comment is desired.
null
if no
comment exists.public JotComment createComment(int type, java.lang.String text)
type
- the type of comment to create.text
- the text of the comment. The comment characters should be
omitted.
addComment(JotMember, boolean, JotComment)
public void addComment(JotMember member, boolean before, JotComment comment)
member
- the existing member to position the comment relative
to.before
- whether to add the comment before or after the member.comment
- the comment to add.public void removeComment(JotComment comment)
comment
- the comment to remove.public JotComment[] getComments()
public JotComment getComment(JotMember member, boolean before)
member
- the member to use for finding the comment.before
- whether to look before or after the member.
null
if no
comment can be found at the specified location.public void addBlankLine(JotMember member, boolean before)
member
- the existing member to add the blank line relative to.before
- whether to add the blank line before or after the member.public JotComment convertMemberToComment(JotMember member)
member
- an existing member in the class
null
is returned.public java.lang.String getPackage()
|
Extension SDK | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright ©1997, 2003, Oracle. All rights reserved.