public final class ConfigurationLoader extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ConfigurationLoader.IgnoredModulesOptions
Enum to specify behaviour regarding ignored modules.
|
private class |
ConfigurationLoader.InternalLoader
Implements the SAX document handler interfaces, so they do not
appear in the public API of the ConfigurationLoader.
|
| Modifier and Type | Field and Description |
|---|---|
private java.util.Deque<DefaultConfiguration> |
configStack
The loaded configurations.
|
private Configuration |
configuration
The Configuration that is being built.
|
private static char |
DOLLAR_SIGN
Dollar sign literal.
|
private static java.lang.String |
DTD_CONFIGURATION_NAME_1_0
The resource for version 1_0 of the configuration dtd.
|
private static java.lang.String |
DTD_CONFIGURATION_NAME_1_1
The resource for version 1_1 of the configuration dtd.
|
private static java.lang.String |
DTD_CONFIGURATION_NAME_1_2
The resource for version 1_2 of the configuration dtd.
|
private static java.lang.String |
DTD_CONFIGURATION_NAME_1_3
The resource for version 1_3 of the configuration dtd.
|
private static java.lang.String |
DTD_PUBLIC_CS_ID_1_0
The new public ID for version 1_0 of the configuration dtd.
|
private static java.lang.String |
DTD_PUBLIC_CS_ID_1_1
The new public ID for version 1_1 of the configuration dtd.
|
private static java.lang.String |
DTD_PUBLIC_CS_ID_1_2
The new public ID for version 1_2 of the configuration dtd.
|
private static java.lang.String |
DTD_PUBLIC_CS_ID_1_3
The new public ID for version 1_3 of the configuration dtd.
|
private static java.lang.String |
DTD_PUBLIC_ID_1_0
The public ID for version 1_0 of the configuration dtd.
|
private static java.lang.String |
DTD_PUBLIC_ID_1_1
The public ID for version 1_1 of the configuration dtd.
|
private static java.lang.String |
DTD_PUBLIC_ID_1_2
The public ID for version 1_2 of the configuration dtd.
|
private static java.lang.String |
DTD_PUBLIC_ID_1_3
The public ID for version 1_3 of the configuration dtd.
|
private boolean |
omitIgnoredModules
Flags if modules with the severity 'ignore' should be omitted.
|
private PropertyResolver |
overridePropsResolver
Property resolver.
|
private static java.lang.String |
SAX_PARSE_EXCEPTION_FORMAT
Format of message for sax parse exception.
|
private ConfigurationLoader.InternalLoader |
saxHandler
The SAX document handler.
|
private ThreadModeSettings |
threadModeSettings
The thread mode configuration.
|
private static java.lang.String |
UNABLE_TO_PARSE_EXCEPTION_PREFIX
Prefix for the exception when unable to parse resource.
|
| Modifier | Constructor and Description |
|---|---|
private |
ConfigurationLoader(PropertyResolver overrideProps,
boolean omitIgnoredModules,
ThreadModeSettings threadModeSettings)
Creates a new
ConfigurationLoader instance. |
| Modifier and Type | Method and Description |
|---|---|
private static java.util.Map<java.lang.String,java.lang.String> |
createIdToResourceNameMap()
Creates mapping between local resources and dtd ids.
|
static Configuration |
loadConfiguration(org.xml.sax.InputSource configSource,
PropertyResolver overridePropsResolver,
ConfigurationLoader.IgnoredModulesOptions ignoredModulesOptions)
Returns the module configurations from a specified input source.
|
static Configuration |
loadConfiguration(org.xml.sax.InputSource configSource,
PropertyResolver overridePropsResolver,
ConfigurationLoader.IgnoredModulesOptions ignoredModulesOptions,
ThreadModeSettings threadModeSettings)
Returns the module configurations from a specified input source.
|
static Configuration |
loadConfiguration(java.lang.String config,
PropertyResolver overridePropsResolver)
Returns the module configurations in a specified file.
|
static Configuration |
loadConfiguration(java.lang.String config,
PropertyResolver overridePropsResolver,
ConfigurationLoader.IgnoredModulesOptions ignoredModulesOptions)
Returns the module configurations in a specified file.
|
static Configuration |
loadConfiguration(java.lang.String config,
PropertyResolver overridePropsResolver,
ConfigurationLoader.IgnoredModulesOptions ignoredModulesOptions,
ThreadModeSettings threadModeSettings)
Returns the module configurations in a specified file.
|
static Configuration |
loadConfiguration(java.lang.String config,
PropertyResolver overridePropsResolver,
ThreadModeSettings threadModeSettings)
Returns the module configurations in a specified file.
|
private void |
parseInputSource(org.xml.sax.InputSource source)
Parses the specified input source loading the configuration information.
|
private static void |
parsePropertyString(java.lang.String value,
java.util.List<java.lang.String> fragments,
java.util.List<java.lang.String> propertyRefs)
Parses a string containing
${xxx} style property
references into two lists. |
private static java.lang.String |
replaceProperties(java.lang.String value,
PropertyResolver props,
java.lang.String defaultValue)
Replaces
${xxx} style constructions in the given value
with the string value of the corresponding data types. |
private static final java.lang.String SAX_PARSE_EXCEPTION_FORMAT
private static final java.lang.String DTD_PUBLIC_ID_1_0
private static final java.lang.String DTD_PUBLIC_CS_ID_1_0
private static final java.lang.String DTD_CONFIGURATION_NAME_1_0
private static final java.lang.String DTD_PUBLIC_ID_1_1
private static final java.lang.String DTD_PUBLIC_CS_ID_1_1
private static final java.lang.String DTD_CONFIGURATION_NAME_1_1
private static final java.lang.String DTD_PUBLIC_ID_1_2
private static final java.lang.String DTD_PUBLIC_CS_ID_1_2
private static final java.lang.String DTD_CONFIGURATION_NAME_1_2
private static final java.lang.String DTD_PUBLIC_ID_1_3
private static final java.lang.String DTD_PUBLIC_CS_ID_1_3
private static final java.lang.String DTD_CONFIGURATION_NAME_1_3
private static final java.lang.String UNABLE_TO_PARSE_EXCEPTION_PREFIX
private static final char DOLLAR_SIGN
private final ConfigurationLoader.InternalLoader saxHandler
private final PropertyResolver overridePropsResolver
private final java.util.Deque<DefaultConfiguration> configStack
private final boolean omitIgnoredModules
private final ThreadModeSettings threadModeSettings
private Configuration configuration
private ConfigurationLoader(PropertyResolver overrideProps, boolean omitIgnoredModules, ThreadModeSettings threadModeSettings) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException
ConfigurationLoader instance.overrideProps - resolver for overriding propertiesomitIgnoredModules - true if ignored modules should be
omittedthreadModeSettings - the thread mode configurationjavax.xml.parsers.ParserConfigurationException - if an error occursorg.xml.sax.SAXException - if an error occursprivate static java.util.Map<java.lang.String,java.lang.String> createIdToResourceNameMap()
private void parseInputSource(org.xml.sax.InputSource source) throws java.io.IOException, org.xml.sax.SAXException
source - the source that contains the configuration datajava.io.IOException - if an error occursorg.xml.sax.SAXException - if an error occurspublic static Configuration loadConfiguration(java.lang.String config, PropertyResolver overridePropsResolver) throws CheckstyleException
config - location of config file, can be either a URL or a filenameoverridePropsResolver - overriding propertiesCheckstyleException - if an error occurspublic static Configuration loadConfiguration(java.lang.String config, PropertyResolver overridePropsResolver, ThreadModeSettings threadModeSettings) throws CheckstyleException
config - location of config file, can be either a URL or a filenameoverridePropsResolver - overriding propertiesthreadModeSettings - the thread mode configurationCheckstyleException - if an error occurspublic static Configuration loadConfiguration(java.lang.String config, PropertyResolver overridePropsResolver, ConfigurationLoader.IgnoredModulesOptions ignoredModulesOptions) throws CheckstyleException
config - location of config file, can be either a URL or a filenameoverridePropsResolver - overriding propertiesignoredModulesOptions - OMIT if modules with severity
'ignore' should be omitted, EXECUTE otherwiseCheckstyleException - if an error occurspublic static Configuration loadConfiguration(java.lang.String config, PropertyResolver overridePropsResolver, ConfigurationLoader.IgnoredModulesOptions ignoredModulesOptions, ThreadModeSettings threadModeSettings) throws CheckstyleException
config - location of config file, can be either a URL or a filenameoverridePropsResolver - overriding propertiesignoredModulesOptions - OMIT if modules with severity
'ignore' should be omitted, EXECUTE otherwisethreadModeSettings - the thread mode configurationCheckstyleException - if an error occurspublic static Configuration loadConfiguration(org.xml.sax.InputSource configSource, PropertyResolver overridePropsResolver, ConfigurationLoader.IgnoredModulesOptions ignoredModulesOptions) throws CheckstyleException
configSource - the input stream to the Checkstyle configurationoverridePropsResolver - overriding propertiesignoredModulesOptions - OMIT if modules with severity
'ignore' should be omitted, EXECUTE otherwiseCheckstyleException - if an error occurspublic static Configuration loadConfiguration(org.xml.sax.InputSource configSource, PropertyResolver overridePropsResolver, ConfigurationLoader.IgnoredModulesOptions ignoredModulesOptions, ThreadModeSettings threadModeSettings) throws CheckstyleException
configSource - the input stream to the Checkstyle configurationoverridePropsResolver - overriding propertiesignoredModulesOptions - OMIT if modules with severity
'ignore' should be omitted, EXECUTE otherwisethreadModeSettings - the thread mode configurationCheckstyleException - if an error occursprivate static java.lang.String replaceProperties(java.lang.String value, PropertyResolver props, java.lang.String defaultValue) throws CheckstyleException
${xxx} style constructions in the given value
with the string value of the corresponding data types. This method must remain
outside inner class for easier testing since inner class requires an instance.
Code copied from ant - http://cvs.apache.org/viewcvs/jakarta-ant/src/main/org/apache/tools/ant/ProjectHelper.java
value - The string to be scanned for property references.
May be null, in which case this
method returns immediately with no effect.props - Mapping (String to String) of property names to their
values. Must not be null.defaultValue - default to use if one of the properties in value
cannot be resolved from props.null if the original string is null.CheckstyleException - if the string contains an opening
${} without a closing
{@code }private static void parsePropertyString(java.lang.String value, java.util.List<java.lang.String> fragments, java.util.List<java.lang.String> propertyRefs) throws CheckstyleException
${xxx} style property
references into two lists. The first list is a collection
of text fragments, while the other is a set of string property names.
null entries in the first list indicate a property
reference from the second list.
Code copied from ant - http://cvs.apache.org/viewcvs/jakarta-ant/src/main/org/apache/tools/ant/ProjectHelper.java
value - Text to parse. Must not be null.fragments - List to add text fragments to.
Must not be null.propertyRefs - List to add property names to.
Must not be null.CheckstyleException - if the string contains an opening
${} without a closing
{@code }Copyright © 2001-2022. All Rights Reserved.