public class ReadContext extends Context
Extends Context
to provide read specific functionality.
Three stacks are used to manage the reading:
MappingAction
's
used to execute the mapping of the current element and it's ancesters back to the
document root.Constructor and Description |
---|
ReadContext(BindingConfiguration bindingConfiguration,
ReadConfiguration readConfiguration)
Constructs a
ReadContext with standard log. |
ReadContext(Context context,
ReadConfiguration readConfiguration)
Constructs a
ReadContext with the same settings
as an existing Context . |
ReadContext(org.apache.commons.logging.Log log,
BindingConfiguration bindingConfiguration,
ReadConfiguration readConfiguration)
Base constructor
|
ReadContext(ReadContext readContext)
Constructs a
ReadContext
with the same settings as an existing Context . |
Modifier and Type | Method and Description |
---|---|
void |
clearBeans()
Clears the beans indexed by id.
|
MappingAction |
currentMappingAction()
Gets the current mapping action
|
ActionMappingStrategy |
getActionMappingStrategy()
Gets the strategy used to define default mappings actions
for elements.
|
Object |
getBean()
Gets the current bean.
|
Object |
getBean(String id)
Gets a bean from storage by an (xml) ID.
|
BeanCreationChain |
getBeanCreationChain()
Gets the
BeanCreationChange to be used to create beans
when an element is mapped. |
ClassLoader |
getClassLoader()
Gets the classloader to be used.
|
ElementDescriptor |
getCurrentDescriptor()
Gets the
ElementDescriptor that describes the
mapping for the current element. |
String |
getCurrentElement()
Gets the element name for the currently mapped element.
|
Updater |
getCurrentUpdater()
Gets the current
Updater . |
Class |
getLastMappedClass()
Gets the Class that was last mapped, if there is one.
|
Class |
getRootClass() |
XMLIntrospector |
getXMLIntrospector()
Gets the
XMLIntrospector to be used to create
the mappings for the xml. |
void |
markClassMap(Class mappedClazz)
Marks the element name stack with a class mapping.
|
Object |
popBean()
Pops the last mapping
Object from the
stack containing beans that have been mapped. |
String |
popElement()
Pops the top element from the element mapping stack.
|
MappingAction |
popMappingAction()
Pops an action mapping from the stack
|
void |
populateAttributes(AttributeDescriptor[] attributeDescriptors,
org.xml.sax.Attributes attributes)
Populates the object mapped by the
AttributeDescriptor s
with the values in the given Attributes . |
Updater |
popUpdater()
Pops the top
Updater from the stack. |
void |
pushBean(Object bean)
Pushs a newly mapped
Object onto the mapped bean stack. |
void |
pushElement(String elementName)
Pushes the given element onto the element mapping stack.
|
void |
pushMappingAction(MappingAction mappingAction)
Pushs an action mapping onto the stack
|
void |
pushUpdater(Updater updater)
Pushes an
Updater onto the stack. |
void |
putBean(String id,
Object bean)
Puts a bean into storage indexed by an (xml) ID.
|
Class |
resolvePolymorphicType(ElementMapping mapping)
Resolves any polymorphism in the element mapping.
|
void |
setBean(Object bean)
Set the current bean.
|
void |
setClassLoader(ClassLoader classLoader)
Sets the classloader to be used.
|
void |
setRootClass(Class rootClass) |
void |
setXMLIntrospector(XMLIntrospector xmlIntrospector)
Sets the
XMLIntrospector to be used to create
the mappings for the xml. |
getClassNameAttribute, getIdMappingStrategy, getInheritedOption, getLog, getMapIDs, getObjectStringConverter, getOptions, getValueSuppressionStrategy, getVariable, getVariables, newContext, popOptions, pushOptions, setClassNameAttribute, setLog, setValueSuppressionStrategy, setVariable, setVariables
public ReadContext(Context context, ReadConfiguration readConfiguration)
ReadContext
with the same settings
as an existing Context
.context
- not nullreadConfiguration
- not nullpublic ReadContext(BindingConfiguration bindingConfiguration, ReadConfiguration readConfiguration)
ReadContext
with standard log.bindingConfiguration
- the dynamic configuration, not nullreadConfiguration
- the extra read configuration not nullpublic ReadContext(org.apache.commons.logging.Log log, BindingConfiguration bindingConfiguration, ReadConfiguration readConfiguration)
log
- log to this LogbindingConfiguration
- the dynamic configuration, not nullreadConfiguration
- the extra read configuration not nullpublic ReadContext(ReadContext readContext)
ReadContext
with the same settings as an existing Context
.readContext
- not nullpublic void putBean(String id, Object bean)
id
- the ID string of the xml element associated with the beanbean
- the Object to store, not nullpublic Object getBean(String id)
id
- the ID string of the xml element associated with the beanpublic void clearBeans()
public ClassLoader getClassLoader()
public void setClassLoader(ClassLoader classLoader)
classLoader
- the ClassLoader to be used, possibly nullpublic BeanCreationChain getBeanCreationChain()
BeanCreationChange
to be used to create beans
when an element is mapped.public ActionMappingStrategy getActionMappingStrategy()
ActionMappingStrategy
. not nullpublic String popElement()
public String getCurrentElement()
public Class getLastMappedClass()
public void pushElement(String elementName) throws Exception
elementName
- the local name if the parser is namespace aware,
otherwise the full element name. Not nullException
public void markClassMap(Class mappedClazz) throws IntrospectionException
mappedClazz
- the Class which has been mapped at the current path, not nullIntrospectionException
public MappingAction popMappingAction()
MappingAction
, not nullpublic void pushMappingAction(MappingAction mappingAction)
mappingAction
- public MappingAction currentMappingAction()
public void setBean(Object bean)
Context
public Object popBean()
Object
from the
stack containing beans that have been mapped.public void pushBean(Object bean)
Object
onto the mapped bean stack.bean
- public XMLIntrospector getXMLIntrospector()
XMLIntrospector
to be used to create
the mappings for the xml.XMLIntrospector
, not nullpublic void setXMLIntrospector(XMLIntrospector xmlIntrospector)
XMLIntrospector
to be used to create
the mappings for the xml.xmlIntrospector
- XMLIntrospector
, not nullpublic Class getRootClass()
public void setRootClass(Class rootClass)
public ElementDescriptor getCurrentDescriptor() throws Exception
ElementDescriptor
that describes the
mapping for the current element.ElementDescriptor
or null if there is no
current mappingException
public void populateAttributes(AttributeDescriptor[] attributeDescriptors, org.xml.sax.Attributes attributes)
AttributeDescriptor
s
with the values in the given Attributes
.attributeDescriptors
- AttributeDescriptor
s, not nullattributes
- Attributes
, not nullpublic void pushUpdater(Updater updater)
Pushes an Updater
onto the stack.
NoteAny action pushing an Updater
onto
the stack should take responsibility for popping
the updater from the stack at an appropriate time.
Usage: this may be used by actions which require a temporary object to be updated. Pushing an updater onto the stack allow actions downstream to transparently update the temporary proxy.
updater
- Updater, possibly nullpublic Updater popUpdater()
Updater
from the stack.
NoteAny action pushing an Updater
onto
the stack should take responsibility for popping
the updater from the stack at an appropriate time.
Updater
, possibly nullpublic Updater getCurrentUpdater()
Updater
.
This may (or may not) be the updater for the current
descriptor.
If the current descriptor is a bean child,
the the current updater will (most likely)
be the updater for the property.
Actions (that, for example, use proxy objects)
may push updaters onto the stack.public Class resolvePolymorphicType(ElementMapping mapping)
mapping
- ElementMapping
describing the mapped elementnull
if the type cannot be resolved
or if the current descriptor is not polymorphicCopyright © 2002-2013 Apache Software Foundation. All Rights Reserved.