/** * Returns the module configurations in a specified file. * @param config location of config file, can be either a URL or a filename * @param overridePropsResolver overriding properties * @return the check configurations * @throws CheckstyleException if an error occurs */ public static Configuration loadConfiguration(String config, PropertyResolver overridePropsResolver) throws CheckstyleException { return loadConfiguration(config, overridePropsResolver, IgnoredModulesOptions.EXECUTE); }
final boolean omitIgnoreModules = ignoredModulesOptions == IgnoredModulesOptions.OMIT; final ConfigurationLoader loader = new ConfigurationLoader(overridePropsResolver, omitIgnoreModules, threadModeSettings); loader.parseInputSource(configSource); return loader.configuration;
parsePropertyString(value, fragments, propertyRefs);
/** * Returns the module configurations in a specified file. * @param config location of config file, can be either a URL or a filename * @param overridePropsResolver overriding properties * @param threadModeSettings the thread mode configuration * @return the check configurations * @throws CheckstyleException if an error occurs */ public static Configuration loadConfiguration(String config, PropertyResolver overridePropsResolver, ThreadModeSettings threadModeSettings) throws CheckstyleException { return loadConfiguration(config, overridePropsResolver, IgnoredModulesOptions.EXECUTE, threadModeSettings); }
try { final ConfigurationLoader loader = new ConfigurationLoader(overridePropsResolver, omitIgnoredModules, threadModeSettings); loader.parseInputSource(configSource); return loader.configuration;
parsePropertyString(value, fragments, propertyRefs);
/** * Returns the module configurations in a specified file. * * @param config location of config file, can be either a URL or a filename * @param overridePropsResolver overriding properties * @param ignoredModulesOptions {@code OMIT} if modules with severity * 'ignore' should be omitted, {@code EXECUTE} otherwise * @return the check configurations * @throws CheckstyleException if an error occurs */ public static Configuration loadConfiguration(String config, PropertyResolver overridePropsResolver, IgnoredModulesOptions ignoredModulesOptions) throws CheckstyleException { return loadConfiguration(config, overridePropsResolver, ignoredModulesOptions, ThreadModeSettings.SINGLE_THREAD_MODE_INSTANCE); }
try { final ConfigurationLoader loader = new ConfigurationLoader(overridePropsResolver, omitIgnoredModules, threadModeSettings); loader.parseInputSource(configSource); return loader.configuration;
/** * 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 * * @param configSource the input stream to the Checkstyle configuration * @param overridePropsResolver overriding properties * @param ignoredModulesOptions {@code OMIT} if modules with severity * 'ignore' should be omitted, {@code EXECUTE} otherwise * @return the check configurations * @throws CheckstyleException if an error occurs */ public static Configuration loadConfiguration(InputSource configSource, PropertyResolver overridePropsResolver, IgnoredModulesOptions ignoredModulesOptions) throws CheckstyleException { return loadConfiguration(configSource, overridePropsResolver, ignoredModulesOptions, ThreadModeSettings.SINGLE_THREAD_MODE_INSTANCE); }
final boolean omitIgnoreModules = ignoredModulesOptions == IgnoredModulesOptions.OMIT; final ConfigurationLoader loader = new ConfigurationLoader(overridePropsResolver, omitIgnoreModules, threadModeSettings); loader.parseInputSource(configSource); return loader.configuration;
/** * Returns the module configurations in a specified file. * * @param config location of config file, can be either a URL or a filename * @param overridePropsResolver overriding properties * @param omitIgnoredModules {@code true} if modules with severity * 'ignore' should be omitted, {@code false} otherwise * @return the check configurations * @throws CheckstyleException if an error occurs * @deprecated in order to fulfill demands of BooleanParameter IDEA check. * @noinspection BooleanParameter */ @Deprecated public static Configuration loadConfiguration(String config, PropertyResolver overridePropsResolver, boolean omitIgnoredModules) throws CheckstyleException { return loadConfiguration(config, overridePropsResolver, omitIgnoredModules, ThreadModeSettings.SINGLE_THREAD_MODE_INSTANCE); }
/** * 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 * * @param configSource the input stream to the Checkstyle configuration * @param overridePropsResolver overriding properties * @param omitIgnoredModules {@code true} if modules with severity * 'ignore' should be omitted, {@code false} otherwise * @return the check configurations * @throws CheckstyleException if an error occurs * @deprecated in order to fulfill demands of BooleanParameter IDEA check. * @noinspection BooleanParameter */ @Deprecated public static Configuration loadConfiguration(InputSource configSource, PropertyResolver overridePropsResolver, boolean omitIgnoredModules) throws CheckstyleException { return loadConfiguration(configSource, overridePropsResolver, omitIgnoredModules, ThreadModeSettings.SINGLE_THREAD_MODE_INSTANCE); }
/** * Returns the module configurations from a specified input stream. * Note that clients are required to close the given stream by themselves * * @param configStream the input stream to the Checkstyle configuration * @param overridePropsResolver overriding properties * @param omitIgnoredModules {@code true} if modules with severity * 'ignore' should be omitted, {@code false} otherwise * @return the check configurations * @throws CheckstyleException if an error occurs * * @deprecated As this method does not provide a valid system ID, * preventing resolution of external entities, a * {@link #loadConfiguration(InputSource,PropertyResolver,boolean) * version using an InputSource} * should be used instead * @noinspection BooleanParameter */ @Deprecated public static Configuration loadConfiguration(InputStream configStream, PropertyResolver overridePropsResolver, boolean omitIgnoredModules) throws CheckstyleException { return loadConfiguration(new InputSource(configStream), overridePropsResolver, omitIgnoredModules); }
/** * Returns the module configurations in a specified file. * * @param config location of config file, can be either a URL or a filename * @param overridePropsResolver overriding properties * @param ignoredModulesOptions {@code OMIT} if modules with severity * 'ignore' should be omitted, {@code EXECUTE} otherwise * @param threadModeSettings the thread mode configuration * @return the check configurations * @throws CheckstyleException if an error occurs */ public static Configuration loadConfiguration(String config, PropertyResolver overridePropsResolver, IgnoredModulesOptions ignoredModulesOptions, ThreadModeSettings threadModeSettings) throws CheckstyleException { // figure out if this is a File or a URL final URI uri = CommonUtil.getUriByFilename(config); final InputSource source = new InputSource(uri.toString()); return loadConfiguration(source, overridePropsResolver, ignoredModulesOptions, threadModeSettings); }
/** * Returns the module configurations in a specified file. * * @param config location of config file, can be either a URL or a filename * @param overridePropsResolver overriding properties * @param omitIgnoredModules {@code true} if modules with severity * 'ignore' should be omitted, {@code false} otherwise * @param threadModeSettings the thread mode configuration * @return the check configurations * @throws CheckstyleException if an error occurs * @deprecated in order to fulfill demands of BooleanParameter IDEA check. * @noinspection BooleanParameter, WeakerAccess */ @Deprecated public static Configuration loadConfiguration(String config, PropertyResolver overridePropsResolver, boolean omitIgnoredModules, ThreadModeSettings threadModeSettings) throws CheckstyleException { // figure out if this is a File or a URL final URI uri = CommonUtil.getUriByFilename(config); final InputSource source = new InputSource(uri.toString()); return loadConfiguration(source, overridePropsResolver, omitIgnoredModules, threadModeSettings); }
public static Configuration loadConfiguration(String path, Properties props) throws CheckstyleException { return ConfigurationLoader.loadConfiguration(path, new PropertiesExpander(props)); }
@Test public void testExternalEntityFromUri() throws Exception { final Properties props = new Properties(); props.setProperty("checkstyle.basedir", "basedir"); final File file = new File( getPath("subdir/InputConfigurationLoaderExternalEntitySubDir.xml")); final DefaultConfiguration config = (DefaultConfiguration) ConfigurationLoader.loadConfiguration( file.toURI().toString(), new PropertiesExpander(props)); final Properties atts = new Properties(); atts.setProperty("tabWidth", "4"); atts.setProperty("basedir", "basedir"); verifyConfigNode(config, "Checker", 2, atts); }
private Configuration loadConfiguration( String name, Properties props) throws Exception { final String fName = getPath(name); return ConfigurationLoader.loadConfiguration(fName, new PropertiesExpander(props)); }
@Test public void testResourceLoadConfiguration() throws Exception { final Properties props = new Properties(); props.setProperty("checkstyle.basedir", "basedir"); // load config that's only found in the classpath final DefaultConfiguration config = (DefaultConfiguration) ConfigurationLoader.loadConfiguration( getPath("InputConfigurationLoaderChecks.xml"), new PropertiesExpander(props)); //verify the root, and property substitution final Properties attributes = new Properties(); attributes.setProperty("tabWidth", "4"); attributes.setProperty("basedir", "basedir"); verifyConfigNode(config, "Checker", 3, attributes); }
@Test public void testConfigWithIgnoreUsingInputSource() throws Exception { final DefaultConfiguration config = (DefaultConfiguration) ConfigurationLoader.loadConfiguration(new InputSource( new File(getPath("InputConfigurationLoaderModuleIgnoreSeverity.xml")) .toURI().toString()), new PropertiesExpander(new Properties()), true); final Configuration[] children = config.getChildren(); assertEquals("Invalid children count", 0, children[0].getChildren().length); }