java.lang.Object
com.foursoft.harness.navext.runtime.io.read.XMLReader<T,I>
Type Parameters:
T - The root class to deserialize
I - The class to identify xml objects

public class XMLReader<T,I> extends Object
A generic xml reader which includes the back references, id mapper and a simple event log.
  • Constructor Details

    • XMLReader

      public XMLReader(Class<T> rootTypeClass, Class<I> identifiableClass, Function<I,String> idMapper)
      It will log warnings, errors and fatal validation events to the slf4j, see @ValidationEventLogger
      Parameters:
      rootTypeClass - the root class of the jaxb model
      identifiableClass - the class of the identifiable element
      idMapper - the mapper function to get the id of each element
      See Also:
    • XMLReader

      public XMLReader(Class<T> rootTypeClass, Class<I> identifiableClass, Function<I,String> idMapper, Consumer<jakarta.xml.bind.ValidationEvent> validationEventConsumer)
      Parameters:
      rootTypeClass - the root class of the jaxb model
      identifiableClass - the class of the identifiable element
      idMapper - the mapper function to get the id of each element
      validationEventConsumer - a consumer for validation events
      See Also:
  • Method Details

    • read

      public T read(String filename)
      Builds the complete JAXB tree structure of an xml file. Uses the already registered event consumer for validation events
      Parameters:
      filename - the path name of the XML file.
      Returns:
      the JAXB object structure representing the xml file
      Throws:
      XMLIOException - in case of an IOException
    • read

      public T read(InputStream inputStream)
      Builds the complete JAXB tree structure of an xml stream. Uses the already registered event consumer for validation events
      Parameters:
      inputStream - the input stream to read from
      Returns:
      the JAXB object structure representing the xml file.
      Throws:
      XMLIOException - in case of a JAXBException
    • readModel

      public JaxbModel<T,I> readModel(InputStream inputStream)
      Builds the complete JAXB tree structure of an xml stream. Uses the already registered event consumer for validation events
      Parameters:
      inputStream - the input stream to read from
      Returns:
      the JAXB object structure representing the xml file.
      Throws:
      XMLIOException - in case of a JAXBException