public class XmlInspector extends BaseXmlInspector
inspection-result-1.0.xsd
-compliant files (such as
metawidget-metadata.xml
).
XmlInspector is a very simple Inspector: it takes as its input XML in the same format that
Inspectors usually output. It can be useful for declaring 'ad hoc' UI entities that do not map to
any Java class, as well as for declaring UI-specific attributes for existing Java classes (ie. if
you prefer not to use annotations, or if you want to introduce additional 'virtual' properties).
Some attributes accept multiple values, such as lookup
. These can be
supplied as a comma-separated string. The values will be trimmed for whitespace. If the values
themselves contain commas, they can be escaped with the \
character.
Note when using XmlInspector
you should still try to avoid duplicating UI metadata
that already exists in other parts of your application. For example, if you are also using
PropertyTypeInspector
in your CompositeInspector
there is no need to
duplicate the names and types of properties. Also, if you are using
PropertyTypeInspector
and XmlInspector
together, please read the
JavaDoc for restrictAgainstObject
.
XmlInspector
does add some niceties beyond inspection-result-1.0.xsd
.
It supports an extends
attribute to allow one entity
to inherit from
another. It also supports nested entities, for example:
<entity type="Person">
<property name="surname"/>
<property name="address">
<property name="street"/>
<property name="postcode"/>
</property>
</entity>
mLog
Constructor and Description |
---|
XmlInspector(XmlInspectorConfig config)
Constructs an XmlInspector.
|
Modifier and Type | Method and Description |
---|---|
protected String |
getExtendsAttribute()
The attribute on top-level elements that identifies a superclass relationship (if any).
|
protected Map<String,String> |
inspectAction(Element toInspect)
Inspect the given Element and return a Map of attributes if it is an action.
|
protected Map<String,String> |
inspectProperty(Element toInspect)
Inspect the given Element and return a Map of attributes if it is a property.
|
getDocumentElement, getDocumentElement, getNameAttribute, getReferenceAttribute, getTopLevelTypeAttribute, getTypeAttribute, inspect, inspectAsDom, inspectTrait, inspectTraits, inspectTraitSiblings, preprocessDocument, traverse, traverseFromTopLevelTypeToNamedChildren
public XmlInspector(XmlInspectorConfig config)
Note XmlInspector requires a config. It does not have a default constructor, because the
XmlInspectorConfig must be externally configured using setResourceResolver
to
support resolving resources from non-standard locations (such as WEB-INF
protected String getExtendsAttribute()
BaseXmlInspector
getExtendsAttribute
in class BaseXmlInspector
protected Map<String,String> inspectProperty(Element toInspect)
BaseXmlInspector
It is this method's responsibility to decide whether the given Element does, in fact, qualify as a 'property' - based on its own rules. Does nothing by default.
inspectProperty
in class BaseXmlInspector
toInspect
- DOM element to inspectprotected Map<String,String> inspectAction(Element toInspect)
BaseXmlInspector
It is this method's responsibility to decide whether the given Element does, in fact, qualify as an 'action' - based on its own rules. Does nothing by default.
inspectAction
in class BaseXmlInspector
toInspect
- DOM element to inspectCopyright © 2015. All Rights Reserved.