Package org.jibx.schema.codegen
Class SourceBuilder
java.lang.Object
org.jibx.schema.codegen.SourceBuilder
Abstract syntax tree builder. This wraps the AST with convenience methods and added control information.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Visitor to apply edits. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AST
Actual AST instance.private ArrayList
Builders for main classes in file.private final CompilationUnit
Compilation unit.protected final ImportsTracker
Tracker for imports.private final String
Name of this source.private final PackageHolder
Package containing this source.private static final Logger
Logger for class.private static final Map
Map from primitive type name to type code. -
Constructor Summary
ConstructorsConstructorDescriptionSourceBuilder
(AST ast, PackageHolder pack, String name, ImportsTracker imports) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate AbstractTypeDeclaration
createClass
(String cname, boolean isenum) Create a type declaration.Type
createParameterizedType
(String type, String param) Create a parameterized type.Type
createType
(String type) Create type definition.protected Name
createTypeName
(String type) Create type name.void
finish
(boolean verbose) Generate the actual source file.(package private) AST
getAST()
AST access for related classes.Get the name of the package containing this source file.newInnerClass
(String cname, ClassBuilder outer, boolean isenum) Add a new inner class to the file.newMainClass
(String cname, boolean isenum) Add a new main class to the file.
-
Field Details
-
s_logger
private static final Logger s_loggerLogger for class. -
s_primitiveTypeCodes
Map from primitive type name to type code. -
m_ast
private final AST m_astActual AST instance. -
m_package
Package containing this source. -
m_name
Name of this source. -
m_compilationUnit
private final CompilationUnit m_compilationUnitCompilation unit. -
m_importsTracker
Tracker for imports. -
m_classes
Builders for main classes in file.
-
-
Constructor Details
-
SourceBuilder
Constructor.- Parameters:
ast
-pack
-name
-imports
-
-
-
Method Details
-
getAST
AST getAST()AST access for related classes.- Returns:
- AST
-
getPackageName
Get the name of the package containing this source file.- Returns:
- name
-
createClass
Create a type declaration.- Parameters:
cname
- class nameisenum
- Java 5 enum class flag- Returns:
- type declaration
-
newMainClass
Add a new main class to the file.- Parameters:
cname
- class nameisenum
- Java 5 enum class flag- Returns:
- builder
-
newInnerClass
Add a new inner class to the file.- Parameters:
cname
- class nameouter
- containing class builderisenum
- Java 5 enum class flag- Returns:
- builder
-
createTypeName
Create type name.- Parameters:
type
- fully-qualified type name- Returns:
- name
-
createType
Create type definition. This uses the supplied type name, which may include array suffixes and/or type parameters, to construct the actual type definition.- Parameters:
type
- fully qualified type name, or primitive type name- Returns:
- constructed typed definition
-
createParameterizedType
Create a parameterized type.- Parameters:
type
- fully qualified type nameparam
- fully qualified parameter type name- Returns:
- type
-
finish
public void finish(boolean verbose) Generate the actual source file.- Parameters:
verbose
-
-