|
Eclipse JDT 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A factory used to create document fragment (DF) nodes. An
IDOMCompilationUnit
represents the root of a complete JDOM (that
is, a ".java" file). Other node types represent fragments of a compilation
unit.
The factory can be used to create empty DFs or it can create DFs from source
strings. All DFs created empty are assigned default values as required, such
that a call to IDOMNode.getContents
will generate a valid source
string. See individual create
methods for details on the default
values supplied. The factory does its best to recognize Java structures in
the source provided. If the factory is completely unable to recognize source
constructs, the factory method returns null
.
Even if a DF is created successfully from source code, it does not guarantee that the source code will compile error free. Similarly, the contents of a DF are not guaranteed to compile error free. However, syntactically correct source code is guaranteed to be recognized and successfully generate a DF. Similarly, if all of the fragments of a JDOM are syntactically correct, the contents of the entire document will be correct too.
The factory does not perform or provide any code formatting. Document fragments created on source strings must be pre-formatted. The JDOM attempts to maintain the formatting of documents as best as possible. For this reason, document fragments created for nodes that are to be strung together should end with a new-line character. Failing to do so will result in a document that has elements strung together on the same line. This is especially important if a source string ends with a // comment. In this case, it would be syntactically incorrect to omit the new line character.
This interface is not intended to be implemented by clients.
IDOMNode
Method Summary | |
IDOMType |
createClass()
Creates a default type document fragment. |
IDOMCompilationUnit |
createCompilationUnit()
Creates and return an empty JDOM. |
IDOMCompilationUnit |
createCompilationUnit(char[] sourceCode,
String name)
Creates a JDOM on the given source code. |
IDOMCompilationUnit |
createCompilationUnit(String sourceCode,
String name)
Creates a JDOM on the given source code. |
IDOMField |
createField()
Creates a default field document fragment. |
IDOMField |
createField(String sourceCode)
Creates a field document fragment on the given source code. |
IDOMImport |
createImport()
Creates an empty import document fragment. |
IDOMImport |
createImport(String sourceCode)
Creates an import document fragment on the given source code. |
IDOMInitializer |
createInitializer()
Creates an empty initializer document fragment. |
IDOMInitializer |
createInitializer(String sourceCode)
Creates an initializer document fragment from the given source code. |
IDOMType |
createInterface()
Creates a default type document fragment. |
IDOMMethod |
createMethod()
Creates a default method document fragment. |
IDOMMethod |
createMethod(String sourceCode)
Creates a method document fragment on the given source code. |
IDOMPackage |
createPackage()
Creates an empty package document fragment. |
IDOMPackage |
createPackage(String sourceCode)
Creates a package document fragment on the given source code. |
IDOMType |
createType()
Creates a default type document fragment. |
IDOMType |
createType(String sourceCode)
Creates a type document fragment on the given source code. |
Method Detail |
public IDOMCompilationUnit createCompilationUnit()
public IDOMCompilationUnit createCompilationUnit(char[] sourceCode, String name)
sourceCode
- the source code character array, or null
name
- the name of the compilation unit
null
if unable to recognize
the source code, or if the source code is null
public IDOMCompilationUnit createCompilationUnit(String sourceCode, String name)
sourceCode
- the source code string, or null
name
- the name of the compilation unit
null
if unable to recognize
the source code, or if the source code is null
public IDOMField createField()
"Object"
, name "aField"
,
no comment, and no initializer.
public IDOMField createField(String sourceCode)
sourceCode
- the source code
null
if unable to recognize
the source code, if the source code is null
, or when the source
contains more than one VariableDeclarator clausepublic IDOMImport createImport()
"java.lang.*"
.
public IDOMImport createImport(String sourceCode)
sourceCode
- the source code
null
if unable to recognize
the source code, or if the source code is null
public IDOMInitializer createInitializer()
public IDOMInitializer createInitializer(String sourceCode)
sourceCode
- the source code
null
if unable to recognize
the source code, or if the source code is null
public IDOMMethod createMethod()
"void"
, be named
"newMethod"
, have no parameters, no comment, and an empty body.
public IDOMMethod createMethod(String sourceCode)
sourceCode
- the source code
null
if unable to recognize
the source code, or if the source code is null
public IDOMPackage createPackage()
public IDOMPackage createPackage(String sourceCode)
sourceCode
- the source code
null
if unable to recognize
the source code, or if the source code is null
public IDOMType createType()
"AClass"
, with no members or comment.
public IDOMType createClass()
"AClass"
, with no members or comment.
public IDOMType createInterface()
"AnInterface"
, with no members or comment.
public IDOMType createType(String sourceCode)
sourceCode
- the source code
null
if unable to recognize
the source code, or if the source code is null
|
Eclipse JDT 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |