Class ConfigurationLoader

java.lang.Object
com.puppycrawl.tools.checkstyle.ConfigurationLoader

public final class ConfigurationLoader extends Object
Loads a configuration from a standard configuration XML file.
  • Field Details

    • DTD_PUBLIC_CS_ID_1_3

      public static final String 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

      public static final String DTD_CONFIGURATION_NAME_1_3
      The resource for version 1_3 of the configuration dtd.
      See Also:
    • SAX_PARSE_EXCEPTION_FORMAT

      private static final String SAX_PARSE_EXCEPTION_FORMAT
      Format of message for sax parse exception.
      See Also:
    • DTD_PUBLIC_ID_1_0

      private static final String DTD_PUBLIC_ID_1_0
      The public ID for version 1_0 of the configuration dtd.
      See Also:
    • DTD_PUBLIC_CS_ID_1_0

      private static final String 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

      private static final String DTD_CONFIGURATION_NAME_1_0
      The resource for version 1_0 of the configuration dtd.
      See Also:
    • DTD_PUBLIC_ID_1_1

      private static final String DTD_PUBLIC_ID_1_1
      The public ID for version 1_1 of the configuration dtd.
      See Also:
    • DTD_PUBLIC_CS_ID_1_1

      private static final String 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

      private static final String DTD_CONFIGURATION_NAME_1_1
      The resource for version 1_1 of the configuration dtd.
      See Also:
    • DTD_PUBLIC_ID_1_2

      private static final String DTD_PUBLIC_ID_1_2
      The public ID for version 1_2 of the configuration dtd.
      See Also:
    • DTD_PUBLIC_CS_ID_1_2

      private static final String 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

      private static final String DTD_CONFIGURATION_NAME_1_2
      The resource for version 1_2 of the configuration dtd.
      See Also:
    • DTD_PUBLIC_ID_1_3

      private static final String DTD_PUBLIC_ID_1_3
      The public ID for version 1_3 of the configuration dtd.
      See Also:
    • UNABLE_TO_PARSE_EXCEPTION_PREFIX

      private static final String UNABLE_TO_PARSE_EXCEPTION_PREFIX
      Prefix for the exception when unable to parse resource.
      See Also:
    • DOLLAR_SIGN

      private static final char DOLLAR_SIGN
      Dollar sign literal.
      See Also:
    • DOLLAR_SIGN_STRING

      private static final String DOLLAR_SIGN_STRING
      Dollar sign string.
    • ID_TO_RESOURCE_NAME_MAP

      private static final Map<String,String> ID_TO_RESOURCE_NAME_MAP
      Static map of DTD IDs to resource names.
    • saxHandler

      private final ConfigurationLoader.InternalLoader saxHandler
      The SAX document handler.
    • overridePropsResolver

      private final PropertyResolver overridePropsResolver
      Property resolver.
    • omitIgnoredModules

      private final boolean omitIgnoredModules
      Flags if modules with the severity 'ignore' should be omitted.
    • threadModeSettings

      private final ThreadModeSettings threadModeSettings
      The thread mode configuration.
  • Constructor Details

  • Method Details

    • parseInputSource

      private Configuration parseInputSource(InputSource source) throws IOException, SAXException
      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 occurs
      SAXException - 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 filename
      overridePropsResolver - 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 filename
      overridePropsResolver - overriding properties
      threadModeSettings - 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 filename
      overridePropsResolver - overriding properties
      ignoredModulesOptions - 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 filename
      overridePropsResolver - overriding properties
      ignoredModulesOptions - OMIT if modules with severity 'ignore' should be omitted, EXECUTE otherwise
      threadModeSettings - 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 configuration
      overridePropsResolver - overriding properties
      ignoredModulesOptions - 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 configuration
      overridePropsResolver - overriding properties
      ignoredModulesOptions - OMIT if modules with severity 'ignore' should be omitted, EXECUTE otherwise
      threadModeSettings - the thread mode configuration
      Returns:
      the check configurations
      Throws:
      CheckstyleException - if an error occurs