|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jibx.schema.codegen.CodeGen
public class CodeGen
Code generator from schema definition.
Nested Class Summary | |
---|---|
private static class |
CodeGen.SchemaNameFilter
File name pattern matcher. |
private static class |
CodeGen.SchemaNameVisitor
Visitor for checking element namespace usage in schema definitions. |
Field Summary | |
---|---|
private static long |
BLOCK_NAME_INHERIT_MASK
Mask for schema elements which block name inheritance downward. |
private static QName[] |
DEFAULT_REPLACEMENTS
Default type replacements applied. |
private BindingOrganizer |
m_bindingDirectory
Directory for constructed bindings. |
private java.util.ArrayList |
m_definitions
Definitions to be generated (may be global schema definitions, or reused nested components with classes). |
private SchemasetCustom |
m_global
Code generation customizations. |
private PackageOrganizer |
m_packageDirectory
Package directory for generated classes. |
private java.io.File |
m_schemaDir
Root directory for schemas. |
private java.net.URL |
m_schemaRoot
Root URL for schemas. |
private java.io.File |
m_targetDir
Target directory for code generation. |
private ValidationContext |
m_validationContext
Context for loading and processing schemas. |
private static org.apache.log4j.Logger |
s_logger
Logger for class. |
private static long |
TYPE_DEFINE_MASK
Mask for schema elements which define a type. |
private static long |
TYPE_DERIVE_MASK
Mask for schema elements which derive from a type. |
Constructor Summary | |
---|---|
CodeGen(CodeGenCommandLine parms)
Constructor. |
|
CodeGen(SchemasetCustom custom,
ValidationContext vctx)
Constructor used by tests. |
Method Summary | |
---|---|
private static void |
addDefaultSubstitutions(SchemasetCustom custom)
Add default type substitutions to set currently defined. |
void |
applyAndNormalize()
Apply extensions and normalize all schemas. |
private java.lang.String |
assembleName(java.lang.String prefix,
java.lang.String base)
Assemble a name from a base name and an optional prefix. |
private void |
assignNames(java.lang.String prefix,
GroupItem group,
boolean force)
Set the basic names to be used for a structure of items. |
private java.lang.String |
checkDirectName(Item item)
Check if an item has an associated name. |
private void |
checkInline(DefinitionItem definition,
int depth)
Check if a global definition structure is to be inlined. |
private void |
compactGroups(GroupItem group)
Compact group structures. |
private int |
computeComplexity(GroupItem group,
int depth)
Compute the complexity of a structure. |
private void |
convertToDefinitions(GroupItem group)
Convert nested groups which are not inlined to freestanding definitions. |
boolean |
customizeSchemas()
Validate and apply customizations to loaded schemas. |
private java.lang.String |
deriveName(Item item,
boolean force)
Derive the base name for an item. |
private SchemasetCustom |
findSchemaset(SchemaElement schema,
SchemasetCustom custom)
Find the most specific schemaset owning a schema. |
java.lang.String |
generate(boolean verbose)
Generate the data model. |
BindingOrganizer |
getBindingDirectory()
Get the binding directory. |
PackageOrganizer |
getPackageDirectory()
Get the package directory used for code generation. |
private boolean |
isSimple(GroupItem group)
Check if a group consists only of a single non-repeating item, which is not an enumeration. |
private SchemaElement[] |
load(java.util.ArrayList list)
Load and validate the root schema list. |
static void |
main(java.lang.String[] args)
Run the binding generation using command line parameters. |
private boolean |
processExtensions()
Process substitutions and deletions defined by extensions. |
void |
pruneDefinitions()
Processes the schemas to remove unused global definitions. |
private static boolean |
reportProblems(ValidationContext vctx)
Report problems using console output. |
private void |
setName(QName qname,
MappingElementBase mapping)
Set the name and namespace URI for a concrete <mapping> binding component. |
void |
validateSchemas(SchemaElement[] schemas)
Validate the schemas. |
void |
writeBindings(java.lang.String name,
java.lang.String pack)
Write the binding definitions file(s). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final org.apache.log4j.Logger s_logger
private static final QName[] DEFAULT_REPLACEMENTS
private static final long TYPE_DERIVE_MASK
private static final long TYPE_DEFINE_MASK
private static final long BLOCK_NAME_INHERIT_MASK
private final SchemasetCustom m_global
private final java.net.URL m_schemaRoot
private final java.io.File m_schemaDir
private final java.io.File m_targetDir
private final ValidationContext m_validationContext
private PackageOrganizer m_packageDirectory
private java.util.ArrayList m_definitions
private BindingOrganizer m_bindingDirectory
Constructor Detail |
---|
public CodeGen(CodeGenCommandLine parms)
parms
- command line parameterspublic CodeGen(SchemasetCustom custom, ValidationContext vctx)
custom
- vctx
- Method Detail |
---|
private static void addDefaultSubstitutions(SchemasetCustom custom)
custom
- private SchemasetCustom findSchemaset(SchemaElement schema, SchemasetCustom custom)
schema
- custom
- schema set customization
null
if nonepublic void validateSchemas(SchemaElement[] schemas)
schemas
- schemas to be validatedprivate SchemaElement[] load(java.util.ArrayList list) throws JiBXException, java.io.IOException
list
- resolvers for schemas to be loaded
JiBXException
- on unrecoverable error in schemas
java.io.IOException
- on error reading schemaspublic boolean customizeSchemas()
true
if successful, false
if errorprivate boolean processExtensions()
true
if any changes to the schemas, false
if notpublic void applyAndNormalize()
public void pruneDefinitions()
private java.lang.String checkDirectName(Item item)
item
-
null
if noneprivate java.lang.String deriveName(Item item, boolean force)
item
- force
- name forced flag
null
if to use inherited name when force == false
)private void compactGroups(GroupItem group)
group
- private java.lang.String assembleName(java.lang.String prefix, java.lang.String base)
prefix
- base
-
private void assignNames(java.lang.String prefix, GroupItem group, boolean force)
deriveName(Item,boolean)
. This method calls itself recursively to handle nested groups.
prefix
- text to be prefixed to names within inlined group (null
if none)group
- item group to be assignedforce
- force name derivation flagprivate int computeComplexity(GroupItem group, int depth)
checkInline(DefinitionItem, int)
.
group
- depth
- nesting depth
private boolean isSimple(GroupItem group)
group
-
true
if simple group, false
if repeated, multiple, or enumerationprivate void convertToDefinitions(GroupItem group)
group
- private void checkInline(DefinitionItem definition, int depth)
computeComplexity(GroupItem, int)
. The two methods together determine the inlining status of all items.
definition
- depth
- nesting depthprivate void setName(QName qname, MappingElementBase mapping)
StructureClassHolder
equivalent.
qname
- qualified name to be set (null
if none)mapping
- public java.lang.String generate(boolean verbose)
verbose
-
public BindingOrganizer getBindingDirectory()
public void writeBindings(java.lang.String name, java.lang.String pack) throws JiBXException, java.io.IOException
generate(boolean)
is called.
name
- pack
-
JiBXException
java.io.IOException
private static boolean reportProblems(ValidationContext vctx)
vctx
-
true
if one or more errors, false
if notpublic PackageOrganizer getPackageDirectory()
public static void main(java.lang.String[] args) throws java.lang.Exception
args
-
java.lang.Exception
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |