|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dsto.dfc.databeans.io.XmlDecodeContext
public class XmlDecodeContext
Stores context information (eg ID -> value mapping) during an XML decode
session. Also mediates decoding via decode(Element)
.
XmlDecoder clients receive an instance via
XmlDecoder.decode(XmlDecodeContext, Element)
.
Nested Class Summary | |
---|---|
static interface |
XmlDecodeContext.IdCallback
Callback interface for clients that wish to use forward references. |
Constructor Summary | |
---|---|
protected |
XmlDecodeContext(LazyElementMap xmlDecoders,
TypeMap textDecoders,
Map typeAliases)
|
Method Summary | |
---|---|
String |
aliasToType(String alias)
Map an alias to it's a type value if it has one. |
void |
callbackWithObjectForId(XmlDecodeContext.IdCallback callback,
org.jdom.Element element,
String id,
Object extraData)
Register a callback to be invoked when a value becomes available for a given ID. |
Object |
decode(org.jdom.Element element)
Mediates the decoding of an element. |
Class |
decodeType(String typeName)
Decode an encoded type into the original Class. |
protected void |
doPostDecode()
|
String |
getAliasType(String alias)
Get the type name for an alias. |
Object |
getProperty(Object name)
Get a custom property defined by setProperty(Object, Object) . |
TextDecoder |
getTextDecoder(Class type)
Get the text decoder for a given value type. |
Object |
getValue(String id)
Get a value registered with a given ID. |
XmlDecoder |
getXmlDecoder(String elementName)
Get the decoder registered for a given element type. |
void |
registerValue(org.jdom.Element element,
Object value)
Register a value for an ID if one is specified on an element. |
void |
registerValue(String id,
Object value)
Register a value with a given ID. |
protected void |
setProperties(Map properties)
Set all custom properties. |
void |
setProperty(Object name,
Object value)
Define a custom property that will be accessible during this session via getProperty(Object) . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected XmlDecodeContext(LazyElementMap xmlDecoders, TypeMap textDecoders, Map typeAliases)
Method Detail |
---|
protected void doPostDecode()
protected void setProperties(Map properties)
XmlInput
.
setProperty(Object, Object)
public void setProperty(Object name, Object value)
getProperty(Object)
.
XmlInput.setProperty(Object, Object)
public Object getProperty(Object name)
setProperty(Object, Object)
.
public Object decode(org.jdom.Element element) throws ClassNotFoundException, IllegalArgumentException
element
- The element to decode.
ClassNotFoundException
- if a class referenced by the element tree
is not found.
IllegalArgumentException
- if there is a logical error in the element
tree.public XmlDecoder getXmlDecoder(String elementName) throws IllegalArgumentException
decode(Element)
.
elementName
- The element name (eg from element.getName ()).
IllegalArgumentException
- if there is no decoder for the element.public TextDecoder getTextDecoder(Class type)
public Object getValue(String id) throws IllegalArgumentException
decode(Element)
.
id
- The value ID.
IllegalArgumentException
- if no value for ID.registerValue(String, Object)
public void registerValue(org.jdom.Element element, Object value)
decode(Element)
after invoking
an XmlDecoder, but a decoder may choose to call this as soon as it creates
its value so that any child decoders can reference it.
element
- The element. If the element has no "id" attribute, this
call does nothing.value
- The value to register.public void registerValue(String id, Object value) throws IllegalArgumentException
decode(Element)
.
id
- The ID.value
- The value.
IllegalArgumentException
- if ID is already in use by another
value.getValue(String)
public String getAliasType(String alias)
alias
- The alias.
aliasToType(String)
public String aliasToType(String alias)
getAliasType(String)
except it returns the parameter if no alias
mapping is found.
alias
- The alias/type name.
public Class decodeType(String typeName) throws ClassNotFoundException
ClassNotFoundException
XmlEncodeContext.encodeType(Class)
public void callbackWithObjectForId(XmlDecodeContext.IdCallback callback, org.jdom.Element element, String id, Object extraData)
XmlDecodeContext.IdCallback.objectForIdCallback(XmlDecodeContext, Element, Object, Object)
.
The callback will be invoked immediately if an ID is already
available.
callback
- The callback target.element
- The element param to be passed to the callback.id
- The id for which a value is needed.extraData
- Any extra data to be passed to the callback (may
be null).XmlDecodeContext.IdCallback.objectForIdCallback(XmlDecodeContext, Element, Object, Object)
,
callbackWithObjectForId(IdCallback,
Element, String, Object)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |