Class XMLReader<T,I>
java.lang.Object
com.foursoft.harness.navext.runtime.io.read.XMLReader<T,I>
- Type Parameters:
T- The root class to deserializeI- The class to identify xml objects
A generic xml reader which includes the back references, id mapper and a simple event log.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionread(InputStream inputStream) Builds the complete JAXB tree structure of an xml stream.Builds the complete JAXB tree structure of an xml file.readModel(InputStream inputStream) Builds the complete JAXB tree structure of an xml stream.
-
Constructor Details
-
XMLReader
It will log warnings, errors and fatal validation events to the slf4j, see @ValidationEventLogger- Parameters:
rootTypeClass- the root class of the jaxb modelidentifiableClass- the class of the identifiable elementidMapper- 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 modelidentifiableClass- the class of the identifiable elementidMapper- the mapper function to get the id of each elementvalidationEventConsumer- a consumer for validation events- See Also:
-
-
Method Details
-
read
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
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
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
-