public class XmlDataImporter extends PropertyDataImporter
<ArbitraryRoot>
<EntityName primitivePropertyName="... value ...">
<anotherPrimitivePropertyName>... value ...</anotherPrimitivePropertyName>
<entityProperty>
<ReferencedEntityName>
... properties ...
</ReferencedEntityName>
</entityProperty>
<anotherEntityProperty>
<ReferencedEntityName reference="true">
... unique properties necessary to identify the entity in the EntityRegistration ...
</ReferencedEntityName>
</anotherEntityProperty>
<embeddedProperty>
... properties ...
</embeddedProperty>
</EntityName>
<EntityName>...</EntityName>
...
</ArbitraryRoot>
| Constructor and Description |
|---|
XmlDataImporter()
Creates a new instance of
XmlDataImporter. |
XmlDataImporter(GeneratorContext context,
EntityRegistration entityRegistration) |
| Modifier and Type | Method and Description |
|---|---|
protected <E> void |
importAttribute(XMLEventReader reader,
StartElement element,
E entity,
Map<String,? extends Property<? super E,?>> properties,
Attribute attribute)
Imports an attribute from XML.
|
protected <E> void |
importElement(XMLEventReader reader,
StartElement entityElement,
E entity,
Map<String,? extends Property<? super E,?>> properties,
StartElement propertyElement)
Imports an element from XML for an entity.
|
protected <E,T> void |
importEmbeddedProperty(XMLEventReader reader,
StartElement propertyElement,
E entity,
EmbeddedProperty<? super E,T> property)
Imports a property which contains an
embedded object from XML. |
protected <E> void |
importEntity(XMLEventReader reader,
StartElement element,
EntityClass<E> classDescription,
boolean reference,
Consumer<E> onImport)
Imports an entity and invokes a function as soon the entity is imported.
|
protected <E,T> void |
importEntityProperty(XMLEventReader reader,
E entity,
EntityProperty<E,T> property)
Imports a property which contains an
entity from XML. |
List<Object> |
importFile(DataFile file)
Imports all entites found in the given XML file.
|
protected <E,T> void |
importPluralProperty(XMLEventReader reader,
E entity,
PluralProperty<? super E,?,T> property)
Imports a
Collection or Map property from XML. |
protected <E,T> void |
importPrimitiveProperty(XMLEventReader reader,
E entity,
PrimitiveProperty<E,T> property)
Imports the given property from XML.
|
protected <E,T> void |
importPrimitiveProperty(XMLEventReader reader,
E entity,
PrimitiveProperty<E,T> property,
T value)
Imports the given value for the given property from XML.
|
protected <E> void |
importProperties(XMLEventReader reader,
StartElement element,
Map<String,? extends Property<? super E,?>> properties,
E entity)
Imports the given set of properties from the XML file for the given entity.
|
protected <E,T> void |
importProperty(XMLEventReader reader,
StartElement element,
Property<? super E,T> property,
E entity)
Imports one property from the XML file.
|
addConverter, findConverterpublic XmlDataImporter()
XmlDataImporter.
Uses its own GeneratorContext and EntityRegistration, so only use as standalone importer.@ConstructorProperties(value={"context","entityRegistration"}) @Generated(value="lombok") public XmlDataImporter(GeneratorContext context, EntityRegistration entityRegistration)
protected <E> void importAttribute(XMLEventReader reader, StartElement element, E entity, Map<String,? extends Property<? super E,?>> properties, Attribute attribute) throws XMLStreamException
E - the type of the imported entityreader - the XML streamelement - the element of the entityentity - the imported entityproperties - all properties known for the entity typeattribute - the imported attributeXMLStreamException - if the XML is invalidprotected <E> void importElement(XMLEventReader reader, StartElement entityElement, E entity, Map<String,? extends Property<? super E,?>> properties, StartElement propertyElement) throws XMLStreamException
E - the type of the imported entityreader - the XML streamentityElement - the element of the entityentity - the imported entityproperties - all properties known for the entity typepropertyElement - the imported elementXMLStreamException - if the XML is invalidprotected <E,T> void importEmbeddedProperty(XMLEventReader reader, StartElement propertyElement, E entity, EmbeddedProperty<? super E,T> property) throws XMLStreamException
embedded object from XML.E - the type of the current entityT - the type of the embedded objectreader - the XML streampropertyElement - the current element that started the propertyentity - the imported entityproperty - the imported property of the entityXMLStreamException - if the XML is invalidprotected <E> void importEntity(XMLEventReader reader, StartElement element, EntityClass<E> classDescription, boolean reference, Consumer<E> onImport) throws XMLStreamException
reference, the given handler is invoked as soon the entity is
registered.E - the type of the imported entityreader - the XML streamelement - the element that started the importclassDescription - the description of the type of the entityreference - indicates that the imported entity is just a reference to an existing entityonImport - the handler to call as soon as the entity is foundXMLStreamException - if there is an error during importprotected <E,T> void importEntityProperty(XMLEventReader reader, E entity, EntityProperty<E,T> property) throws XMLStreamException
entity from XML.E - the type of the current entityT - the type of the property (the target entity)reader - the XML streamentity - the imported entityproperty - the imported property of the entityXMLStreamException - if the XML is invalidpublic List<Object> importFile(DataFile file) throws IOException, DataImportException
file - the fileIOException - if there was a problem when accessing the fileDataImportException - if the XML or its contents was invalidprotected <E,T> void importPluralProperty(XMLEventReader reader, E entity, PluralProperty<? super E,?,T> property) throws XMLStreamException
Collection or Map property from XML.E - the type of the current entityT - the type of the embedded objectreader - the XML streamentity - the imported entityproperty - the imported property of the entityXMLStreamException - if the XML is invalidprotected <E,T> void importPrimitiveProperty(XMLEventReader reader, E entity, PrimitiveProperty<E,T> property) throws XMLStreamException
importPrimitiveProperty(XMLEventReader, Object, PrimitiveProperty, Object).reader - the XML streamentity - the imported entityproperty - the imported propertyXMLStreamException - if the XML is invalidprotected <E,T> void importPrimitiveProperty(XMLEventReader reader, E entity, PrimitiveProperty<E,T> property, T value)
reader - the XML streamentity - the imported entityproperty - the imported propertyvalue - the imported valueprotected <E> void importProperties(XMLEventReader reader, StartElement element, Map<String,? extends Property<? super E,?>> properties, E entity) throws XMLStreamException
E - the type of the entityreader - the XML streamelement - the element of the entityproperties - all properties known for the entity typeentity - the entity to importXMLStreamException - if the XML is invalidprotected <E,T> void importProperty(XMLEventReader reader, StartElement element, Property<? super E,T> property, E entity) throws XMLStreamException
E - the type of the imported entityreader - the XML streamelement - the element that triggered the import of the propertyproperty - the imported propertyentity - the imported entityXMLStreamException - if the XML is invalidCopyright © 2020 fastnate.org. All rights reserved.