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 classFile name pattern matcher. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final longMask for schema elements which block name inheritance downward.private static final QName[]Default type replacements applied.private BindingOrganizerDirectory for constructed bindings.private ArrayListDefinitions to be generated (may be global schema definitions, or reused nested components with classes).private final SchemasetCustomCode generation customizations.private final FileRoot directory for schemas.private final URLRoot URL for schemas.private final FileTarget directory for code generation.private final ValidationContextContext for loading and processing schemas.private static final LoggerLogger for class.private static final longMask for schema elements which define a type.private static final longMask 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 voidaddCustomizedSchemas(URL base, File dir, SchemasetCustom custom, InsertionOrderedSet fileset) Add the schemas specified by customizations to the set to be loaded.voidApply extensions and normalize all schemas.booleanValidate and apply customizations to loaded schemas.private SchemasetCustomfindSchemaset(SchemaElement schema, SchemasetCustom custom) Find the most specific schemaset owning a schema.private SchemaElement[]Load and validate the root schema list.static voidRun the schema refactoring using command line parameters.private booleanProcess substitutions and deletions defined by extensions.voidProcesses the schemas to remove unused global definitions.private static booleanReport problems using console output.voidvalidateSchemas(SchemaElement[] schemas) Validate the schemas.private voidwriteSchemas(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,
nullif 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:
trueif successful,falseif 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:
trueif any changes to the schemas,falseif 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:
trueif one or more errors,falseif 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
-