Class MetaschemaXmlReader
java.lang.Object
gov.nist.secauto.metaschema.databind.io.xml.MetaschemaXmlReader
- All Implemented Interfaces:
IParsingContext<org.codehaus.stax2.XMLEventReader2,,IXmlProblemHandler> IXmlParsingContext
Supports reading XML-based Metaschema module instances.
-
Constructor Summary
ConstructorsConstructorDescriptionMetaschemaXmlReader(org.codehaus.stax2.XMLEventReader2 reader, URI source) Construct a new Module-aware XML parser using the default problem handler.MetaschemaXmlReader(org.codehaus.stax2.XMLEventReader2 reader, URI source, IXmlProblemHandler problemHandler) Construct a new Module-aware parser. -
Method Summary
Modifier and TypeMethodDescriptionA handler that provides callbacks used to resolve parsing issues.org.codehaus.stax2.XMLEventReader2The parser used for reading data associated with the supported format.Get the URI-based resource read by this parser.protected booleanisNextInstance(IBoundInstanceModel<?> targetInstance) Determine if the next data to read corresponds to the next model instance.<CLASS> CLASSread(IBoundDefinitionModelComplex definition) Parses XML into a bound object based on the provideddefinition.protected voidreadFlagInstances(IBoundDefinitionModelComplex targetDefinition, IBoundObject targetObject, StartElement start) Read the XML attribute data described by thetargetDefinitionand apply it to the providedtargetObject.<T> booleanreadItems(IBoundInstanceModel<T> instance, IBoundObject parentObject, boolean parseGrouping) Read the data associated with theinstanceand apply it to the providedparentObject.protected voidreadModelInstances(IBoundDefinitionModelAssembly targetDefinition, IBoundObject targetObject) Read the XML element data described by thetargetDefinitionand apply it to the providedtargetObject.
-
Constructor Details
-
MetaschemaXmlReader
Construct a new Module-aware XML parser using the default problem handler.- Parameters:
reader- the XML reader to parse withsource- the resource being parsed- See Also:
-
MetaschemaXmlReader
public MetaschemaXmlReader(@NonNull org.codehaus.stax2.XMLEventReader2 reader, @NonNull URI source, @NonNull IXmlProblemHandler problemHandler) Construct a new Module-aware parser.- Parameters:
reader- the XML reader to parse withsource- the resource being parsedproblemHandler- the problem handler implementation to use
-
-
Method Details
-
getReader
Description copied from interface:IParsingContextThe parser used for reading data associated with the supported format.- Specified by:
getReaderin interfaceIParsingContext<org.codehaus.stax2.XMLEventReader2,IXmlProblemHandler> - Returns:
- the parser
-
getSource
Description copied from interface:IParsingContextGet the URI-based resource read by this parser.- Specified by:
getSourcein interfaceIParsingContext<org.codehaus.stax2.XMLEventReader2,IXmlProblemHandler> - Returns:
- the resource URI
-
getProblemHandler
Description copied from interface:IParsingContextA handler that provides callbacks used to resolve parsing issues.- Specified by:
getProblemHandlerin interfaceIParsingContext<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 provideddefinition.Parses the
XMLStreamConstants.START_DOCUMENT, any processing instructions, and the element.- Specified by:
readin interfaceIXmlParsingContext- 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 thetargetDefinitionand apply it to the providedtargetObject.- Parameters:
targetDefinition- the Module definition that describes the syntax of the data to readtargetObject- the Java object that data parsed by this method will be stored instart- the containing XML element that was previously parsed- Throws:
IOException- if an error occurred while parsing the inputXMLStreamException- 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 thetargetDefinitionand apply it to the providedtargetObject.- Parameters:
targetDefinition- the Module definition that describes the syntax of the data to readtargetObject- 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:
trueif the Module instance needs to be parsed, orfalseotherwise- 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 theinstanceand apply it to the providedparentObject.- Specified by:
readItemsin interfaceIXmlParsingContext- Type Parameters:
T- the item Java type- Parameters:
instance- the instance to parse data forparentObject- the Java object that data parsed by this method will be stored inparseGrouping- iftrueparse the instance's grouping element orfalseotherwise- Returns:
trueif the instance was parsed, orfalseif the data did not contain information for this instance- Throws:
IOException- if an error occurred while parsing the input
-