Package org.jibx.schema.codegen
Class Refactory
java.lang.Object
org.jibx.schema.codegen.Refactory
Schema refactoring tool. Although many of the methods in this class use
public
access, they are intended
for use only by the JiBX developers and may change from one release to the next. To make use of this class from your
own code, call the main(String[])
method with an appropriate argument list.- Author:
- Dennis M. Sosnoski
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
File name pattern matcher. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
Mask for schema elements which block name inheritance downward.private static final QName[]
Default type replacements applied.private BindingOrganizer
Directory for constructed bindings.private ArrayList
Definitions to be generated (may be global schema definitions, or reused nested components with classes).private final SchemasetCustom
Code generation customizations.private final File
Root directory for schemas.private final URL
Root URL for schemas.private final File
Target directory for code generation.private final ValidationContext
Context for loading and processing schemas.private static final Logger
Logger for class.private static final long
Mask for schema elements which define a type.private static final long
Mask for schema elements which derive from a type. -
Constructor Summary
ConstructorsConstructorDescriptionRefactory
(SchemasetCustom custom, ValidationContext vctx) Constructor used by tests.Refactory
(RefactoryCommandLine parms) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
addCustomizedSchemas
(URL base, File dir, SchemasetCustom custom, InsertionOrderedSet fileset) Add the schemas specified by customizations to the set to be loaded.void
Apply extensions and normalize all schemas.boolean
Validate and apply customizations to loaded schemas.private SchemasetCustom
findSchemaset
(SchemaElement schema, SchemasetCustom custom) Find the most specific schemaset owning a schema.private SchemaElement[]
Load and validate the root schema list.static void
Run the schema refactoring using command line parameters.private boolean
Process substitutions and deletions defined by extensions.void
Processes the schemas to remove unused global definitions.private static boolean
Report problems using console output.void
validateSchemas
(SchemaElement[] schemas) Validate the schemas.private void
writeSchemas
(File destdir) Write schema definitions to file system.
-
Field Details
-
s_logger
private static final Logger s_loggerLogger for class. -
DEFAULT_REPLACEMENTS
Default type replacements applied. -
TYPE_DERIVE_MASK
private static final long TYPE_DERIVE_MASKMask for schema elements which derive from a type. -
TYPE_DEFINE_MASK
private static final long TYPE_DEFINE_MASKMask for schema elements which define a type. -
BLOCK_NAME_INHERIT_MASK
private static final long BLOCK_NAME_INHERIT_MASKMask for schema elements which block name inheritance downward. -
m_global
Code generation customizations. -
m_schemaRoot
Root URL for schemas. -
m_schemaDir
Root directory for schemas. -
m_targetDir
Target directory for code generation. -
m_validationContext
Context for loading and processing schemas. -
m_definitions
Definitions to be generated (may be global schema definitions, or reused nested components with classes). -
m_bindingDirectory
Directory for constructed bindings.
-
-
Constructor Details
-
Refactory
Constructor.- Parameters:
parms
- command line parameters
-
Refactory
Constructor used by tests. This uses supplied schemas and skips writing to the file system.- Parameters:
custom
-vctx
-
-
-
Method Details
-
findSchemaset
Find the most specific schemaset owning a schema. If multiple matches are found which are not in line of containment the first match is returned and the conflict is reported as an error.- Parameters:
schema
-custom
- schema set customization- Returns:
- owning schemaset,
null
if none
-
validateSchemas
Validate the schemas.- Parameters:
schemas
- schemas to be validated
-
load
Load and validate the root schema list.- Parameters:
list
- resolvers for schemas to be loaded- Returns:
- schemas in validation order
- Throws:
JiBXException
- on unrecoverable error in schemasIOException
- on error reading schemas
-
customizeSchemas
public boolean customizeSchemas()Validate and apply customizations to loaded schemas.- Returns:
true
if successful,false
if error
-
processExtensions
private boolean processExtensions()Process substitutions and deletions defined by extensions. This builds the cross-reference information for the global definition components of the schemas while removing references to deleted components.- Returns:
true
if any changes to the schemas,false
if not
-
applyAndNormalize
public void applyAndNormalize()Apply extensions and normalize all schemas. This may be a multipass process, since applying extensions may create the opportunity for further normalizations and vice versa. -
pruneDefinitions
public void pruneDefinitions()Processes the schemas to remove unused global definitions. -
writeSchemas
Write schema definitions to file system.- Parameters:
destdir
- destination directory- Throws:
JiBXException
- on error in marshallingIOException
- on error writing
-
reportProblems
Report problems using console output. This clears the problem list after they've been reported, to avoid multiple reports of the same problems.- Parameters:
vctx
-- Returns:
true
if one or more errors,false
if not
-
addCustomizedSchemas
private static void addCustomizedSchemas(URL base, File dir, SchemasetCustom custom, InsertionOrderedSet fileset) throws MalformedURLException Add the schemas specified by customizations to the set to be loaded.- Parameters:
base
- root URL for schemasdir
- root directory for schemascustom
- schema set customizationfileset
- set of schema files to be loaded- Throws:
MalformedURLException
-
main
Run the schema refactoring using command line parameters.- Parameters:
args
-- Throws:
Exception
-