Package org.jibx.schema.codegen
Class PackageOrganizer
- java.lang.Object
-
- org.jibx.schema.codegen.PackageOrganizer
-
public class PackageOrganizer extends java.lang.ObjectOrganizer 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
Fields Modifier and Type Field Description private java.lang.String[]m_authorityDiscardsArray of case-insensitive strings to be discarded from start of authority component of URI when converting to package name.private java.io.Filem_generateDirectoryBase directory for code generation.private InsertionOrderedMapm_namePackageMapMap from package name to package information.private java.lang.String[]m_namespaceLeadMatchesLeading URI text to be matched (paired with replacement values).private java.lang.String[]m_namespaceLeadReplacesReplacement text for URI matches (paired with leading URI texts).private java.util.Mapm_namespacePackageMapMap from schema namespace URI to package (empty if unused).private java.lang.Stringm_noNamespacePackagePackage to use for no-namespace schema components.private java.util.Mapm_packageDirectoryMapMap from package to base directory for code generation (empty if unused).private java.util.Mapm_uriPackageMapMap from namespace URI to package information.
-
Constructor Summary
Constructors Constructor Description PackageOrganizer(java.io.File basedir, java.lang.String npkg)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PackageHoldergetPackage(java.lang.String pname)Get package information based on package name.PackageHoldergetPackageForUri(java.lang.String uri)Get the information for a package.java.util.ArrayListgetPackages()Get the defined packages.private inthexValue(char chr)Get value of character as hex digit.private static booleanisAsciiAlpha(char chr)Check if a character is an ASCII alpha character.private static booleanisAsciiAlphaNum(char chr)Check if a character is an ASCII alpha or numeric character.private static booleanisAsciiNum(char chr)Check if a character is an ASCII numeric character.private booleanisHexChar(char chr)Check if a character is a hex digit.voidsetNamespaceLeadReplaces(java.lang.String[] leads, java.lang.String[] repls)Set the namespace lead replacement patterns.voidsetNSPackageMap(java.util.Map map)Set map from namespace URIs to packages.voidsetPackageDirMap(java.util.Map map)Set map from package to base generation directory.java.lang.StringuriToPackage(java.lang.String uri)Convert namespace URI to package name.
-
-
-
Field Detail
-
m_generateDirectory
private final java.io.File m_generateDirectory
Base directory for code generation.
-
m_namespaceLeadMatches
private java.lang.String[] m_namespaceLeadMatches
Leading URI text to be matched (paired with replacement values). These values are matched using case-insensitive comparisons.
-
m_namespaceLeadReplaces
private java.lang.String[] m_namespaceLeadReplaces
Replacement text for URI matches (paired with leading URI texts).
-
m_namespacePackageMap
private java.util.Map m_namespacePackageMap
Map from schema namespace URI to package (empty if unused).
-
m_packageDirectoryMap
private java.util.Map m_packageDirectoryMap
Map from package to base directory for code generation (empty if unused).
-
m_authorityDiscards
private java.lang.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 java.util.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 java.lang.String m_noNamespacePackage
Package to use for no-namespace schema components.
-
-
Method Detail
-
setNamespaceLeadReplaces
public void setNamespaceLeadReplaces(java.lang.String[] leads, java.lang.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(java.util.Map map)
Set map from namespace URIs to packages.- Parameters:
map- String-to-String map
-
setPackageDirMap
public void setPackageDirMap(java.util.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 java.lang.String uriToPackage(java.lang.String uri)
Convert namespace URI to package name.- Parameters:
uri-- Returns:
- package name
-
getPackage
public PackageHolder getPackage(java.lang.String pname)
Get package information based on package name.- Parameters:
pname-- Returns:
- package information
-
getPackageForUri
public PackageHolder getPackageForUri(java.lang.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 java.util.ArrayList getPackages()
Get the defined packages. The returned list is guaranteed to be ordered such that parent packages precede child packages.- Returns:
- packages
-
-