Class SuppressionsLoader
java.lang.Object
org.xml.sax.helpers.DefaultHandler
com.puppycrawl.tools.checkstyle.XmlLoader
com.puppycrawl.tools.checkstyle.filters.SuppressionsLoader
- All Implemented Interfaces:
ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
Loads a filter chain of suppressions.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.XmlLoader
XmlLoader.LoadExternalDtdFeatureProvider
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
String literal for attribute name.private static final String
String literal for attribute name.private static final String
String literal for attribute name.private static final String
String literal for attribute name.private static final String
String literal for attribute name.private static final String
String literal for attribute name.private static final String
String literal for attribute name.private static final String
The new public ID for version 1_0 configuration dtd.private static final String
The new public ID for version 1_1 configuration dtd.private static final String
The new public ID for version 1_1 configuration dtd.private static final String
The new public ID for version 1_2 configuration dtd.private static final String
The new public ID for version 1_2 configuration dtd.private static final String
The public ID for the configuration dtd.private static final String
The public ID for the configuration dtd.private static final String
The public ID for the configuration dtd.private static final String
The public ID for the configuration dtd.private static final String
The public ID for the configuration dtd.private static final String
The resource for the configuration dtd.private static final String
The resource for the configuration dtd.private static final String
The resource for the configuration dtd.private static final String
The resource for the configuration dtd.private static final String
The resource for the configuration dtd.private final FilterSet
The filter chain to return in getAFilterChain(), configured during parsing.private final Set<TreeWalkerFilter>
The set of theTreeWalkerFilter
filters.private static final String
File search error message. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Creates a newSuppressionsLoader
instance. -
Method Summary
Modifier and TypeMethodDescriptionCreates mapping between local resources and dtd ids.private static SuppressFilterElement
getSuppressElement
(Attributes attributes) Returns the suppress element, initialized from given attributes.private static SuppressionsLoader
getSuppressionLoader
(InputSource source, String sourceName) Parses specified source and returns the suppression loader.private static XpathFilterElement
getXpathFilter
(Attributes attributes) Returns the xpath filter, initialized from given attributes.static FilterSet
loadSuppressions
(String filename) Returns the suppression filters in a specified file.private static FilterSet
loadSuppressions
(InputSource source, String sourceName) Returns the suppression filters in a specified source.static Set<TreeWalkerFilter>
loadXpathSuppressions
(String filename) Returns the suppressionTreeWalker
filters in a specified file.private static Set<TreeWalkerFilter>
loadXpathSuppressions
(InputSource source, String sourceName) Returns the suppressionTreeWalker
filters in a specified source.void
startElement
(String namespaceUri, String localName, String qName, Attributes attributes) Methods inherited from class com.puppycrawl.tools.checkstyle.XmlLoader
error, parseInputSource, resolveEntity
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, fatalError, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
-
Field Details
-
DTD_PUBLIC_ID_1_0
The public ID for the configuration dtd.- See Also:
-
DTD_PUBLIC_CS_ID_1_0
The new public ID for version 1_0 configuration dtd.- See Also:
-
DTD_SUPPRESSIONS_NAME_1_0
The resource for the configuration dtd.- See Also:
-
DTD_PUBLIC_ID_1_1
The public ID for the configuration dtd.- See Also:
-
DTD_PUBLIC_CS_ID_1_1
The new public ID for version 1_1 configuration dtd.- See Also:
-
DTD_SUPPRESSIONS_NAME_1_1
The resource for the configuration dtd.- See Also:
-
DTD_PUBLIC_ID_1_2
The public ID for the configuration dtd.- See Also:
-
DTD_PUBLIC_CS_ID_1_2
The new public ID for version 1_2 configuration dtd.- See Also:
-
DTD_SUPPRESSIONS_NAME_1_2
The resource for the configuration dtd.- See Also:
-
DTD_PUBLIC_ID_1_1_XPATH
The public ID for the configuration dtd.- See Also:
-
DTD_PUBLIC_CS_ID_1_1_XPATH
The new public ID for version 1_1 configuration dtd.- See Also:
-
DTD_SUPPRESSIONS_NAME_1_1_XPATH
The resource for the configuration dtd.- See Also:
-
DTD_PUBLIC_ID_1_2_XPATH
The public ID for the configuration dtd.- See Also:
-
DTD_PUBLIC_CS_ID_1_2_XPATH
The new public ID for version 1_2 configuration dtd.- See Also:
-
DTD_SUPPRESSIONS_NAME_1_2_XPATH
The resource for the configuration dtd.- See Also:
-
UNABLE_TO_FIND_ERROR_MESSAGE
File search error message.- See Also:
-
ATTRIBUTE_NAME_FILES
String literal for attribute name.- See Also:
-
ATTRIBUTE_NAME_CHECKS
String literal for attribute name.- See Also:
-
ATTRIBUTE_NAME_MESSAGE
String literal for attribute name.- See Also:
-
ATTRIBUTE_NAME_ID
String literal for attribute name.- See Also:
-
ATTRIBUTE_NAME_QUERY
String literal for attribute name.- See Also:
-
ATTRIBUTE_NAME_LINES
String literal for attribute name.- See Also:
-
ATTRIBUTE_NAME_COLUMNS
String literal for attribute name.- See Also:
-
filterChain
The filter chain to return in getAFilterChain(), configured during parsing. -
treeWalkerFilters
The set of theTreeWalkerFilter
filters. Being filled during parsing.
-
-
Constructor Details
-
SuppressionsLoader
Creates a newSuppressionsLoader
instance.- Throws:
ParserConfigurationException
- if an error occursSAXException
- if an error occurs
-
-
Method Details
-
startElement
public void startElement(String namespaceUri, String localName, String qName, Attributes attributes) throws SAXException - Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
- Throws:
SAXException
-
getSuppressElement
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:
SAXException
- if an error occurs.
-
getXpathFilter
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:
SAXException
- if an error occurs.
-
loadSuppressions
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(InputSource source, 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 Set<TreeWalkerFilter> loadXpathSuppressions(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 Set<TreeWalkerFilter> loadXpathSuppressions(InputSource source, 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(InputSource source, 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
Creates mapping between local resources and dtd ids.- Returns:
- map between local resources and dtd ids.
-