Package com.puppycrawl.tools.checkstyle
Class ConfigurationLoader.InternalLoader
java.lang.Object
org.xml.sax.helpers.DefaultHandler
com.puppycrawl.tools.checkstyle.XmlLoader
com.puppycrawl.tools.checkstyle.ConfigurationLoader.InternalLoader
- All Implemented Interfaces:
ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
- Enclosing class:
- ConfigurationLoader
Implements the SAX document handler interfaces, so they do not
appear in the public API of the ConfigurationLoader.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.XmlLoader
XmlLoader.LoadExternalDtdFeatureProvider
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Deque<DefaultConfiguration>
The loaded configurations.private Configuration
The Configuration that is being built.private static final String
Default attribute.private static final String
Name of the key attribute.private static final String
Name of the message element.private static final String
Name of the message element.private static final String
Module elements.private static final String
Name attribute.private static final String
Property element.private static final String
Name of the severity property.private static final String
Value attribute. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static boolean
containsAttribute
(Configuration module, String attributeName) Util method to recheck attribute in module.void
endElement
(String uri, String localName, String qName) private static void
parsePropertyString
(String value, Collection<String> fragments, Collection<String> propertyRefs) Parses a string containing${xxx}
style property references into two collections.private String
replaceProperties
(String value, String defaultValue) Replaces${xxx}
style constructions in the given value with the string value of the corresponding data types.void
startElement
(String uri, 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, endPrefixMapping, fatalError, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.xml.sax.ContentHandler
declaration
-
Field Details
-
MODULE
Module elements.- See Also:
-
NAME
Name attribute.- See Also:
-
PROPERTY
Property element.- See Also:
-
VALUE
Value attribute.- See Also:
-
DEFAULT
Default attribute.- See Also:
-
SEVERITY
Name of the severity property.- See Also:
-
MESSAGE
Name of the message element.- See Also:
-
METADATA
Name of the message element.- See Also:
-
KEY
Name of the key attribute.- See Also:
-
configStack
The loaded configurations. -
configuration
The Configuration that is being built.
-
-
Constructor Details
-
InternalLoader
Creates a new InternalLoader.- Throws:
SAXException
- if an error occursParserConfigurationException
- if an error occurs
-
-
Method Details
-
replaceProperties
Replaces${xxx}
style constructions in the given value with the string value of the corresponding data types.Code copied from ant
- Parameters:
value
- The string to be scanned for property references. Must not benull
.defaultValue
- default to use if one of the properties in value cannot be resolved from props.- Returns:
- the original string with the properties replaced.
- Throws:
CheckstyleException
- if the string contains an opening${} without a closing {@code }
-
parsePropertyString
private static void parsePropertyString(String value, Collection<String> fragments, Collection<String> propertyRefs) throws CheckstyleException Parses a string containing${xxx}
style property references into two collections. The first one is a collection of text fragments, while the other is a set of string property names.null
entries in the first collection indicate a property reference from the second collection.Code copied from ant
- Parameters:
value
- Text to parse. Must not benull
.fragments
- Collection to add text fragments to. Must not benull
.propertyRefs
- Collection to add property names to. Must not benull
.- Throws:
CheckstyleException
- if the string contains an opening${} without a closing {@code }
-
startElement
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException - Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
- Throws:
SAXException
-
endElement
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
- Throws:
SAXException
-
containsAttribute
Util method to recheck attribute in module.- Parameters:
module
- module to checkattributeName
- name of attribute in module to find- Returns:
- true if attribute is present in module
-