public abstract class ClassHolder extends TypeData implements IClassHolder
Modifier and Type | Class and Description |
---|---|
protected static class |
ClassHolder.DataNode
Information for a data structure component of a class definition.
|
protected static class |
ClassHolder.LeafNode
Information for a leaf node of the data structure tree.
|
protected static class |
ClassHolder.ParentNode
Information for an interior node of the data structure tree.
|
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
COLLECTION_VARIABLE_NAME |
protected static java.lang.String |
COLLECTION_VARIABLE_TYPE |
protected java.lang.String |
m_baseName
Base class name (for use when generating separate classes for nested structures).
|
private ClassBuilder |
m_classBuilder
Builder for class.
|
protected ClassDecorator[] |
m_decorators
Decorators to be called in order during class code generation.
|
private boolean |
m_generated
Class generated flag.
|
protected BindingHolder |
m_holder
Holder for class binding definition.
|
protected ImportsTracker |
m_importsTracker
Tracker for imports.
|
protected LazyList |
m_inners
Holders for inner classes defined within this class (
null if an inner class). |
protected java.lang.String |
m_listImplClass
Class used for initializing list instances.
|
private java.lang.String |
m_name
Simple class name.
|
protected NameConverter |
m_nameConverter
Name conversion handler.
|
protected UniqueNameSet |
m_nameSet
Value names used in class.
|
protected ClassHolder |
m_outerClass
Containing class (
null if not an inner class). |
protected PackageHolder |
m_package
Package containing class.
|
private SchemaCustom |
m_schemaCustom
Customizations for the schema containing the schema component matching this class.
|
private TypeData |
m_superClass
Superclass to be extended as part of schema model (
null if none). |
private java.lang.String |
m_superName
Superclass name to be extended if extension not required by model (
null if none). |
protected boolean |
m_useInnerClasses
Use inner classes for substructures flag.
|
private static SchemaDocumentationGenerator |
s_generator
Schema documentation generator.
|
private static org.apache.log4j.Logger |
s_logger
Logger for class.
|
private static javax.xml.transform.Transformer |
s_transformer
Null transformer used to output text form of documentation.
|
Modifier | Constructor and Description |
---|---|
protected |
ClassHolder(java.lang.String name,
ClassHolder context,
boolean simple)
Constructor for creating a child inner class definition.
|
|
ClassHolder(java.lang.String name,
java.lang.String base,
PackageHolder pack,
BindingHolder holder,
NameConverter nconv,
ClassDecorator[] decorators,
boolean inner,
boolean simple)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addField(org.eclipse.jdt.core.dom.FieldDeclaration field)
Add separately-constructed field to this class definition.
|
boolean |
addImport(java.lang.String fqname)
Add import for class.
|
void |
addInterface(java.lang.String interf)
Add an interface to this class definition.
|
void |
addMethod(org.eclipse.jdt.core.dom.MethodDeclaration method)
Add separately-constructed method declaration to this class definition.
|
void |
addType(org.eclipse.jdt.core.dom.TypeDeclaration type)
Add separately-constructed inner class declaration to this class definition.
|
void |
buildDataStructure(GroupItem group,
BindingHolder bindhold)
Convert an item structure to a class representation.
|
private static java.lang.String |
buildName(java.lang.String name,
PackageHolder pack)
Build fully-qualified class name
|
protected static java.lang.String |
describe(ClassHolder.DataNode node)
Describe the schema component associated with a node.
|
protected java.lang.String |
extractDocumentation(AnnotatedBase element)
Extract schema documentation from an element.
|
protected void |
finishClass(ElementBase binding)
Finish class construction.
|
abstract void |
generate(boolean verbose,
SourceBuilder builder)
Generate this class.
|
protected void |
generateInner(boolean verbose,
SourceBuilder builder)
Generate any inner classes of this class.
|
protected ClassBuilder |
getBuilder()
Get the builder for this class.
|
org.eclipse.jdt.core.dom.FieldDeclaration[] |
getFields()
Get the fields defined in this class.
|
ImportsTracker |
getImports()
Get imports information.
|
java.lang.String[] |
getInterfaces()
Get the interfaces implemented by this class.
|
org.eclipse.jdt.core.dom.MethodDeclaration[] |
getMethods()
Get the methods defined in this class.
|
java.lang.String |
getName()
Get simple name.
|
IClassHolder |
getOuterClass()
Get containing class of inner class.
|
PackageHolder |
getPackage()
Get containing package.
|
SchemaCustom |
getSchemaCustom()
Get the schema customization associated with root schema component matching this class.
|
StringPair[] |
getSortedFields()
Get a sorted array of the field names and types defined in this class.
|
TypeData |
getSuperClass()
Get base class to be extended.
|
java.lang.String |
getSuperClassName()
Get name of base class to be extended.
|
java.lang.String |
getTypeName(java.lang.String type)
Get the name to be used for a type.
|
protected void |
importValueType(ClassHolder.DataNode value)
Import the type associated with an item, if not directly accessible
|
protected void |
initClass(boolean verbose,
ClassBuilder builder,
ClassHolder.ParentNode root)
Initialize the class construction.
|
boolean |
isGenerated()
Check if the class has been generated.
|
boolean |
isSuperClassForced()
Check if superclass is forced by schema model.
|
void |
setListImplementation(java.lang.String list)
Set name of list implementation class to be used for initializing instances.
|
void |
setSuperClass(TypeData sclas)
Set superclass to be extended.
|
void |
setSuperClassName(java.lang.String base)
Set name of base class to be extended.
|
getBindingName, getFullName, isPregenerated, isSimpleValue
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getFullName
protected static final java.lang.String COLLECTION_VARIABLE_TYPE
protected static final java.lang.String COLLECTION_VARIABLE_NAME
private static final org.apache.log4j.Logger s_logger
private static final SchemaDocumentationGenerator s_generator
private static final javax.xml.transform.Transformer s_transformer
private final java.lang.String m_name
private TypeData m_superClass
null
if none).private java.lang.String m_superName
null
if none).private boolean m_generated
private ClassBuilder m_classBuilder
private SchemaCustom m_schemaCustom
protected final PackageHolder m_package
protected final BindingHolder m_holder
protected final NameConverter m_nameConverter
protected final java.lang.String m_baseName
protected final ClassDecorator[] m_decorators
protected final boolean m_useInnerClasses
protected final LazyList m_inners
null
if an inner class).protected final ClassHolder m_outerClass
null
if not an inner class).protected final ImportsTracker m_importsTracker
protected java.lang.String m_listImplClass
protected UniqueNameSet m_nameSet
public ClassHolder(java.lang.String name, java.lang.String base, PackageHolder pack, BindingHolder holder, NameConverter nconv, ClassDecorator[] decorators, boolean inner, boolean simple)
name
- class namebase
- base class namepack
- package informationholder
- binding holdernconv
- name converterdecorators
- class decoratorsinner
- use inner classes for substructuressimple
- simple value flagprotected ClassHolder(java.lang.String name, ClassHolder context, boolean simple)
name
- class namecontext
- parent classsimple
- simple value flagprivate static java.lang.String buildName(java.lang.String name, PackageHolder pack)
name
- simple class namepack
- package informationpublic SchemaCustom getSchemaCustom()
protected java.lang.String extractDocumentation(AnnotatedBase element)
element
- null
if noneprotected static java.lang.String describe(ClassHolder.DataNode node)
node
- protected void importValueType(ClassHolder.DataNode value)
value
- public void buildDataStructure(GroupItem group, BindingHolder bindhold)
group
- item groupbindhold
- associated binding definition holderpublic PackageHolder getPackage()
public java.lang.String getName()
getName
in interface IClassHolder
public IClassHolder getOuterClass()
getOuterClass
in interface IClassHolder
null
if not an inner classpublic TypeData getSuperClass()
null
if none)public void setSuperClass(TypeData sclas)
sclas
- (null
if none)public boolean isSuperClassForced()
isSuperClassForced
in interface IClassHolder
true
if superclass forced, false
if notpublic java.lang.String getSuperClassName()
getSuperClassName
in interface IClassHolder
null
if none)public void setSuperClassName(java.lang.String base)
getSuperClassName()
returns null
.setSuperClassName
in interface IClassHolder
base
- fully-qualified class name of base class (null
if none)public void setListImplementation(java.lang.String list)
setListImplementation
in interface IClassHolder
list
- fully-qualified class name of list implementation (non-null
)public boolean isGenerated()
generate(boolean, SourceBuilder)
, in order to prevent multiple generation passes over the same class.true
if generated, false
if notprotected ClassBuilder getBuilder()
public java.lang.String[] getInterfaces()
getInterfaces
in interface IClassHolder
public ImportsTracker getImports()
public org.eclipse.jdt.core.dom.FieldDeclaration[] getFields()
getFields
in interface IClassHolder
public org.eclipse.jdt.core.dom.MethodDeclaration[] getMethods()
getMethods
in interface IClassHolder
public boolean addImport(java.lang.String fqname)
addImport
in interface IClassHolder
fqname
- fully qualified class nametrue
if added as importpublic java.lang.String getTypeName(java.lang.String type)
getTypeName
in interface IClassHolder
type
- fully qualified class namepublic void addInterface(java.lang.String interf)
addInterface
in interface IClassHolder
interf
- interface typepublic void addField(org.eclipse.jdt.core.dom.FieldDeclaration field)
addField
in interface IClassHolder
field
- public void addMethod(org.eclipse.jdt.core.dom.MethodDeclaration method)
addMethod
in interface IClassHolder
method
- public void addType(org.eclipse.jdt.core.dom.TypeDeclaration type)
addType
in interface IClassHolder
type
- public StringPair[] getSortedFields()
protected void initClass(boolean verbose, ClassBuilder builder, ClassHolder.ParentNode root)
verbose
- builder
- root
- data structure tree root nodeprotected void finishClass(ElementBase binding)
binding
- binding definition component for this classprotected void generateInner(boolean verbose, SourceBuilder builder)
verbose
- builder
- class source file builderpublic abstract void generate(boolean verbose, SourceBuilder builder)
initClass(boolean, ClassBuilder, ParentNode)
before doing their own code generation.verbose
- builder
- class source file builder