|
org.openide.src 1.8.22 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.openide.src.Element org.openide.src.SourceElement
public final class SourceElement
Describes an entire Java source file. Note that there is no standard in-memory implementation of this element; every user of the class is expected to have a reasonable implementation according to where the source file resides.
The source element should be parsed in the background using
prepare()
before any attempts are made to access its properties
to read or to write, or to call print(org.openide.src.ElementPrinter)
;
otherwise such accesses will block until the parse is finished.
Nested Class Summary | |
---|---|
static interface |
SourceElement.Impl
Pluggable behaviour for source elements. |
Nested classes/interfaces inherited from class org.openide.src.Element |
---|
Element.Impl2 |
Field Summary | |
---|---|
static int |
STATUS_ERROR
Status when the source element contains unrecoverable errors. |
static int |
STATUS_NOT
Status when the source element is not yet prepared. |
static int |
STATUS_OK
Status when the source element has been parsed and is error-free. |
static int |
STATUS_PARTIAL
Status when the source element contains minor errors. |
Fields inherited from class org.openide.src.Element |
---|
impl, impl2 |
Fields inherited from interface org.openide.src.ElementProperties |
---|
PROP_ALL_CLASSES, PROP_BODY, PROP_CLASS_OR_INTERFACE, PROP_CLASSES, PROP_CONSTRUCTORS, PROP_EXCEPTIONS, PROP_FIELDS, PROP_IMPORTS, PROP_INIT_VALUE, PROP_INITIALIZERS, PROP_INTERFACES, PROP_JAVADOC, PROP_MEMBERS, PROP_METHODS, PROP_MODIFIERS, PROP_NAME, PROP_PACKAGE, PROP_PARAMETERS, PROP_RETURN, PROP_STATIC, PROP_STATUS, PROP_SUPERCLASS, PROP_TYPE, PROP_VALID |
Constructor Summary | |
---|---|
SourceElement(SourceElement.Impl impl)
Create a new source element. |
Method Summary | |
---|---|
void |
addClass(ClassElement el)
Add a new top-level class. |
void |
addClasses(ClassElement[] els)
Add some new top-level classes. |
void |
addImport(Import el)
Add an import. |
void |
addImports(Import[] els)
Add some imports. |
ClassElement[] |
getAllClasses()
Get all classes recursively, both top-level and inner. |
ClassElement |
getClass(Identifier name)
Find a top-level class by name. |
ClassElement[] |
getClasses()
Get the top-level classes. |
Import[] |
getImports()
Get all imports. |
Identifier |
getPackage()
Get the package of this source file. |
int |
getStatus()
Get the parsing status of the element. |
Task |
prepare()
Begin parsing this source element. |
void |
print(ElementPrinter printer)
Print this element (and all its subelements) into an element printer. |
void |
removeClass(ClassElement el)
Remove an top-level class. |
void |
removeClasses(ClassElement[] els)
Remove some top-level classes. |
void |
removeImport(Import el)
Remove an import. |
void |
removeImports(Import[] els)
Remove some imports. |
void |
runAtomic(Runnable run)
Lock the underlaing document to have exclusive access to it and could make changes on this SourceElement. |
void |
runAtomicAsUser(Runnable run)
Executes given runnable in "user mode" does not allowing any modifications to parts of text marked as guarded. |
void |
setClasses(ClassElement[] els)
Set the top-level classes. |
void |
setImports(Import[] imprt)
Set all imports. |
void |
setPackage(Identifier id)
Set the package of this source file. |
Methods inherited from class org.openide.src.Element |
---|
addPropertyChangeListener, addVetoableChangeListener, getCookie, markCurrent, removePropertyChangeListener, removeVetoableChangeListener, toString, writeReplace |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int STATUS_NOT
public static final int STATUS_ERROR
public static final int STATUS_PARTIAL
public static final int STATUS_OK
Constructor Detail |
---|
public SourceElement(SourceElement.Impl impl)
impl
- the pluggable implementationMethod Detail |
---|
public int getStatus()
STATUS_NOT
, STATUS_ERROR
, STATUS_PARTIAL
, or STATUS_OK
public Task prepare()
getStatus()
should be STATUS_NOT
, and change
to one of the other three when parsing is complete, according to whether
or not errors were encountered, and their severity.
public void setPackage(Identifier id) throws SourceException
id
- the package name, or null
to use the default package
SourceException
- if the operation cannot proceedpublic Identifier getPackage()
null
if this source file is in the default packagepublic Import[] getImports()
public void setImports(Import[] imprt) throws SourceException
imprt
- the new imports
SourceException
- if the operation cannot proceedpublic void addImport(Import el) throws SourceException
el
- the import to add
SourceException
- if the operation cannot proceedpublic void addImports(Import[] els) throws SourceException
els
- the imports to add
SourceException
- if the operation cannot proceedpublic void removeImport(Import el) throws SourceException
el
- the import to remove
SourceException
- if the operation cannot proceedpublic void removeImports(Import[] els) throws SourceException
els
- the imports to remove
SourceException
- if the operation cannot proceedpublic void addClass(ClassElement el) throws SourceException
el
- the top-level class to add
SourceException
- if impossiblepublic void addClasses(ClassElement[] els) throws SourceException
els
- the top-level classes to add
SourceException
- if impossiblepublic void removeClass(ClassElement el) throws SourceException
el
- the top-level class to remove
SourceException
- if impossiblepublic void removeClasses(ClassElement[] els) throws SourceException
els
- the top-level classes to remove
SourceException
- if impossiblepublic void setClasses(ClassElement[] els) throws SourceException
els
- the new top-level classes
SourceException
- if impossiblepublic ClassElement[] getClasses()
public ClassElement getClass(Identifier name)
name
- the name to look for
null
if it does not existpublic ClassElement[] getAllClasses()
public void print(ElementPrinter printer) throws ElementPrinterInterruptException
Element
printer
- the element printer
ElementPrinterInterruptException
- if the printer canceled the printingpublic void runAtomic(Runnable run)
run
- the action to runpublic void runAtomicAsUser(Runnable run) throws SourceException
run
- the action to run
SourceException
- if a modification of guarded text occured
and that is why no changes to the document has been done.
|
org.openide.src 1.8.22 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |