Interface IDOMFactory
-
- All Known Implementing Classes:
DOMFactory
public interface IDOMFactory
Deprecated.The JDOM was made obsolete by the addition in 2.0 of the more powerful, fine-grained DOM/AST API found in the org.eclipse.jdt.core.dom package.A factory used to create document fragment (DF) nodes. AnIDOMCompilationUnit
represents the root of a complete JDOM (that is, a source file with one of theJava-like extensions
). 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 individualcreate
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 returnsnull
.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.
- See Also:
IDOMNode
- Restriction:
- This interface is not intended to be implemented by clients.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description IDOMType
createClass()
Deprecated.Creates a default type document fragment.IDOMCompilationUnit
createCompilationUnit()
Deprecated.Creates and return an empty JDOM.IDOMCompilationUnit
createCompilationUnit(char[] sourceCode, String name)
Deprecated.Creates a JDOM on the given source code.IDOMCompilationUnit
createCompilationUnit(String sourceCode, String name)
Deprecated.Creates a JDOM on the given source code.IDOMField
createField()
Deprecated.Creates a default field document fragment.IDOMField
createField(String sourceCode)
Deprecated.Creates a field document fragment on the given source code.IDOMImport
createImport()
Deprecated.Creates an empty import document fragment.IDOMImport
createImport(String sourceCode)
Deprecated.Creates an import document fragment on the given source code.IDOMInitializer
createInitializer()
Deprecated.Creates an empty initializer document fragment.IDOMInitializer
createInitializer(String sourceCode)
Deprecated.Creates an initializer document fragment from the given source code.IDOMType
createInterface()
Deprecated.Creates a default type document fragment.IDOMMethod
createMethod()
Deprecated.Creates a default method document fragment.IDOMMethod
createMethod(String sourceCode)
Deprecated.Creates a method document fragment on the given source code.IDOMPackage
createPackage()
Deprecated.Creates an empty package document fragment.IDOMPackage
createPackage(String sourceCode)
Deprecated.Creates a package document fragment on the given source code.IDOMType
createType()
Deprecated.Creates a default type document fragment.IDOMType
createType(String sourceCode)
Deprecated.Creates a type document fragment on the given source code.
-
-
-
Method Detail
-
createCompilationUnit
IDOMCompilationUnit createCompilationUnit()
Deprecated.Creates and return an empty JDOM. The initial content is an empty string.- Returns:
- the new compilation unit
-
createCompilationUnit
IDOMCompilationUnit createCompilationUnit(char[] sourceCode, String name)
Deprecated.Creates a JDOM on the given source code. The syntax for the given source code corresponds to CompilationUnit (JLS2 7.3).- Parameters:
sourceCode
- the source code character array, ornull
name
- the name of the compilation unit- Returns:
- the new compilation unit, or
null
if unable to recognize the source code, or if the source code isnull
-
createCompilationUnit
IDOMCompilationUnit createCompilationUnit(String sourceCode, String name)
Deprecated.Creates a JDOM on the given source code. The syntax for the given source code corresponds to CompilationUnit (JLS2 7.3).- Parameters:
sourceCode
- the source code string, ornull
name
- the name of the compilation unit- Returns:
- the new compilation unit, or
null
if unable to recognize the source code, or if the source code isnull
-
createField
IDOMField createField()
Deprecated.Creates a default field document fragment. Initially the field will have default protection, type"Object"
, name"aField"
, no comment, and no initializer.- Returns:
- the new field
-
createField
IDOMField createField(String sourceCode)
Deprecated.Creates a field document fragment on the given source code. The given source string corresponds to FieldDeclaration (JLS2 8.3) and ConstantDeclaration (JLS2 9.3) restricted to a single VariableDeclarator clause.- Parameters:
sourceCode
- the source code- Returns:
- the new field, or
null
if unable to recognize the source code, if the source code isnull
, or when the source contains more than one VariableDeclarator clause
-
createImport
IDOMImport createImport()
Deprecated.Creates an empty import document fragment. Initially the import will have name"java.lang.*"
and be non-static.- Returns:
- the new import
-
createImport
IDOMImport createImport(String sourceCode)
Deprecated.Creates an import document fragment on the given source code. The syntax for the given source string corresponds to ImportDeclaration (JLS2 7.5).- Parameters:
sourceCode
- the source code- Returns:
- the new import, or
null
if unable to recognize the source code, or if the source code isnull
-
createInitializer
IDOMInitializer createInitializer()
Deprecated.Creates an empty initializer document fragment. Initially the initializer will be static and have no body or comment.- Returns:
- the new initializer
-
createInitializer
IDOMInitializer createInitializer(String sourceCode)
Deprecated.Creates an initializer document fragment from the given source code. The syntax for the given source string corresponds to InstanceInitializer (JLS2 8.6) and StaticDeclaration (JLS2 8.7).- Parameters:
sourceCode
- the source code- Returns:
- the new initializer, or
null
if unable to recognize the source code, or if the source code isnull
-
createMethod
IDOMMethod createMethod()
Deprecated.Creates a default method document fragment. Initially the method will have public visibility, return type"void"
, be named"newMethod"
, have no parameters, no comment, and an empty body.- Returns:
- the new method
-
createMethod
IDOMMethod createMethod(String sourceCode)
Deprecated.Creates a method document fragment on the given source code. The syntax for the given source string corresponds to MethodDeclaration (JLS2 8.4), ConstructorDeclaration (JLS2 8.8), and AbstractMethodDeclaration (JLS2 9.4).- Parameters:
sourceCode
- the source code- Returns:
- the new method, or
null
if unable to recognize the source code, or if the source code isnull
-
createPackage
IDOMPackage createPackage()
Deprecated.Creates an empty package document fragment. Initially the package declaration will have no name.- Returns:
- the new package
-
createPackage
IDOMPackage createPackage(String sourceCode)
Deprecated.Creates a package document fragment on the given source code. The syntax for the given source string corresponds to PackageDeclaration (JLS2 7.4).- Parameters:
sourceCode
- the source code- Returns:
- the new package, or
null
if unable to recognize the source code, or if the source code isnull
-
createType
IDOMType createType()
Deprecated.Creates a default type document fragment. Initially the type will be a public class named"AClass"
, with no members or comment.- Returns:
- the new type
-
createClass
IDOMType createClass()
Deprecated.Creates a default type document fragment. Initially the type will be a public class named"AClass"
, with no members or comment.- Returns:
- the new class
- Since:
- 2.0
-
createInterface
IDOMType createInterface()
Deprecated.Creates a default type document fragment. Initially the type will be a public interface named"AnInterface"
, with no members or comment.- Returns:
- the new interface
- Since:
- 2.0
-
createType
IDOMType createType(String sourceCode)
Deprecated.Creates a type document fragment on the given source code. The syntax for the given source string corresponds to ClassDeclaration (JLS2 8.1) and InterfaceDeclaration (JLS2 9.1).- Parameters:
sourceCode
- the source code- Returns:
- the new type, or
null
if unable to recognize the source code, or if the source code isnull
-
-