Class PackageOrganizer

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

public class PackageOrganizer extends Object
Organizer for package information. This handles the conversions from namespace URIs to package names, and organizes the packages in a tree structure.
Author:
Dennis M. Sosnoski
  • Field Details

    • m_generateDirectory

      private final File m_generateDirectory
      Base directory for code generation.
    • m_namespaceLeadMatches

      private String[] m_namespaceLeadMatches
      Leading URI text to be matched (paired with replacement values). These values are matched using case-insensitive comparisons.
    • m_namespaceLeadReplaces

      private String[] m_namespaceLeadReplaces
      Replacement text for URI matches (paired with leading URI texts).
    • m_namespacePackageMap

      private Map m_namespacePackageMap
      Map from schema namespace URI to package (empty if unused).
    • m_packageDirectoryMap

      private Map m_packageDirectoryMap
      Map from package to base directory for code generation (empty if unused).
    • m_authorityDiscards

      private String[] m_authorityDiscards
      Array of case-insensitive strings to be discarded from start of authority component of URI when converting to package name. The default is the string "www."
    • m_uriPackageMap

      private Map m_uriPackageMap
      Map from namespace URI to package information. This is used in combination with the name-package map, since multiple URIs may be converted to the same package name.
    • m_namePackageMap

      private InsertionOrderedMap m_namePackageMap
      Map from package name to package information. This is used in combination with the URI-package map.
    • m_noNamespacePackage

      private String m_noNamespacePackage
      Package to use for no-namespace schema components.
  • Constructor Details

    • PackageOrganizer

      public PackageOrganizer(File basedir, String npkg)
      Constructor.
      Parameters:
      basedir - default base directory for code generation
      npkg - default package for no-namespace schema components
  • Method Details

    • setNamespaceLeadReplaces

      public void setNamespaceLeadReplaces(String[] leads, String[] repls)
      Set the namespace lead replacement patterns. This consists of lead texts to be matches and paired replacement texts. When a particular lead text is found in a URI the replacement text is substituted.
      Parameters:
      leads -
      repls -
    • setNSPackageMap

      public void setNSPackageMap(Map map)
      Set map from namespace URIs to packages.
      Parameters:
      map - String-to-String map
    • setPackageDirMap

      public void setPackageDirMap(Map map)
      Set map from package to base generation directory. If this is unset all packages are generated under the default base directory, as are any packages not covered by this map. All subpackages of a package go under the parent package unless otherwise specified by this map.
      Parameters:
      map - String-to-File map
    • isHexChar

      private boolean isHexChar(char chr)
      Check if a character is a hex digit.
      Parameters:
      chr -
      Returns:
      hex digit flag
    • hexValue

      private int hexValue(char chr)
      Get value of character as hex digit.
      Parameters:
      chr -
      Returns:
      hex digit value
    • isAsciiAlpha

      private static boolean isAsciiAlpha(char chr)
      Check if a character is an ASCII alpha character.
      Parameters:
      chr -
      Returns:
      alpha character flag
    • isAsciiNum

      private static boolean isAsciiNum(char chr)
      Check if a character is an ASCII numeric character.
      Parameters:
      chr -
      Returns:
      numeric character flag
    • isAsciiAlphaNum

      private static boolean isAsciiAlphaNum(char chr)
      Check if a character is an ASCII alpha or numeric character.
      Parameters:
      chr -
      Returns:
      alpha or numeric character flag
    • uriToPackage

      public String uriToPackage(String uri)
      Convert namespace URI to package name.
      Parameters:
      uri -
      Returns:
      package name
    • getPackage

      public PackageHolder getPackage(String pname)
      Get package information based on package name.
      Parameters:
      pname -
      Returns:
      package information
    • getPackageForUri

      public PackageHolder getPackageForUri(String uri)
      Get the information for a package.
      Parameters:
      uri - corresponding namespace URI (non-null, empty string for no namespace)
      Returns:
      package information
    • getPackages

      public ArrayList getPackages()
      Get the defined packages. The returned list is guaranteed to be ordered such that parent packages precede child packages.
      Returns:
      packages