Class Refactory

java.lang.Object
org.jibx.schema.codegen.Refactory

public class Refactory extends Object
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
  • Field Details

    • s_logger

      private static final Logger s_logger
      Logger for class.
    • DEFAULT_REPLACEMENTS

      private static final QName[] DEFAULT_REPLACEMENTS
      Default type replacements applied.
    • TYPE_DERIVE_MASK

      private static final long TYPE_DERIVE_MASK
      Mask for schema elements which derive from a type.
    • TYPE_DEFINE_MASK

      private static final long TYPE_DEFINE_MASK
      Mask for schema elements which define a type.
    • BLOCK_NAME_INHERIT_MASK

      private static final long BLOCK_NAME_INHERIT_MASK
      Mask for schema elements which block name inheritance downward.
    • m_global

      private final SchemasetCustom m_global
      Code generation customizations.
    • m_schemaRoot

      private final URL m_schemaRoot
      Root URL for schemas.
    • m_schemaDir

      private final File m_schemaDir
      Root directory for schemas.
    • m_targetDir

      private final File m_targetDir
      Target directory for code generation.
    • m_validationContext

      private final ValidationContext m_validationContext
      Context for loading and processing schemas.
    • m_definitions

      private ArrayList m_definitions
      Definitions to be generated (may be global schema definitions, or reused nested components with classes).
    • m_bindingDirectory

      private BindingOrganizer m_bindingDirectory
      Directory for constructed bindings.
  • Constructor Details

    • Refactory

      public Refactory(RefactoryCommandLine parms)
      Constructor.
      Parameters:
      parms - command line parameters
    • Refactory

      public Refactory(SchemasetCustom custom, ValidationContext vctx)
      Constructor used by tests. This uses supplied schemas and skips writing to the file system.
      Parameters:
      custom -
      vctx -
  • Method Details

    • findSchemaset

      private SchemasetCustom findSchemaset(SchemaElement schema, SchemasetCustom custom)
      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

      public void validateSchemas(SchemaElement[] schemas)
      Validate the schemas.
      Parameters:
      schemas - schemas to be validated
    • load

      private SchemaElement[] load(List list) throws JiBXException, IOException
      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 schemas
      IOException - 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

      private void writeSchemas(File destdir) throws JiBXException, IOException
      Write schema definitions to file system.
      Parameters:
      destdir - destination directory
      Throws:
      JiBXException - on error in marshalling
      IOException - on error writing
    • reportProblems

      private static boolean reportProblems(ValidationContext vctx)
      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 schemas
      dir - root directory for schemas
      custom - schema set customization
      fileset - set of schema files to be loaded
      Throws:
      MalformedURLException
    • main

      public static void main(String[] args) throws Exception
      Run the schema refactoring using command line parameters.
      Parameters:
      args -
      Throws:
      Exception