Class XsdParserCore

  • Direct Known Subclasses:
    XsdParser, XsdParserJar

    public abstract class XsdParserCore
    extends java.lang.Object
    • Field Detail

      • parseMappers

        static java.util.Map<java.lang.String,​ConfigEntryData> parseMappers
        A Map object that contains a parse function to each XsdAbstractElement concrete type supported by this mapper, this way based on the concrete XsdAbstractElement tag the according parse method can be invoked.
      • xsdTypesToJava

        private static java.util.Map<java.lang.String,​java.lang.String> xsdTypesToJava
        A Map object that contains the all the XSD types and their respective types in the Java language.
      • parseElements

        public java.util.Map<java.lang.String,​java.util.List<ReferenceBase>> parseElements
        A List which contains all the top elements parsed by this class.
      • unsolvedElements

        private java.util.Map<java.lang.String,​java.util.List<UnsolvedReference>> unsolvedElements
        A List of UnsolvedReference elements that weren't solved. This list is consulted after all the elements are parsed in order to find if there is any suitable parsed element to replace the unsolved element.
      • parserUnsolvedElementsMap

        private java.util.List<UnsolvedReferenceItem> parserUnsolvedElementsMap
        A List containing all the elements that even after parsing all the elements on the file, don't have a suitable object to replace the reference. This list can be consulted after the parsing process to assert if there is any missing information in the XSD file.
      • schemaLocations

        java.util.List<java.lang.String> schemaLocations
        A List containing the paths of files that were present in either XsdInclude or XsdImport objects that are present in the original or subsequent files. These paths are stored to be parsed as well, the parsing process only ends when all the files present in this List are parsed.
      • schemaLocationsMap

        java.util.Map<java.lang.String,​java.lang.String> schemaLocationsMap
      • currentFile

        protected java.lang.String currentFile
    • Constructor Detail

      • XsdParserCore

        public XsdParserCore()
    • Method Detail

      • isXsdSchema

        boolean isXsdSchema​(org.w3c.dom.Node node)
        Verifies if a given Node object, i.e. node is a xsd:schema node.
        Parameters:
        node - The node to verify.
        Returns:
        True if the node is a xsd:schema or xs:schema. False otherwise.
      • resolveRefs

        void resolveRefs()
        This method resolves all the remaining UnsolvedReference objects present after all the elements are parsed. It starts by iterating all parseElements and inserting all the parsed elements with a name attribute in the concreteElementsMap variable. After that it iterates on the unsolvedElements list in order to find if any of the unsolvedReferences can be solved by replacing the unsolvedElement by its matching NamedConcreteElement object, present in the concreteElementsMap. The UnsolvedReference objects matches a NamedConcreteElement object by having its ref attribute with the same value as the name attribute of the NamedConcreteElement.
      • resolveOtherNamespaceRefs

        private void resolveOtherNamespaceRefs()
      • replaceUnsolvedImportedReference

        private void replaceUnsolvedImportedReference​(java.util.Map<java.lang.String,​java.util.List<NamedConcreteElement>> concreteElementsMap,
                                                      UnsolvedReference unsolvedReference,
                                                      java.lang.String fileName)
      • cleanPath

        private java.lang.String cleanPath​(java.lang.String pathValue)
        Clean the path by useless ../ example /A/B/../B/C into /A/B/C
      • resolveInnerRefs

        private void resolveInnerRefs()
      • replaceUnsolvedReference

        private void replaceUnsolvedReference​(java.util.Map<java.lang.String,​java.util.List<NamedConcreteElement>> concreteElementsMap,
                                              UnsolvedReference unsolvedReference,
                                              java.lang.String fileName)
        Replaces a single UnsolvedReference object, with the respective NamedConcreteElement object. If there isn't a NamedConcreteElement object to replace the UnsolvedReference object, information is stored informing the user of this Project of the occurrence.
        Parameters:
        concreteElementsMap - The map containing all named concreteElements.
        unsolvedReference - The unsolved reference to solve.
      • getUnsolvedReferences

        public java.util.List<UnsolvedReferenceItem> getUnsolvedReferences()
        Returns:
        The List of UnsolvedReferenceItem that represent all the objects with a reference that couldn't be solved.
      • getResultXsdElements

        public java.util.stream.Stream<XsdElement> getResultXsdElements()
        Returns:
        A list of all the top level parsed xsd:elements by this class. It doesn't return any other elements apart from xsd:elements. To access the whole element tree use getResultXsdSchemas()
      • getResultXsdSchemas

        public java.util.stream.Stream<XsdSchema> getResultXsdSchemas()
        Returns:
        A List of all the XsdSchema elements parsed by this class. You can use the XsdSchema instances to navigate through the whole element tree.
      • addUnsolvedReference

        public void addUnsolvedReference​(UnsolvedReference unsolvedReference)
        Adds an UnsolvedReference object to the unsolvedElements list which should be solved at a later time in the parsing process.
        Parameters:
        unsolvedReference - The unsolvedReference to add to the unsolvedElements list.
      • addFileToParse

        public void addFileToParse​(java.lang.String schemaLocation)
        Adds a new file to the parsing queue. This new file appears by having xsd:import or xsd:include tags in the original file to parse.
        Parameters:
        schemaLocation - A new file path of another XSD file to parse.
      • getXsdTypesToJava

        public static java.util.Map<java.lang.String,​java.lang.String> getXsdTypesToJava()
      • getParseMappers

        public static java.util.Map<java.lang.String,​ConfigEntryData> getParseMappers()
      • addParsedElement

        public void addParsedElement​(ReferenceBase wrappedElement)
      • updateConfig

        static void updateConfig​(ParserConfig config)
      • isRelativePath

        protected boolean isRelativePath​(java.lang.String filePath)
      • getDocumentBuilder

        protected javax.xml.parsers.DocumentBuilder getDocumentBuilder()
                                                                throws javax.xml.parsers.ParserConfigurationException
        Throws:
        javax.xml.parsers.ParserConfigurationException