Class SuppressionsLoader
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- com.puppycrawl.tools.checkstyle.XmlLoader
-
- com.puppycrawl.tools.checkstyle.filters.SuppressionsLoader
-
- All Implemented Interfaces:
org.xml.sax.ContentHandler
,org.xml.sax.DTDHandler
,org.xml.sax.EntityResolver
,org.xml.sax.ErrorHandler
public final class SuppressionsLoader extends XmlLoader
Loads a filter chain of suppressions.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.XmlLoader
XmlLoader.LoadExternalDtdFeatureProvider
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
ATTRIBUTE_NAME_CHECKS
String literal for attribute name.private static java.lang.String
ATTRIBUTE_NAME_COLUMNS
String literal for attribute name.private static java.lang.String
ATTRIBUTE_NAME_FILES
String literal for attribute name.private static java.lang.String
ATTRIBUTE_NAME_ID
String literal for attribute name.private static java.lang.String
ATTRIBUTE_NAME_LINES
String literal for attribute name.private static java.lang.String
ATTRIBUTE_NAME_MESSAGE
String literal for attribute name.private static java.lang.String
ATTRIBUTE_NAME_QUERY
String literal for attribute name.private static java.lang.String
DTD_PUBLIC_CS_ID_1_0
The new public ID for version 1_0 configuration dtd.private static java.lang.String
DTD_PUBLIC_CS_ID_1_1
The new public ID for version 1_1 configuration dtd.private static java.lang.String
DTD_PUBLIC_CS_ID_1_1_XPATH
The new public ID for version 1_1 configuration dtd.private static java.lang.String
DTD_PUBLIC_CS_ID_1_2
The new public ID for version 1_2 configuration dtd.private static java.lang.String
DTD_PUBLIC_CS_ID_1_2_XPATH
The new public ID for version 1_2 configuration dtd.private static java.lang.String
DTD_PUBLIC_ID_1_0
The public ID for the configuration dtd.private static java.lang.String
DTD_PUBLIC_ID_1_1
The public ID for the configuration dtd.private static java.lang.String
DTD_PUBLIC_ID_1_1_XPATH
The public ID for the configuration dtd.private static java.lang.String
DTD_PUBLIC_ID_1_2
The public ID for the configuration dtd.private static java.lang.String
DTD_PUBLIC_ID_1_2_XPATH
The public ID for the configuration dtd.private static java.lang.String
DTD_SUPPRESSIONS_NAME_1_0
The resource for the configuration dtd.private static java.lang.String
DTD_SUPPRESSIONS_NAME_1_1
The resource for the configuration dtd.private static java.lang.String
DTD_SUPPRESSIONS_NAME_1_1_XPATH
The resource for the configuration dtd.private static java.lang.String
DTD_SUPPRESSIONS_NAME_1_2
The resource for the configuration dtd.private static java.lang.String
DTD_SUPPRESSIONS_NAME_1_2_XPATH
The resource for the configuration dtd.private FilterSet
filterChain
The filter chain to return in getAFilterChain(), configured during parsing.private java.util.Set<TreeWalkerFilter>
treeWalkerFilters
The set of theTreeWalkerFilter
filters.private static java.lang.String
UNABLE_TO_FIND_ERROR_MESSAGE
File search error message.
-
Constructor Summary
Constructors Modifier Constructor Description private
SuppressionsLoader()
Creates a newSuppressionsLoader
instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.util.Map<java.lang.String,java.lang.String>
createIdToResourceNameMap()
Creates mapping between local resources and dtd ids.private static SuppressFilterElement
getSuppressElement(org.xml.sax.Attributes attributes)
Returns the suppress element, initialized from given attributes.private static SuppressionsLoader
getSuppressionLoader(org.xml.sax.InputSource source, java.lang.String sourceName)
Parses specified source and returns the suppression loader.private static XpathFilterElement
getXpathFilter(org.xml.sax.Attributes attributes)
Returns the xpath filter, initialized from given attributes.static FilterSet
loadSuppressions(java.lang.String filename)
Returns the suppression filters in a specified file.private static FilterSet
loadSuppressions(org.xml.sax.InputSource source, java.lang.String sourceName)
Returns the suppression filters in a specified source.static java.util.Set<TreeWalkerFilter>
loadXpathSuppressions(java.lang.String filename)
Returns the suppressionTreeWalker
filters in a specified file.private static java.util.Set<TreeWalkerFilter>
loadXpathSuppressions(org.xml.sax.InputSource source, java.lang.String sourceName)
Returns the suppressionTreeWalker
filters in a specified source.void
startElement(java.lang.String namespaceUri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
-
Methods inherited from class com.puppycrawl.tools.checkstyle.XmlLoader
error, parseInputSource, resolveEntity
-
-
-
-
Field Detail
-
DTD_PUBLIC_ID_1_0
private static final java.lang.String DTD_PUBLIC_ID_1_0
The public ID for the configuration dtd.- See Also:
- Constant Field Values
-
DTD_PUBLIC_CS_ID_1_0
private static final java.lang.String DTD_PUBLIC_CS_ID_1_0
The new public ID for version 1_0 configuration dtd.- See Also:
- Constant Field Values
-
DTD_SUPPRESSIONS_NAME_1_0
private static final java.lang.String DTD_SUPPRESSIONS_NAME_1_0
The resource for the configuration dtd.- See Also:
- Constant Field Values
-
DTD_PUBLIC_ID_1_1
private static final java.lang.String DTD_PUBLIC_ID_1_1
The public ID for the configuration dtd.- See Also:
- Constant Field Values
-
DTD_PUBLIC_CS_ID_1_1
private static final java.lang.String DTD_PUBLIC_CS_ID_1_1
The new public ID for version 1_1 configuration dtd.- See Also:
- Constant Field Values
-
DTD_SUPPRESSIONS_NAME_1_1
private static final java.lang.String DTD_SUPPRESSIONS_NAME_1_1
The resource for the configuration dtd.- See Also:
- Constant Field Values
-
DTD_PUBLIC_ID_1_2
private static final java.lang.String DTD_PUBLIC_ID_1_2
The public ID for the configuration dtd.- See Also:
- Constant Field Values
-
DTD_PUBLIC_CS_ID_1_2
private static final java.lang.String DTD_PUBLIC_CS_ID_1_2
The new public ID for version 1_2 configuration dtd.- See Also:
- Constant Field Values
-
DTD_SUPPRESSIONS_NAME_1_2
private static final java.lang.String DTD_SUPPRESSIONS_NAME_1_2
The resource for the configuration dtd.- See Also:
- Constant Field Values
-
DTD_PUBLIC_ID_1_1_XPATH
private static final java.lang.String DTD_PUBLIC_ID_1_1_XPATH
The public ID for the configuration dtd.- See Also:
- Constant Field Values
-
DTD_PUBLIC_CS_ID_1_1_XPATH
private static final java.lang.String DTD_PUBLIC_CS_ID_1_1_XPATH
The new public ID for version 1_1 configuration dtd.- See Also:
- Constant Field Values
-
DTD_SUPPRESSIONS_NAME_1_1_XPATH
private static final java.lang.String DTD_SUPPRESSIONS_NAME_1_1_XPATH
The resource for the configuration dtd.- See Also:
- Constant Field Values
-
DTD_PUBLIC_ID_1_2_XPATH
private static final java.lang.String DTD_PUBLIC_ID_1_2_XPATH
The public ID for the configuration dtd.- See Also:
- Constant Field Values
-
DTD_PUBLIC_CS_ID_1_2_XPATH
private static final java.lang.String DTD_PUBLIC_CS_ID_1_2_XPATH
The new public ID for version 1_2 configuration dtd.- See Also:
- Constant Field Values
-
DTD_SUPPRESSIONS_NAME_1_2_XPATH
private static final java.lang.String DTD_SUPPRESSIONS_NAME_1_2_XPATH
The resource for the configuration dtd.- See Also:
- Constant Field Values
-
UNABLE_TO_FIND_ERROR_MESSAGE
private static final java.lang.String UNABLE_TO_FIND_ERROR_MESSAGE
File search error message.- See Also:
- Constant Field Values
-
ATTRIBUTE_NAME_FILES
private static final java.lang.String ATTRIBUTE_NAME_FILES
String literal for attribute name.- See Also:
- Constant Field Values
-
ATTRIBUTE_NAME_CHECKS
private static final java.lang.String ATTRIBUTE_NAME_CHECKS
String literal for attribute name.- See Also:
- Constant Field Values
-
ATTRIBUTE_NAME_MESSAGE
private static final java.lang.String ATTRIBUTE_NAME_MESSAGE
String literal for attribute name.- See Also:
- Constant Field Values
-
ATTRIBUTE_NAME_ID
private static final java.lang.String ATTRIBUTE_NAME_ID
String literal for attribute name.- See Also:
- Constant Field Values
-
ATTRIBUTE_NAME_QUERY
private static final java.lang.String ATTRIBUTE_NAME_QUERY
String literal for attribute name.- See Also:
- Constant Field Values
-
ATTRIBUTE_NAME_LINES
private static final java.lang.String ATTRIBUTE_NAME_LINES
String literal for attribute name.- See Also:
- Constant Field Values
-
ATTRIBUTE_NAME_COLUMNS
private static final java.lang.String ATTRIBUTE_NAME_COLUMNS
String literal for attribute name.- See Also:
- Constant Field Values
-
filterChain
private final FilterSet filterChain
The filter chain to return in getAFilterChain(), configured during parsing.
-
treeWalkerFilters
private final java.util.Set<TreeWalkerFilter> treeWalkerFilters
The set of theTreeWalkerFilter
filters. Being filled during parsing.
-
-
Constructor Detail
-
SuppressionsLoader
private SuppressionsLoader() throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException
Creates a newSuppressionsLoader
instance.- Throws:
javax.xml.parsers.ParserConfigurationException
- if an error occursorg.xml.sax.SAXException
- if an error occurs
-
-
Method Detail
-
startElement
public void startElement(java.lang.String namespaceUri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes) throws org.xml.sax.SAXException
- Specified by:
startElement
in interfaceorg.xml.sax.ContentHandler
- Overrides:
startElement
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
getSuppressElement
private static SuppressFilterElement getSuppressElement(org.xml.sax.Attributes attributes) throws org.xml.sax.SAXException
Returns the suppress element, initialized from given attributes.- Parameters:
attributes
- the attributes of xml-tag "<suppress></suppress>", specified inside suppression file.- Returns:
- the suppress element
- Throws:
org.xml.sax.SAXException
- if an error occurs.
-
getXpathFilter
private static XpathFilterElement getXpathFilter(org.xml.sax.Attributes attributes) throws org.xml.sax.SAXException
Returns the xpath filter, initialized from given attributes.- Parameters:
attributes
- the attributes of xml-tag "<suppress-xpath></suppress-xpath>", specified inside suppression file.- Returns:
- the xpath filter
- Throws:
org.xml.sax.SAXException
- if an error occurs.
-
loadSuppressions
public static FilterSet loadSuppressions(java.lang.String filename) throws CheckstyleException
Returns the suppression filters in a specified file.- Parameters:
filename
- name of the suppressions file.- Returns:
- the filter chain of suppression elements specified in the file.
- Throws:
CheckstyleException
- if an error occurs.
-
loadSuppressions
private static FilterSet loadSuppressions(org.xml.sax.InputSource source, java.lang.String sourceName) throws CheckstyleException
Returns the suppression filters in a specified source.- Parameters:
source
- the source for the suppressions.sourceName
- the name of the source.- Returns:
- the filter chain of suppression elements in source.
- Throws:
CheckstyleException
- if an error occurs.
-
loadXpathSuppressions
public static java.util.Set<TreeWalkerFilter> loadXpathSuppressions(java.lang.String filename) throws CheckstyleException
Returns the suppressionTreeWalker
filters in a specified file.- Parameters:
filename
- name of the suppressions file.- Returns:
- the set of xpath suppression elements specified in the file.
- Throws:
CheckstyleException
- if an error occurs.
-
loadXpathSuppressions
private static java.util.Set<TreeWalkerFilter> loadXpathSuppressions(org.xml.sax.InputSource source, java.lang.String sourceName) throws CheckstyleException
Returns the suppressionTreeWalker
filters in a specified source.- Parameters:
source
- the source for the suppressions.sourceName
- the name of the source.- Returns:
- the set of xpath suppression elements specified in source.
- Throws:
CheckstyleException
- if an error occurs.
-
getSuppressionLoader
private static SuppressionsLoader getSuppressionLoader(org.xml.sax.InputSource source, java.lang.String sourceName) throws CheckstyleException
Parses specified source and returns the suppression loader.- Parameters:
source
- the source for the suppressions.sourceName
- the name of the source.- Returns:
- the suppression loader
- Throws:
CheckstyleException
- if an error occurs.
-
createIdToResourceNameMap
private static java.util.Map<java.lang.String,java.lang.String> createIdToResourceNameMap()
Creates mapping between local resources and dtd ids.- Returns:
- map between local resources and dtd ids.
-
-