public class XMLPropertyDomParser extends AbstractPropertyContainerUpdater implements uk.ac.ed.epcc.webapp.Contexed, PropertyContainerDomParser
PropertyContainerDomParser for data in an XML format.
Normally this is included into a target parser by composition. The class of the target parser is passed to the constructor to allow configuration by reflection and annotations.
Properties are extracted from each XML record using an Xpath expression to
identify the fragment to parse and a DomValueParser to perform the parse.
Target classes can pre-define properties and use annotations to set the xpath and parser
values.
New properties can be defined by setting: tag.prop.name=type where type is one of string, date or number.
The xpath target is set using tag.prop-name.xpath
Namespaces for use in these Xpaths can be defined using tag.namespace.prefix=uri
The DomValueParser can be set using tag.prop-name.parser
though if this property is not set a default parser is generated using the schema type or the
target type of the property.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
USE_SCHEMA_FEATURE_PREFIX |
| Constructor and Description |
|---|
XMLPropertyDomParser(uk.ac.ed.epcc.webapp.AppContext context,
java.lang.Class target,
javax.xml.namespace.NamespaceContext ns,
java.lang.String default_schema_name)
Constructs a new
XMLPropertyDomParser |
| Modifier and Type | Method and Description |
|---|---|
java.util.Set<PropertyTag> |
defines(org.w3c.dom.Node record)
Return the set of PropertyTags that may be defined by the record Node
No attempt is made to parse the actual content so this method may be used on a
template document where no actual values are specified.
|
java.lang.String |
endParse()
End a batch parse this de-allocates any temporary storage and
and perform any final operations.
|
javax.xml.parsers.DocumentBuilder |
getBuilder() |
uk.ac.ed.epcc.webapp.AppContext |
getContext() |
<T> DomValueParser<? extends T> |
getParser(java.lang.Class<T> clazz,
org.w3c.dom.Node n) |
<T> DomValueParser<? extends T> |
getParser(org.w3c.dom.TypeInfo info,
org.w3c.dom.Node n) |
PropertyFinder |
initFinder(uk.ac.ed.epcc.webapp.AppContext context,
PropertyFinder prev,
java.lang.String mode)
Generate a PropertyFinder that will find any PropertyTag generated by this class.
|
boolean |
parse(PropertyMap map,
org.w3c.dom.Node record)
Parse a Dom representation of a UsageRecord in an XML format.
|
void |
startParse(PropertyContainer defaults)
Start a batch parse.
|
getDerivedProperties, modifyDefaultTableSpecification, uniqueclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetDerivedProperties, modifyDefaultTableSpecificationpublic static final java.lang.String USE_SCHEMA_FEATURE_PREFIX
public XMLPropertyDomParser(uk.ac.ed.epcc.webapp.AppContext context,
java.lang.Class target,
javax.xml.namespace.NamespaceContext ns,
java.lang.String default_schema_name)
XMLPropertyDomParsercontext - AppContexttarget - target class to query for propertiesdefault_schema_name - public java.lang.String endParse()
PropertyContainerUpdaterendParse in interface PropertyContainerUpdaterendParse in class AbstractPropertyContainerUpdaterpublic uk.ac.ed.epcc.webapp.AppContext getContext()
getContext in interface uk.ac.ed.epcc.webapp.Contexedpublic final PropertyFinder initFinder(uk.ac.ed.epcc.webapp.AppContext context, PropertyFinder prev, java.lang.String mode)
PropertyContainerUpdaterAll properties defined at run-time should have their PropertyTag objects constructed by the time the first call to this method returns. As some parsers properties will generate different things depending on the other properties already in scope this method is passed a PropertyFinder for any properties that may already be in scope. This will include any default parameters specified when the data was uploaded and any properties generated from the database meta-data. Though it is perfectly legal to return a PropertyFinder that returns a superset of the generated properties the only requirement is that the returned finder can find any property that this classes parse method may actually generate values for. So Normally the contents of the super-finder are not included in the result unless these values are actually generated by the parse. If values are generated then a MultiFinder can be populated with the PropertyRegistrys from the generated properties
initFinder in interface PropertyContainerUpdaterprev - PropertyFinder for the higher levels in the call chain.mode - String name of the destination table in case per-table customisation is neededpublic void startParse(PropertyContainer defaults) throws java.lang.Exception
PropertyContainerUpdaterstartParse in interface PropertyContainerUpdaterstartParse in class AbstractPropertyContainerUpdaterjava.lang.Exceptiondefaults - properties constant for this accounting run.public java.util.Set<PropertyTag> defines(org.w3c.dom.Node record)
PropertyContainerDomParserdefines in interface PropertyContainerDomParserpublic boolean parse(PropertyMap map, org.w3c.dom.Node record) throws AccountingParseException
PropertyContainerDomParserparse in interface PropertyContainerDomParserAccountingParseExceptionmap - PropertyMap to add quantitiespublic <T> DomValueParser<? extends T> getParser(org.w3c.dom.TypeInfo info, org.w3c.dom.Node n)
public <T> DomValueParser<? extends T> getParser(java.lang.Class<T> clazz, org.w3c.dom.Node n)
public javax.xml.parsers.DocumentBuilder getBuilder()