Package org.jibx.custom
Class CustomizationCommandLineBase
java.lang.Object
org.jibx.custom.CustomizationCommandLineBase
- Direct Known Subclasses:
ClassCustomizationBase
,CodeGenCommandLine
,SchemaCommandLineBase
Command line processor for all types of customizable tools. This just provides the basic handling of a customizations
file, target directory, and overrides of values in the customizations root object.
TODO: should extend SchemaCommandLinebase
- Author:
- Dennis M. Sosnoski
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
Wrapper class for command line argument list. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String[]
Ordered array of usage lines for parameters at this level.private List
List of specified classes or files.private File
Target directory for output.private final String[]
Complete array of usage lines.private boolean
Verbose output flag.static final Class[]
Array of method parameter classes for single String parameter.static final Class[]
Array of classes for String and unmarshaller parameters.private static final int
Number of leading characters in usage lines checked for uniqueness. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CustomizationCommandLineBase
(String[] lines) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Map
applyOverrides
(Map overmap) Apply map of override values to customizations read from file or created as default.protected boolean
Check extension parameter.protected void
Finish processing of command line parameters.Get extra arguments from command line.Get generate directory.protected String[]
Get the usage lines describing command line parameters.boolean
Check if verbose output requested.protected abstract boolean
loadCustomizations
(String path) Load the customizations file.protected static String[]
mergeUsageLines
(String[] base, String[] adds) Merge two arrays of strings, returning an ordered array containing all the strings from both provided arrays.abstract void
Print usage information.boolean
processArgs
(String[] args) Process command line arguments array.static boolean
putKeyValue
(String def, Map map) Set a key=value definition in a map.protected void
Print any extension details.
-
Field Details
-
STRING_PARAMETER_ARRAY
Array of method parameter classes for single String parameter. -
STRING_UNMARSHALLER_PARAMETER_ARRAY
Array of classes for String and unmarshaller parameters. -
USAGE_UNIQUE_CHARS
private static final int USAGE_UNIQUE_CHARSNumber of leading characters in usage lines checked for uniqueness.- See Also:
-
COMMON_USAGE_LINES
Ordered array of usage lines for parameters at this level. -
m_usageLines
Complete array of usage lines. -
m_extraArgs
List of specified classes or files. -
m_generateDirectory
Target directory for output. -
m_verbose
private boolean m_verboseVerbose output flag.
-
-
Constructor Details
-
CustomizationCommandLineBase
Constructor. This just merges the usage line defined by subclasses with those at this level, and checks for any duplication (by comparing the first n characters of the lines).- Parameters:
lines
-
-
-
Method Details
-
processArgs
Process command line arguments array.- Parameters:
args
-- Returns:
true
if valid,false
if not- Throws:
JiBXException
IOException
-
getGeneratePath
Get generate directory.- Returns:
- directory
-
getExtraArgs
Get extra arguments from command line. These extra arguments must follow all parameter flags.- Returns:
- args
-
isVerbose
public boolean isVerbose()Check if verbose output requested.- Returns:
- verbose
-
putKeyValue
Set a key=value definition in a map. This is a command line processing assist method that prints an error message directly if the expected format is not found.- Parameters:
def
-map
-- Returns:
true
if successful,false
if error
-
getUsageLines
Get the usage lines describing command line parameters.- Returns:
- lines
-
mergeUsageLines
Merge two arrays of strings, returning an ordered array containing all the strings from both provided arrays.- Parameters:
base
-adds
-- Returns:
- ordered merged
-
checkParameter
Check extension parameter. This method may be overridden by subclasses to process parameters beyond those known to this base class.- Parameters:
alist
- argument list- Returns:
true
if parameter processed,false
if unknown
-
finishParameters
Finish processing of command line parameters. This method may be overridden by subclasses to implement any added processing after all the command line parameters have been handled.- Parameters:
alist
-
-
verboseDetails
protected void verboseDetails()Print any extension details. This method may be overridden by subclasses to print extension parameter values for verbose output. -
loadCustomizations
Load the customizations file. This method must load the specified customizations file, or create a default customizations instance, of the appropriate type.- Parameters:
path
- customization file path,null
if none- Returns:
true
if successful,false
if an error- Throws:
JiBXException
IOException
-
applyOverrides
Apply map of override values to customizations read from file or created as default.- Parameters:
overmap
- override key-value map- Returns:
- map for key/values not recognized
-
printUsage
public abstract void printUsage()Print usage information.
-