java.lang.Object
gov.nist.secauto.metaschema.databind.io.xml.MetaschemaXmlReader
All Implemented Interfaces:
IParsingContext<org.codehaus.stax2.XMLEventReader2,IXmlProblemHandler>, IXmlParsingContext

public class MetaschemaXmlReader extends Object implements IXmlParsingContext
  • Constructor Details

    • MetaschemaXmlReader

      public MetaschemaXmlReader(@NonNull org.codehaus.stax2.XMLEventReader2 reader)
      Construct a new Module-aware XML parser using the default problem handler.
      Parameters:
      reader - the XML reader to parse with
      See Also:
    • MetaschemaXmlReader

      public MetaschemaXmlReader(@NonNull org.codehaus.stax2.XMLEventReader2 reader, @NonNull IXmlProblemHandler problemHandler)
      Construct a new Module-aware parser.
      Parameters:
      reader - the XML reader to parse with
      problemHandler - the problem handler implementation to use
  • Method Details

    • readItem

      public <ITEM> ITEM readItem(@NonNull IBoundObject item, @NonNull IBoundInstance<ITEM> instance, @NonNull StartElement start) throws IOException
      Throws:
      IOException
    • getReader

      public org.codehaus.stax2.XMLEventReader2 getReader()
      Description copied from interface: IParsingContext
      The parser used for reading data associated with the supported format.
      Specified by:
      getReader in interface IParsingContext<org.codehaus.stax2.XMLEventReader2,IXmlProblemHandler>
      Returns:
      the parser
    • getProblemHandler

      Description copied from interface: IParsingContext
      A handler that provides callbacks used to resolve parsing issues.
      Specified by:
      getProblemHandler in interface IParsingContext<org.codehaus.stax2.XMLEventReader2,IXmlProblemHandler>
      Returns:
      the configured handler
    • read

      @NonNull public <CLASS> CLASS read(@NonNull IBoundDefinitionModelComplex definition) throws IOException
      Parses XML into a bound object based on the provided definition.

      Parses the XMLStreamConstants.START_DOCUMENT, any processing instructions, and the element.

      Specified by:
      read in interface IXmlParsingContext
      Type Parameters:
      CLASS - the returned object type
      Parameters:
      definition - the definition describing the element data to read
      Returns:
      the parsed object
      Throws:
      IOException - if an error occurred while parsing the input
    • readFlagInstances

      protected void readFlagInstances(@NonNull IBoundDefinitionModelComplex targetDefinition, @NonNull IBoundObject targetObject, @NonNull StartElement start) throws IOException, XMLStreamException
      Read the XML attribute data described by the targetDefinition and apply it to the provided targetObject.
      Parameters:
      targetDefinition - the Module definition that describes the syntax of the data to read
      targetObject - the Java object that data parsed by this method will be stored in
      start - the containing XML element that was previously parsed
      Throws:
      IOException - if an error occurred while parsing the input
      XMLStreamException - if an error occurred while parsing XML events
    • readModelInstances

      protected void readModelInstances(@NonNull IBoundDefinitionModelAssembly targetDefinition, @NonNull IBoundObject targetObject) throws IOException
      Read the XML element data described by the targetDefinition and apply it to the provided targetObject.
      Parameters:
      targetDefinition - the Module definition that describes the syntax of the data to read
      targetObject - the Java object that data parsed by this method will be stored in
      Throws:
      IOException - if an error occurred while parsing the input
    • isNextInstance

      protected boolean isNextInstance(@NonNull IBoundInstanceModel<?> targetInstance) throws XMLStreamException
      Determine if the next data to read corresponds to the next model instance.
      Parameters:
      targetInstance - the model instance that describes the syntax of the data to read
      Returns:
      true if the Module instance needs to be parsed, or false otherwise
      Throws:
      XMLStreamException - if an error occurred while parsing XML events
    • readItems

      public <T> boolean readItems(@NonNull IBoundInstanceModel<T> instance, @NonNull IBoundObject parentObject, boolean parseGrouping) throws IOException
      Read the data associated with the instance and apply it to the provided parentObject.
      Specified by:
      readItems in interface IXmlParsingContext
      Type Parameters:
      T - the item Java type
      Parameters:
      instance - the instance to parse data for
      parentObject - the Java object that data parsed by this method will be stored in
      parseGrouping - if true parse the instance's grouping element or false otherwise
      Returns:
      true if the instance was parsed, or false if the data did not contain information for this instance
      Throws:
      IOException - if an error occurred while parsing the input