Class XmlMetadataParser<T extends GenericXmlMetadata>


  • public class XmlMetadataParser<T extends GenericXmlMetadata>
    extends Object
    SAX parser for XML metadata. This is because DOM parsing would consume more time and resources for large metadata files.
    • Field Detail

      • fileClass

        protected Class fileClass
      • schemaLocations

        protected String[] schemaLocations
      • schemaBasePath

        protected String schemaBasePath
    • Constructor Detail

      • XmlMetadataParser

        public XmlMetadataParser​(Class metadataClass)
        Constructs an instance of XmlMetadataParser for the given metadata class.
        Parameters:
        metadataClass - The class of metadata (it should be derived from XmlMetadata).
    • Method Detail

      • inferType

        protected ProductData inferType​(String elementName,
                                        String value)
        Tries to infer the type of the element, based on the available XSD schema definition. If no schema definition exist, the type will always be ProductData.ASCII.
        Parameters:
        elementName - The name of the XML element.
        value - The value of the XML element.
        Returns:
        An instance of ProductData wrapping the element value.
      • shouldValidateSchema

        protected boolean shouldValidateSchema()
        Indicates if the XSD validation should be performed. Override this in derived classes to enable schema validation.
        Returns:
        The default implementation always returns false. In a derived class, true would mean that the XML schema validation should be performed.
      • setSchemaBasePath

        protected void setSchemaBasePath​(String schemaBasePath)
        Sets the location of the schema base path that should be used for XSD schema validation.
        Parameters:
        schemaBasePath - The schema base path.
      • setSchemaLocations

        protected void setSchemaLocations​(String[] schemaLocations)
        Sets the location(s) of the XSD schema(s) that should be used for XSD schema validation.
        Parameters:
        schemaLocations - An array of schema locations.