Class XmlMetaReader

  • public final class XmlMetaReader
    extends Object
    Class having utilities required to read module details from an XML metadata file of a module. This class is used by plugins that need load of metadata from XML files.
    • Constructor Detail

      • XmlMetaReader

        private XmlMetaReader()
        Do no allow XmlMetaReader instances to be created.
    • Method Detail

      • readAllModulesIncludingThirdPartyIfAny

        public static List<ModuleDetailsreadAllModulesIncludingThirdPartyIfAny​(String... thirdPartyPackages)
        Utility to load all the metadata files present in the checkstyle JAR including third parties' module metadata files. checkstyle metadata files are grouped in a folder hierarchy similar to that of their corresponding source files. Third party(e.g. SevNTU Checks) metadata files are prefixed with checkstylemeta- to their file names.
        thirdPartyPackages - fully qualified third party package names(can be only a hint, e.g. for SevNTU it can be com.github.sevntu / com.github)
        list of module details found in the classpath satisfying the above conditions
        IllegalStateException - if there was a problem reading the module metadata files
      • populateModule

        private static void populateModule​(Element mod,
                                           ModuleDetails moduleDetails)
        Populate the module detail object from XML metadata.
        mod - root XML document element
        moduleDetails - module detail object, which is to be updated
      • createProperties

        private static List<ModulePropertyDetailscreateProperties​(Element properties)
        Create module property details from the XML metadata.
        properties - parent document element which contains property's metadata
        list of property details object created
      • getListContentByAttribute

        private static List<StringgetListContentByAttribute​(Element element,
                                                              String listParent,
                                                              String listOption,
                                                              String attribute)
        Utility to get the list contents by the attribute specified.
        element - doc element
        listParent - parent element of list
        listOption - child list element
        attribute - attribute key
        list of strings containing the XML list data
      • getDirectChildsByTag

        private static List<ElementgetDirectChildsByTag​(Element element,
                                                          String sTagName)
        Utility to get the children of an element by tag name.
        element - parent element
        sTagName - tag name of children required
        list of elements retrieved
      • getAttributeValue

        private static String getAttributeValue​(Element element,
                                                String attribute)
        Utility to get attribute value of an element.
        element - target element
        attribute - attribute key
        attribute value