Package org.jibx.schema.codegen
Class PackageOrganizer
java.lang.Object
org.jibx.schema.codegen.PackageOrganizer
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 Summary
FieldsModifier and TypeFieldDescriptionprivate String[]
Array of case-insensitive strings to be discarded from start of authority component of URI when converting to package name.private final File
Base directory for code generation.private InsertionOrderedMap
Map from package name to package information.private String[]
Leading URI text to be matched (paired with replacement values).private String[]
Replacement text for URI matches (paired with leading URI texts).private Map
Map from schema namespace URI to package (empty if unused).private String
Package to use for no-namespace schema components.private Map
Map from package to base directory for code generation (empty if unused).private Map
Map from namespace URI to package information. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetPackage
(String pname) Get package information based on package name.getPackageForUri
(String uri) Get the information for a package.Get the defined packages.private int
hexValue
(char chr) Get value of character as hex digit.private static boolean
isAsciiAlpha
(char chr) Check if a character is an ASCII alpha character.private static boolean
isAsciiAlphaNum
(char chr) Check if a character is an ASCII alpha or numeric character.private static boolean
isAsciiNum
(char chr) Check if a character is an ASCII numeric character.private boolean
isHexChar
(char chr) Check if a character is a hex digit.void
setNamespaceLeadReplaces
(String[] leads, String[] repls) Set the namespace lead replacement patterns.void
setNSPackageMap
(Map map) Set map from namespace URIs to packages.void
setPackageDirMap
(Map map) Set map from package to base generation directory.uriToPackage
(String uri) Convert namespace URI to package name.
-
Field Details
-
m_generateDirectory
Base directory for code generation. -
m_namespaceLeadMatches
Leading URI text to be matched (paired with replacement values). These values are matched using case-insensitive comparisons. -
m_namespaceLeadReplaces
Replacement text for URI matches (paired with leading URI texts). -
m_namespacePackageMap
Map from schema namespace URI to package (empty if unused). -
m_packageDirectoryMap
Map from package to base directory for code generation (empty if unused). -
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
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
Map from package name to package information. This is used in combination with the URI-package map. -
m_noNamespacePackage
Package to use for no-namespace schema components.
-
-
Constructor Details
-
PackageOrganizer
Constructor.- Parameters:
basedir
- default base directory for code generationnpkg
- default package for no-namespace schema components
-
-
Method Details
-
setNamespaceLeadReplaces
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
Set map from namespace URIs to packages.- Parameters:
map
- String-to-String map
-
setPackageDirMap
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
Convert namespace URI to package name.- Parameters:
uri
-- Returns:
- package name
-
getPackage
Get package information based on package name.- Parameters:
pname
-- Returns:
- package information
-
getPackageForUri
Get the information for a package.- Parameters:
uri
- corresponding namespace URI (non-null
, empty string for no namespace)- Returns:
- package information
-
getPackages
Get the defined packages. The returned list is guaranteed to be ordered such that parent packages precede child packages.- Returns:
- packages
-