Class MetaschemaXmlReader

    • Constructor Detail

      • 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:
        DefaultXmlProblemHandler
      • 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 Detail

      • readFlagInstances

        protected void readFlagInstances​(@NonNull
                                         IClassBinding targetDefinition,
                                         @NonNull
                                         Object 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
                                          IAssemblyClassBinding targetDefinition,
                                          @NonNull
                                          Object targetObject,
                                          @NonNull
                                          StartElement start)
                                   throws IOException,
                                          XMLStreamException
        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
        start - the XML element start and attribute data previously parsed
        Throws:
        IOException - if an error occurred while parsing the input
        XMLStreamException - if an error occurred while parsing XML events
      • readFieldValue

        protected void readFieldValue​(@NonNull
                                      IFieldClassBinding targetDefinition,
                                      @NonNull
                                      Object targetObject)
                               throws IOException
        Read the XML element and text 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
                                         IBoundNamedModelInstance 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
      • readModelInstanceValues

        protected boolean readModelInstanceValues​(@NonNull
                                                  IBoundNamedModelInstance instance,
                                                  @NonNull
                                                  Object parentObject,
                                                  @NonNull
                                                  StartElement start)
                                           throws IOException,
                                                  XMLStreamException
        Read the data associated with the instance and apply it to the provided parentObject.
        Parameters:
        instance - the instance to parse data for
        parentObject - the Java object that data parsed by this method will be stored in
        start - the XML element start and attribute data previously parsed
        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
        XMLStreamException - if an error occurred while parsing XML events
      • readModelInstanceValue

        @Nullable
        protected Object readModelInstanceValue​(@NonNull
                                                IBoundAssemblyInstance instance,
                                                @NonNull
                                                Object parentObject,
                                                @NonNull
                                                StartElement start)
                                         throws XMLStreamException,
                                                IOException
        Read the XML data associated with the instance and apply it to the provided parentObject.
        Parameters:
        instance - the instance to parse data for
        parentObject - the Java object that data parsed by this method will be stored in
        start - the XML element start and attribute data previously parsed
        Returns:
        the Java object read, or null if no data was read
        Throws:
        IOException - if an error occurred while parsing the input
        XMLStreamException - if an error occurred while parsing XML events
      • readModelInstanceValue

        @NonNull
        protected Object readModelInstanceValue​(@NonNull
                                                IBoundFieldInstance instance,
                                                @NonNull
                                                Object parentObject,
                                                @NonNull
                                                StartElement start)
                                         throws XMLStreamException,
                                                IOException
        Revise

        Reads an individual XML item from the XML stream.

        Parameters:
        instance - the instance to parse data for
        parentObject - the Java object that data parsed by this method will be stored in
        start - the XML element start and attribute data previously parsed
        Returns:
        the Java object read, or null if no data was read
        Throws:
        IOException - if an error occurred while parsing the input
        XMLStreamException - if an error occurred while parsing XML events