|
Extension SDK 9.0.5 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The JotFile
interface defines the JOT model for a Java file.
The file may be either a source file or a compiled class file.
The JotFile methods to read from the model are available for all files.
Methods that modify the JOT model are only supported for source files;
attempts to modify a compiled source file will result in a
JotException
.
The JotFile for a file can be retrieved from a JotManager
instance.
JotManager
Field Summary |
Fields inherited from interface oracle.ide.addin.Subject |
OBJECT_MODIFIED |
Method Summary | |
void |
addBlankLine(JotFileElement elem,
boolean before)
Adds a blank line to this file. |
JotClass |
addClass(int index,
java.lang.String name)
Adds a new class declaration to this file at a specific location. |
JotClass |
addClass(java.lang.String name)
Adds a new class declaration to this file. |
void |
addComment(JotFileElement elem,
boolean before,
JotComment comment)
Adds a comment to this file. |
JotImport |
addImport(java.lang.String name)
Adds a new import statement to this file. |
void |
commitFile()
Commits any pending changes to the JOT model. |
void |
commitFile(boolean isUndoable)
Deprecated. use commitFile() or commitFile(String); |
void |
commitFile(boolean isUndoable,
java.lang.Object origin)
Deprecated. use commitFile(Object) or commitFile(Object, String) |
void |
commitFile(boolean isUndoable,
java.lang.Object origin,
java.lang.String undoText)
Deprecated. use commitFile(Object) or commitFile(Object, String) |
void |
commitFile(java.lang.Object origin)
Commits any pending changes to the JOT model. |
void |
commitFile(java.lang.Object origin,
java.lang.String undoText)
Commits any pending changes to the JOT model. |
void |
commitFile(java.lang.String undoText)
Commits any pending changes to the JOT model. |
JotComment |
createComment(int type,
java.lang.String text)
Creates a new comment. |
JotError[] |
getAllErrors()
|
JotClass |
getClass(java.lang.String name)
Retrieves a class by name. |
JotClass[] |
getClasses()
Retrieves the classes defined in this file. |
int |
getClassIndex(JotClass cls)
Retrieves the index of the class in this file. |
JotComment |
getComment(JotFileElement elem,
boolean before)
Retrieves the nearest comment to an element. |
JotComment[] |
getComments()
Retrieves all the file-level comments. |
JotDocComment |
getDocComment(JotClass cls)
Retrieves the current JavaDoc comment for a class. |
JotElement |
getElementAtCharacterOffset(int offset)
Retrieves the JotElement that contains the given character offset. |
JotImport |
getImport(java.lang.String name)
Retrieves the named import declaration. |
JotImport[] |
getImports()
Retrieves this file's import declarations. |
java.lang.String |
getMinimumReferenceName(java.lang.String type)
Determines whether a given type can be referred to by its short name. |
JotElement |
getNearestElement(int offset)
Retrieves the nearest element at, or to the right of a given offset, ignoring whitespace that may be present in a containing element (such as a code block) |
java.lang.String |
getPackage()
Retrieves the package name from this file's JotPackageStatement . |
JotPackageStatement |
getPackageStatement()
Retrieves the JotPackageStatement contained in this file. |
java.lang.String |
getQualifiedName(java.lang.String typeName)
Determines the fully qualified name for a given type name. |
JotError[] |
getSemanticErrors()
|
JotError[] |
getSyntaxErrors()
|
long |
getTimestamp()
Retrieves this file's timestamp. |
java.net.URL |
getURL()
Retrieve's this file's URL. |
boolean |
isReadOnly()
Whether this file is read-only. |
boolean |
isSource()
Indicates whether this JotFile instance represents a
source file or a compiled classfile. |
void |
removeClass(JotClass cls)
Removes a class from this file. |
void |
removeComment(JotComment comment)
Removes an existing comment. |
void |
removeImport(JotImport imp)
Removes an existing import from this file. |
void |
rollbackFile()
Rolls back any pending changes to the JOT model. |
JotDocComment |
setDocComment(JotClass cls,
java.lang.String text)
Sets the JavaDoc comment for a class. |
void |
setPackage(java.lang.String pkgName)
Sets the package name in this file's JotPackageStatement . |
void |
setPackageStatement(JotPackageStatement packageStatment,
JotElement placementElement,
boolean beforeElement)
Sets the JotPackageStatement for this file. |
Methods inherited from interface oracle.ide.addin.Subject |
attach, detach, notifyObservers |
Methods inherited from interface oracle.jdeveloper.jot.JotElement |
getChildren, getContainedElements, getElementName, getElementType, getEndOffset, getID, getJotWorkArea, getParent, getStartOffset, isExistent, isStructureKnown, setParent |
Methods inherited from interface oracle.jdeveloper.jot.JotFileLock |
isLockable, readLockFile, readLockModel, readUnlockFile, readUnlockModel, writeLock, writeUnlock |
Method Detail |
public java.net.URL getURL()
public JotPackageStatement getPackageStatement() throws JotInvalidElementException
JotPackageStatement
contained in this file.
JotPackageStatement
, or null if none exists.
JotInvalidElementException
public void setPackageStatement(JotPackageStatement packageStatment, JotElement placementElement, boolean beforeElement) throws JotInvalidElementException
JotPackageStatement
for this file. If one currently exists
it is removed to avoid conflict with the new one.
placementElement
- the JotElement
the package statement should be placed
adjacent to. If this argument is null
the package statement is placed
at the beginning of the file.beforeElement
- if true, the package statement is placed before the specified
placement element. Otherwise it is placed after.
JotInvalidElementException
public JotError[] getAllErrors() throws JotInvalidElementException
JotError instances in this file, including
both syntax and semantic errors.
- Throws:
JotInvalidElementException
public JotError[] getSyntaxErrors() throws JotInvalidElementException
JotInvalidElementException
public JotError[] getSemanticErrors() throws JotInvalidElementException
JotInvalidElementException
public java.lang.String getPackage() throws JotInvalidElementException
JotPackageStatement
.
JotInvalidElementException
public void setPackage(java.lang.String pkgName) throws JotInvalidElementException, JotException
JotPackageStatement
.
Creating a new JotPackageStatement
and inserting it in the file
if none already exists.
pkgName
- the new package name for this file. Specifying
null
will remove the package statement.
JotException
- if this file's package cannot be changed.
JotInvalidElementException
public long getTimestamp() throws JotInvalidElementException
JotFile
instance, expressed as milliseconds since
00:00:00 UTC on January 1, 1970.
JotInvalidElementException
public boolean isReadOnly() throws JotInvalidElementException
isReadOnly
in interface JotElement
JotInvalidElementException
public java.lang.String getMinimumReferenceName(java.lang.String type) throws JotInvalidElementException
type
- the fully qualified type name.
JotInvalidElementException
public JotClass[] getClasses() throws JotInvalidElementException
JotClass
instances;
if the file contains no classes the array is empty.
JotInvalidElementException
public JotClass getClass(java.lang.String name) throws JotInvalidElementException
name
- the name of the desired class. The name may be
optionally fully qualified.
JotClass
instance for the Class, or
null
if the class is not found in this JotFile
.
JotInvalidElementException
public JotClass addClass(java.lang.String name) throws JotInvalidElementException, JotException
name
- the name of the new class.
JotException
- if new classes cannot be added to this file
or the specified classname is not a valid classname.
JotInvalidElementException
public JotClass addClass(int index, java.lang.String name) throws JotInvalidElementException, JotException
index
- the location to insert the new class.name
- the name of the new class.
JotException
- if new classes cannot be added to this file
or the specified classname is not a valid classname.
JotInvalidElementException
public void removeClass(JotClass cls) throws JotInvalidElementException, JotException
cls
- the class to remove. If the class does not exist in this file,
or is not a top-level class, nothing is done.
JotException
- if this file cannot have classes removed.
JotInvalidElementException
public int getClassIndex(JotClass cls) throws JotInvalidElementException
cls
- the top-level class whose location is desired.
JotInvalidElementException
public JotImport[] getImports() throws JotInvalidElementException
JotImport
instances.
JotInvalidElementException
public JotImport getImport(java.lang.String name) throws JotInvalidElementException
name
- the body of an import declaration, such as
java.awt.Button or javax.swing.*.
JotImport
instance, or null
if not found.
JotInvalidElementException
public JotImport addImport(java.lang.String name) throws JotInvalidElementException, JotException
name
- the name of the new import statement. This should either
be a fully qualified classname (for example, java.awt.Button) or
a package with a wildcard (for example, java.io.*).
JotException
- if this file cannot have its import list modified.
JotInvalidElementException
public void removeImport(JotImport imp) throws JotInvalidElementException, JotException
imp
- the import to remove.
JotException
- if this file does not support removing imports.
JotInvalidElementException
public boolean isSource() throws JotInvalidElementException
JotFile
instance represents a
source file or a compiled classfile.
JotFile
instance represents a
source file, false otherwise.
JotInvalidElementException
public void commitFile() throws JotInvalidElementException, JotException
JotException
- if the changes cannot be commited.
JotInvalidElementException
public void commitFile(java.lang.Object origin) throws JotInvalidElementException, JotException
origin
- the originator of the commit request.
JotException
- if the changes cannot be commited.
JotInvalidElementException
public void commitFile(java.lang.String undoText) throws JotInvalidElementException, JotException
undoText
- the text to use for the undo label.
JotException
- if the changes cannot be commited.
JotInvalidElementException
public void commitFile(java.lang.Object origin, java.lang.String undoText) throws JotInvalidElementException, JotException
undoText
- the text to use for the undo label.origin
- the originator of the commit request.
JotException
- if the changes cannot be commited.
JotInvalidElementException
public void commitFile(boolean isUndoable) throws JotInvalidElementException, JotException
isUndoable
- whether the generated command can be undone.
JotException
- if the changes cannot be commited.
JotInvalidElementException
commitFile()
,
commitFile(String)
public void commitFile(boolean isUndoable, java.lang.Object origin) throws JotInvalidElementException, JotException
isUndoable
- whether the generated command can be undone.origin
- the originator of the commit request.
JotException
- if the changes cannot be commited.
JotInvalidElementException
commitFile(Object, String)
,
commitFile(Object)
public void commitFile(boolean isUndoable, java.lang.Object origin, java.lang.String undoText) throws JotInvalidElementException, JotException
isUndoable
- whether the generated command can be undone.origin
- the originator of the commit request.undoText
- the text to display for the undo of this command. If
isUndoable
is false, undoText
is ignored.
JotException
- if the changes cannot be commited.
JotInvalidElementException
commitFile(Object, String)
,
commitFile(Object)
public void rollbackFile() throws JotInvalidElementException, JotException
JotException
- if the file cannot be rolled back.
JotInvalidElementException
public JotDocComment setDocComment(JotClass cls, java.lang.String text) throws JotInvalidElementException
cls
- the JotClass
to comment.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(JotClass cls) throws JotInvalidElementException
cls
- the class 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(JotFileElement, boolean, JotComment)
public void addComment(JotFileElement elem, boolean before, JotComment comment) throws JotInvalidElementException
elem
- the existing file element to position the comment relative
to.before
- whether to add the comment before or after the element.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(JotFileElement elem, boolean before) throws JotInvalidElementException
elem
- the element to use for finding the comment.before
- whether to look before or after the element.
null
if no
comment can be found at the specified location.
JotInvalidElementException
public void addBlankLine(JotFileElement elem, boolean before) throws JotInvalidElementException
elem
- the existing file element to add the blank line relative to.before
- whether to add the blank line before or after the element.
JotInvalidElementException
public java.lang.String getQualifiedName(java.lang.String typeName) throws JotInvalidElementException
JotInvalidElementException
public JotElement getElementAtCharacterOffset(int offset) throws JotInvalidElementException
JotElement
that contains the given character offset. A
JotFile
that does not support character offsets will return null.
offset
- the character offset used to find the correct element.
JotElement
that contains the character offset.
java.lang.IndexOutOfBoundsException
- if the offset is not in the file.
JotInvalidElementException
public JotElement getNearestElement(int offset) throws JotInvalidElementException
offset
- the character offset used to find the correct element.
JotElement
nearest the character offset.
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.