Package com.puppycrawl.tools.checkstyle
Class ConfigurationLoader
java.lang.Object
com.puppycrawl.tools.checkstyle.ConfigurationLoader
Loads a configuration from a standard configuration XML file.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Enum to specify behaviour regarding ignored modules.private final class
Implements the SAX document handler interfaces, so they do not appear in the public API of the ConfigurationLoader. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final char
Dollar sign literal.private static final String
Dollar sign string.private static final String
The resource for version 1_0 of the configuration dtd.private static final String
The resource for version 1_1 of the configuration dtd.private static final String
The resource for version 1_2 of the configuration dtd.static final String
The resource for version 1_3 of the configuration dtd.private static final String
The new public ID for version 1_0 of the configuration dtd.private static final String
The new public ID for version 1_1 of the configuration dtd.private static final String
The new public ID for version 1_2 of the configuration dtd.static final String
The new public ID for version 1_3 of the configuration dtd.private static final String
The public ID for version 1_0 of the configuration dtd.private static final String
The public ID for version 1_1 of the configuration dtd.private static final String
The public ID for version 1_2 of the configuration dtd.private static final String
The public ID for version 1_3 of the configuration dtd.Static map of DTD IDs to resource names.private final boolean
Flags if modules with the severity 'ignore' should be omitted.private final PropertyResolver
Property resolver.private static final String
Format of message for sax parse exception.private final ConfigurationLoader.InternalLoader
The SAX document handler.private final ThreadModeSettings
The thread mode configuration.private static final String
Prefix for the exception when unable to parse resource. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
ConfigurationLoader
(PropertyResolver overrideProps, boolean omitIgnoredModules, ThreadModeSettings threadModeSettings) Creates a newConfigurationLoader
instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic Configuration
loadConfiguration
(String config, PropertyResolver overridePropsResolver) Returns the module configurations in a specified file.static Configuration
loadConfiguration
(String config, PropertyResolver overridePropsResolver, ConfigurationLoader.IgnoredModulesOptions ignoredModulesOptions) Returns the module configurations in a specified file.static Configuration
loadConfiguration
(String config, PropertyResolver overridePropsResolver, ConfigurationLoader.IgnoredModulesOptions ignoredModulesOptions, ThreadModeSettings threadModeSettings) Returns the module configurations in a specified file.static Configuration
loadConfiguration
(String config, PropertyResolver overridePropsResolver, ThreadModeSettings threadModeSettings) Returns the module configurations in a specified file.static Configuration
loadConfiguration
(InputSource configSource, PropertyResolver overridePropsResolver, ConfigurationLoader.IgnoredModulesOptions ignoredModulesOptions) Returns the module configurations from a specified input source.static Configuration
loadConfiguration
(InputSource configSource, PropertyResolver overridePropsResolver, ConfigurationLoader.IgnoredModulesOptions ignoredModulesOptions, ThreadModeSettings threadModeSettings) Returns the module configurations from a specified input source.private Configuration
parseInputSource
(InputSource source) Parses the specified input source loading the configuration information.
-
Field Details
-
DTD_PUBLIC_CS_ID_1_3
The new public ID for version 1_3 of the configuration dtd.- See Also:
-
DTD_CONFIGURATION_NAME_1_3
The resource for version 1_3 of the configuration dtd.- See Also:
-
SAX_PARSE_EXCEPTION_FORMAT
Format of message for sax parse exception.- See Also:
-
DTD_PUBLIC_ID_1_0
The public ID for version 1_0 of the configuration dtd.- See Also:
-
DTD_PUBLIC_CS_ID_1_0
The new public ID for version 1_0 of the configuration dtd.- See Also:
-
DTD_CONFIGURATION_NAME_1_0
The resource for version 1_0 of the configuration dtd.- See Also:
-
DTD_PUBLIC_ID_1_1
The public ID for version 1_1 of the configuration dtd.- See Also:
-
DTD_PUBLIC_CS_ID_1_1
The new public ID for version 1_1 of the configuration dtd.- See Also:
-
DTD_CONFIGURATION_NAME_1_1
The resource for version 1_1 of the configuration dtd.- See Also:
-
DTD_PUBLIC_ID_1_2
The public ID for version 1_2 of the configuration dtd.- See Also:
-
DTD_PUBLIC_CS_ID_1_2
The new public ID for version 1_2 of the configuration dtd.- See Also:
-
DTD_CONFIGURATION_NAME_1_2
The resource for version 1_2 of the configuration dtd.- See Also:
-
DTD_PUBLIC_ID_1_3
The public ID for version 1_3 of the configuration dtd.- See Also:
-
UNABLE_TO_PARSE_EXCEPTION_PREFIX
Prefix for the exception when unable to parse resource.- See Also:
-
DOLLAR_SIGN
Dollar sign literal.- See Also:
-
DOLLAR_SIGN_STRING
Dollar sign string. -
ID_TO_RESOURCE_NAME_MAP
Static map of DTD IDs to resource names. -
saxHandler
The SAX document handler. -
overridePropsResolver
Property resolver. -
omitIgnoredModules
Flags if modules with the severity 'ignore' should be omitted. -
threadModeSettings
The thread mode configuration.
-
-
Constructor Details
-
ConfigurationLoader
private ConfigurationLoader(PropertyResolver overrideProps, boolean omitIgnoredModules, ThreadModeSettings threadModeSettings) throws ParserConfigurationException, SAXException Creates a newConfigurationLoader
instance.- Parameters:
overrideProps
- resolver for overriding propertiesomitIgnoredModules
-true
if ignored modules should be omittedthreadModeSettings
- the thread mode configuration- Throws:
ParserConfigurationException
- if an error occursSAXException
- if an error occurs
-
-
Method Details
-
parseInputSource
Parses the specified input source loading the configuration information. The stream wrapped inside the source, if any, is NOT explicitly closed after parsing, it is the responsibility of the caller to close the stream.- Parameters:
source
- the source that contains the configuration data- Returns:
- the check configurations
- Throws:
IOException
- if an error occursSAXException
- if an error occurs
-
loadConfiguration
public static Configuration loadConfiguration(String config, PropertyResolver overridePropsResolver) throws CheckstyleException Returns the module configurations in a specified file.- Parameters:
config
- location of config file, can be either a URL or a filenameoverridePropsResolver
- overriding properties- Returns:
- the check configurations
- Throws:
CheckstyleException
- if an error occurs
-
loadConfiguration
public static Configuration loadConfiguration(String config, PropertyResolver overridePropsResolver, ThreadModeSettings threadModeSettings) throws CheckstyleException Returns the module configurations in a specified file.- Parameters:
config
- location of config file, can be either a URL or a filenameoverridePropsResolver
- overriding propertiesthreadModeSettings
- the thread mode configuration- Returns:
- the check configurations
- Throws:
CheckstyleException
- if an error occurs
-
loadConfiguration
public static Configuration loadConfiguration(String config, PropertyResolver overridePropsResolver, ConfigurationLoader.IgnoredModulesOptions ignoredModulesOptions) throws CheckstyleException Returns the module configurations in a specified file.- Parameters:
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
otherwise- Returns:
- the check configurations
- Throws:
CheckstyleException
- if an error occurs
-
loadConfiguration
public static Configuration loadConfiguration(String config, PropertyResolver overridePropsResolver, ConfigurationLoader.IgnoredModulesOptions ignoredModulesOptions, ThreadModeSettings threadModeSettings) throws CheckstyleException Returns the module configurations in a specified file.- Parameters:
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 configuration- Returns:
- the check configurations
- Throws:
CheckstyleException
- if an error occurs
-
loadConfiguration
public static Configuration loadConfiguration(InputSource configSource, PropertyResolver overridePropsResolver, ConfigurationLoader.IgnoredModulesOptions ignoredModulesOptions) throws CheckstyleException Returns the module configurations from a specified input source. Note that if the source does wrap an open byte or character stream, clients are required to close that stream by themselves- Parameters:
configSource
- the input stream to the Checkstyle configurationoverridePropsResolver
- overriding propertiesignoredModulesOptions
-OMIT
if modules with severity 'ignore' should be omitted,EXECUTE
otherwise- Returns:
- the check configurations
- Throws:
CheckstyleException
- if an error occurs
-
loadConfiguration
public static Configuration loadConfiguration(InputSource configSource, PropertyResolver overridePropsResolver, ConfigurationLoader.IgnoredModulesOptions ignoredModulesOptions, ThreadModeSettings threadModeSettings) throws CheckstyleException Returns the module configurations from a specified input source. Note that if the source does wrap an open byte or character stream, clients are required to close that stream by themselves- Parameters:
configSource
- the input stream to the Checkstyle configurationoverridePropsResolver
- overriding propertiesignoredModulesOptions
-OMIT
if modules with severity 'ignore' should be omitted,EXECUTE
otherwisethreadModeSettings
- the thread mode configuration- Returns:
- the check configurations
- Throws:
CheckstyleException
- if an error occurs
-