public final class ConfigurationLoader
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
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_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 static java.lang.String |
DTD_RESOURCE_NAME_1_0
The resource for version 1_0 of the configuration dtd.
|
private static java.lang.String |
DTD_RESOURCE_NAME_1_1
The resource for version 1_1 of the configuration dtd.
|
private static java.lang.String |
DTD_RESOURCE_NAME_1_2
The resource for version 1_2 of the configuration dtd.
|
private static java.lang.String |
DTD_RESOURCE_NAME_1_3
The resource 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 ConfigurationLoader.InternalLoader |
saxHandler
The SAX document handler.
|
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)
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,
boolean omitIgnoredModules)
Returns the module configurations from a specified input source.
|
static Configuration |
loadConfiguration(java.io.InputStream configStream,
PropertyResolver overridePropsResolver,
boolean omitIgnoredModules)
Deprecated.
As this method does not provide a valid system ID,
preventing resolution of external entities, a
version using an InputSource
should be used instead |
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,
boolean omitIgnoredModules)
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 DTD_PUBLIC_ID_1_0
private static final java.lang.String DTD_RESOURCE_NAME_1_0
private static final java.lang.String DTD_PUBLIC_ID_1_1
private static final java.lang.String DTD_RESOURCE_NAME_1_1
private static final java.lang.String DTD_PUBLIC_ID_1_2
private static final java.lang.String DTD_RESOURCE_NAME_1_2
private static final java.lang.String DTD_PUBLIC_ID_1_3
private static final java.lang.String DTD_RESOURCE_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 Configuration configuration
private ConfigurationLoader(PropertyResolver overrideProps, boolean omitIgnoredModules) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException
ConfigurationLoader instance.overrideProps - resolver for overriding propertiesomitIgnoredModules - true if ignored modules should be
omittedjavax.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, boolean omitIgnoredModules) throws CheckstyleException
config - location of config file, can be either a URL or a filenameoverridePropsResolver - overriding propertiesomitIgnoredModules - true if modules with severity
'ignore' should be omitted, false otherwiseCheckstyleException - if an error occurs@Deprecated public static Configuration loadConfiguration(java.io.InputStream configStream, PropertyResolver overridePropsResolver, boolean omitIgnoredModules) throws CheckstyleException
version using an InputSource
should be used insteadconfigStream - the input stream to the Checkstyle configurationoverridePropsResolver - overriding propertiesomitIgnoredModules - true if modules with severity
'ignore' should be omitted, false otherwiseCheckstyleException - if an error occurspublic static Configuration loadConfiguration(org.xml.sax.InputSource configSource, PropertyResolver overridePropsResolver, boolean omitIgnoredModules) throws CheckstyleException
configSource - the input stream to the Checkstyle configurationoverridePropsResolver - overriding propertiesomitIgnoredModules - true if modules with severity
'ignore' should be omitted, false otherwiseCheckstyleException - 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.
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 }