|
Extension SDK 9.0.5 | ||||||||||
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 |
isHidden()
|
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, getModifierText, setModifiers, setModifierText |
Methods inherited from interface oracle.jdeveloper.jot.JotNameable |
getName, setName |
Methods inherited from interface oracle.jdeveloper.jot.JotCodeElement |
addPrecedingComment, childrenContainErrors, delete, getContainingJotFile, getLeftWhitespace, getLength, getRightWhitespace, isInError, setLeftWhitespace, setRightWhitespace |
Methods inherited from interface oracle.jdeveloper.jot.JotElement |
getChildren, getContainedElements, getElementName, getElementType, getEndOffset, getID, getJotWorkArea, getParent, getStartOffset, isExistent, isReadOnly, isStructureKnown, setParent |
Method Detail |
public JotFile getFile() throws JotInvalidElementException
JotClass
instance.
JotInvalidElementException
public JotClass getDeclaringClass() throws JotInvalidElementException
JotInvalidElementException
public boolean isAssignableFrom(JotClass cls) throws JotInvalidElementException
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.
JotInvalidElementException
public boolean isInterface()
JotClass
instance is an
interface.
true
if this type is an
interface, else false
.public void setIsInterface(boolean isIface) throws JotInvalidElementException, 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.
JotInvalidElementException
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() throws JotInvalidElementException
true
if this JotClass
is deprecated.
JotInvalidElementException
public boolean isHidden() throws JotInvalidElementException
true
if this JotClass
is hidden.
JotInvalidElementException
public JotType getComponentType() throws JotInvalidElementException
JotClass
instance is an
array, else null
.
JotInvalidElementException
public JotType getType() throws JotInvalidElementException
JotType
instance that contains this
JotClass
instance.
JotType
representing this instance.
JotInvalidElementException
public JotType getSuperclass() throws JotInvalidElementException
JotInvalidElementException
public void setSuperclass(java.lang.String sCls) throws JotInvalidElementException, 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.
JotInvalidElementException
public JotType[] getInterfaces() throws JotInvalidElementException
JotType
instances containing this
instance's declared superinterfaces. If this instance is an array or
primitive the array is empty.
JotInvalidElementException
public void addInterface(java.lang.String iface) throws JotInvalidElementException, 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.
JotInvalidElementException
public void removeInterface(JotType iface) throws JotInvalidElementException, 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.
JotInvalidElementException
public JotField[] getDeclaredFields() throws JotInvalidElementException
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.
JotInvalidElementException
public JotField getDeclaredField(java.lang.String name) throws JotInvalidElementException
name
- the simple (unqualified) name of a declared field.
JotInvalidElementException
public JotField[] getFields() throws JotInvalidElementException
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.
JotInvalidElementException
public JotField getField(java.lang.String name) throws JotInvalidElementException
name
- the simple (unqualified) name of a declared or inherited field.
JotInvalidElementException
public JotField addField(JotMember member, boolean before, java.lang.String type, java.lang.String name) throws JotInvalidElementException, 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.
JotInvalidElementException
public void removeField(JotField fld) throws JotInvalidElementException, 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.
JotInvalidElementException
public JotMethod[] getDeclaredMethods() throws JotInvalidElementException
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.
JotInvalidElementException
public JotMethod[] getDeclaredMethods(java.lang.String name) throws JotInvalidElementException
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.
JotInvalidElementException
public JotMethod getDeclaredMethod(java.lang.String name, JotType[] parameterTypes) throws JotInvalidElementException
name
- the simple (unqualified) name of a method declared for this
type.parameterTypes
- an array of parameter types.
JotInvalidElementException
public JotMethod[] getMethods() throws JotInvalidElementException
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.
JotInvalidElementException
public JotMethod[] getMethods(java.lang.String methodName) throws JotInvalidElementException
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.
JotInvalidElementException
public JotMethod getMethod(java.lang.String name, JotType[] parameterTypes) throws JotInvalidElementException
name
- the simple (unqualified) name of a method declared for this
type, or in any superclass or superinterface.parameterTypes
- an array of parameter types.
JotInvalidElementException
public JotMethod addMethod(JotMember member, boolean before, java.lang.String returnType, java.lang.String name) throws JotInvalidElementException, 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.
JotInvalidElementException
public void removeMethod(JotMethod method) throws JotInvalidElementException, 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.
JotInvalidElementException
public JotConstructor[] getDeclaredConstructors() throws JotInvalidElementException
JotClass
instance.
The array has length 0 if this type is not a class.
JotInvalidElementException
public JotConstructor getDeclaredConstructor(JotType[] parameterTypes) throws JotInvalidElementException
parameterTypes
- an array of parameter types.
JotInvalidElementException
public JotConstructor[] getConstructors() throws JotInvalidElementException
JotClass
instance.
The array has length 0 if this type is not a class, or is a class with no
public constructors.
JotInvalidElementException
public JotConstructor getConstructor(JotType[] parameterTypes) throws JotInvalidElementException
parameterTypes
- an array of parameter types.
JotInvalidElementException
public JotConstructor addConstructor(JotMember member, boolean before) throws JotInvalidElementException, 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.
JotInvalidElementException
public void removeConstructor(JotConstructor ctor) throws JotInvalidElementException, 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.
JotInvalidElementException
public JotClassInitializer[] getDeclaredInitializers() throws JotInvalidElementException
JotClassInitializer
s representing
this classes initializers. If this type
represents a primitive, array, or interface type, a zero-length
array is returned.
JotInvalidElementException
public JotClassInitializer addInitializer(JotMember member, boolean before) throws JotInvalidElementException, 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.
JotInvalidElementException
public void removeInitializer(JotClassInitializer init) throws JotInvalidElementException, 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.
JotInvalidElementException
public JotInnerClass[] getDeclaredInnerClasses() throws JotInvalidElementException
JotClass
instance.
The array has length 0 if this type is not a class, or is a class with no
inner classes.
JotInvalidElementException
public JotInnerClass[] getInnerClasses() throws JotInvalidElementException
JotClass
instance.
The array has length 0 if this type is not a class, or is a class with no
inner classes.
JotInvalidElementException
public JotInnerClass addInnerClass(JotMember member, boolean before, java.lang.String clsName) throws JotInvalidElementException, 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.
JotInvalidElementException
public void removeInnerClass(JotClass cls) throws JotInvalidElementException, 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.
JotInvalidElementException
public boolean isSource() throws JotInvalidElementException
JotClass
represents a class in a source file
or in a compiled class file.
isSource
in interface JotCodeElement
JotClass
is contained in a source file,
or false if this the file is compiled.
JotInvalidElementException
public JotDocComment setDocComment(JotMember member, java.lang.String text) throws JotInvalidElementException
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.
JotInvalidElementException
public JotDocComment getDocComment(JotMember member) throws JotInvalidElementException
member
- the member whose doc comment is desired.
null
if no
comment exists.
JotInvalidElementException
public JotComment createComment(int type, java.lang.String text) throws JotInvalidElementException
type
- the type of comment to create.text
- the text of the comment. The comment characters should be
omitted.
JotInvalidElementException
addComment(JotMember, boolean, JotComment)
public void addComment(JotMember member, boolean before, JotComment comment) throws JotInvalidElementException
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.
JotInvalidElementException
public void removeComment(JotComment comment) throws JotInvalidElementException
comment
- the comment to remove.
JotInvalidElementException
public JotComment[] getComments() throws JotInvalidElementException
JotInvalidElementException
public JotComment getComment(JotMember member, boolean before) throws JotInvalidElementException
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.
JotInvalidElementException
public void addBlankLine(JotMember member, boolean before) throws JotInvalidElementException
member
- the existing member to add the blank line relative to.before
- whether to add the blank line before or after the member.
JotInvalidElementException
public JotComment convertMemberToComment(JotMember member) throws JotInvalidElementException
member
- an existing member in the class
null
is returned.
JotInvalidElementException
public java.lang.String getPackage() throws JotInvalidElementException
JotInvalidElementException
|
Extension SDK | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1997, 2004, Oracle. All rights reserved.