Class PackageNamesLoader
java.lang.Object
org.xml.sax.helpers.DefaultHandler
com.puppycrawl.tools.checkstyle.XmlLoader
com.puppycrawl.tools.checkstyle.PackageNamesLoader
- All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler
Loads a list of package names from a package name XML file.
-
Nested Class Summary
Nested classes/interfaces inherited from class XmlLoader
XmlLoader.LoadExternalDtdFeatureProvider -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringName of default checkstyle package names resource file.private static final StringThe new public ID for the configuration dtd.private static final StringThe public ID for the configuration dtd.private static final StringThe resource for the configuration dtd.private static final StringQualified name for element 'package'.The fully qualified package names.The temporary stack of package name parts. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateCreates a newPackageNamesLoaderinstance. -
Method Summary
Modifier and TypeMethodDescriptionCreates mapping between local resources and dtd ids.voidendElement(String uri, String localName, String qName) private StringCreates a full package name from the package names on the stack.getPackageNames(ClassLoader classLoader) Returns the set of package names, compiled from all checkstyle_packages.xml files found on the given class loaders classpath.private static voidprocessFile(URL packageFile, PackageNamesLoader namesLoader) Reads the file provided and parses it with package names loader.voidstartElement(String uri, String localName, String qName, Attributes attributes) Methods inherited from class XmlLoader
error, parseInputSource, resolveEntityMethods inherited from class DefaultHandler
characters, endDocument, endPrefixMapping, fatalError, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warningMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ContentHandler
declaration
-
Field Details
-
DTD_PUBLIC_ID
-
DTD_PUBLIC_CS_ID
-
DTD_RESOURCE_NAME
-
CHECKSTYLE_PACKAGES
Name of default checkstyle package names resource file. The file must be in the classpath.- See Also:
-
PACKAGE_ELEMENT_NAME
-
packageStack
-
packageNames
-
-
Constructor Details
-
PackageNamesLoader
Creates a newPackageNamesLoaderinstance.- Throws:
ParserConfigurationException- if an error occursSAXException- if an error occurs
-
-
Method Details
-
startElement
- Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler
-
getPackageName
Creates a full package name from the package names on the stack.- Returns:
- the full name of the current package.
-
endElement
- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler
-
getPackageNames
Returns the set of package names, compiled from all checkstyle_packages.xml files found on the given class loaders classpath.- Parameters:
classLoader- the class loader for loading the checkstyle_packages.xml files.- Returns:
- the set of package names.
- Throws:
CheckstyleException- if an error occurs.
-
processFile
private static void processFile(URL packageFile, PackageNamesLoader namesLoader) throws SAXException, CheckstyleException Reads the file provided and parses it with package names loader.- Parameters:
packageFile- file from packagenamesLoader- package names loader- Throws:
SAXException- if an error while parsing occursCheckstyleException- if unable to open file
-
createIdToResourceNameMap
-