Package com.im.df.api.util.xml
Class BasicPersister<T>
- java.lang.Object
-
- com.im.df.api.util.xml.BasicPersister<T>
-
- All Implemented Interfaces:
BasicPersisterInit,IJCPersister,IJCPersister.Reader,IJCPersister.Writer,java.lang.Cloneable
public class BasicPersister<T> extends java.lang.Object implements IJCPersister, BasicPersisterInit, IJCPersister.Reader, IJCPersister.Writer, java.lang.Cloneable
Additional property attributes: staticType - FQN of the type (default: property.getPropertyType) items - FQN of the item type (default: Object) keys - FQN of the key type values - FQN of the key type- Author:
- svata
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.im.df.api.util.xml.IJCPersister
IJCPersister.FinishableBean, IJCPersister.Reader, IJCPersister.Writer
-
-
Constructor Summary
Constructors Constructor Description BasicPersister()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddError(java.io.IOException err)protected booleancanInstantiate(java.lang.Class valueClazz)protected voidclearErrors()java.lang.Objectcreate(java.lang.Object o)org.w3c.dom.AttrcreateAttribute(java.lang.String name)org.w3c.dom.ElementcreateElement(java.lang.String name)protected java.lang.ObjectcreateInstance(java.lang.Object o)Default implementation: will create an instance using reflection.TcreateInstance(org.openide.util.Lookup context, javax.xml.namespace.QName qName)protected java.util.logging.LoggercreateLog()IJCPersister.ReadercreateReader(org.openide.util.Lookup context, java.lang.Class expectedType, org.w3c.dom.Node parent, com.im.commons.progress.DFEnvironmentRO env)Reader factory.org.w3c.dom.ElementcreateState(java.lang.Object bean, org.w3c.dom.Node parent)IJCPersister.WritercreateWriter(org.openide.util.Lookup context, java.lang.Object bean, com.im.commons.progress.DFEnvironmentRO env)Writer factory.protected voiddefaultReadBean()voiddefaultWriteBean()Iterates through BeanInfo and writes all property values.protected org.w3c.dom.ElemententerElement(java.lang.String name, org.openide.util.Lookup context)For readers: enter the named element, and establish the supplied context.protected voidenterElement(org.w3c.dom.Element e, org.openide.util.Lookup context)Enter the specified element and make it current.protected org.w3c.dom.AttrgetAttribute()Returns the current attribute being written to or read from.protected java.lang.StringgetAttribute(java.beans.PropertyDescriptor pd, java.lang.String propName, java.lang.String attr)Helper methods to retrieving metadata.protected TgetBean()The bean instance being written or read.protected java.lang.ClassgetBeanClass()java.util.List<java.io.IOException>getBufferedErrors()protected java.lang.ClassgetClass(java.lang.String name)A helper method to retrieve a Class object without throwing a CNFE.protected javax.xml.namespace.QNamegetConfiguredQName()protected org.openide.util.LookupgetContext()Retrieves the current context.protected static java.lang.ClassLoadergetCurrentClassLoader()com.im.commons.progress.DFEnvironmentROgetEnv()protected org.w3c.dom.NodegetNode()Retrieves the current Node.PersisterRegistrygetPersisterRegistry()Get PersistentRegistry for creating child factories.protected java.lang.ObjectgetPropertyValue(java.beans.PropertyDescriptor property)Helper method to retrieve property's value.javax.xml.namespace.QNamegetQName(java.lang.Object bean)protected org.w3c.dom.ElementgetStorage()Returns the current element being written to or read from.java.lang.ClassgetType(org.w3c.dom.Node n)Returns the class, used to register this Persister, as the type for all handled nodes.IJCPersisterinit()Initializes the persister.booleanisPrimitive(java.lang.Class clazz)The Basic persister does not support primitive serialization, as it works with beans with [multiple] properties.protected voidleaveElement()Leave the element entered usingenterElement(java.lang.String, org.openide.util.Lookup).protected java.lang.ObjectloadObject(java.lang.Class clazz, org.w3c.dom.Node loadFrom, java.lang.Object prototype)Loads an object from the specified Node (attribute or element).protected voidpopElement()Pops an element.protected org.w3c.dom.ElementpushElement(java.lang.String name)Generates an element and makes it "current", so write* helper methods will all use it.java.lang.Objectread(java.lang.String name, java.lang.Object prototype)booleanreadAttr(java.lang.String name, boolean defValue)intreadAttr(java.lang.String name, int defValue)java.lang.StringreadAttr(java.lang.String name, java.lang.String defValue)protected java.lang.ObjectreadAttribute(java.lang.Object prototype)protected voidreadBeanProperties()protected voidreadBeanProperty(java.beans.PropertyDescriptor pd)protected <ITEM> java.util.List<ITEM>readCollection(java.lang.Class<ITEM> itemType, java.lang.String propertyName, boolean throwOnMissing)protected java.util.CollectionreadCollection(java.lang.Class implClazz, java.lang.Class itemType, java.lang.String name, java.lang.String itemName, java.util.Collection prototype)protected java.util.CollectionreadCollection(java.lang.Class implClazz, java.lang.Class itemType, java.lang.String name, java.util.Collection prototype, boolean throwOnMissing)Reads a collection of items.protected java.lang.ObjectreadCollectionProperty(java.beans.PropertyDescriptor pd)protected java.lang.ObjectreadElement(java.lang.Object prototype)protected java.lang.ObjectreadMap(java.lang.Class implClazz, java.lang.Class keyType, java.lang.Class valType, java.lang.String name, java.lang.String itemName, java.util.Map prototype)protected java.lang.ObjectreadMapProperty(java.beans.PropertyDescriptor pd)protected java.lang.ObjectreadObjectPolymorphic(java.lang.String childName, java.lang.Object prototype)protected java.lang.ObjectreadObjectStatic(java.lang.Class type, java.lang.String name, java.lang.Object prototype)Reads a statically-typed Object from the current element.protected java.lang.ObjectreadPrimitiveProperty(java.beans.PropertyDescriptor pd)protected voidsetBean(T bean)Sets the bean instance.voidsetBeanClass(java.lang.Class clazz)voidsetClassBeanInfo(java.beans.BeanInfo classBeanInfo)protected voidsetContext(org.openide.util.Lookup context)Sets a new context.voidsetEnv(com.im.commons.progress.DFEnvironmentRO env)protected voidsetNode(org.w3c.dom.Node n)voidsetPersisterRegistry(PersisterRegistry persisterRegistry)Set PersistentRegistry for creating child factories.voidsetPropertyAttributes(java.util.Map<java.lang.String,java.lang.String> propertyAttributes)voidsetQName(javax.xml.namespace.QName qName)protected voidsetStorage(org.w3c.dom.Element storage)Sets the current element to a specific node.protected voidstoreObject(org.w3c.dom.Element storeTo, java.lang.Object val)Stores object directly in the specified element (not in its sub-elements).protected voidthrowWrappedIOException(java.lang.String reason, java.lang.Throwable cause)protected voidthrowWrappedIOException(java.lang.Throwable cause)voidwrite(java.lang.String name, int value)voidwrite(java.lang.String name, java.lang.String value)org.w3c.dom.Nodewrite(java.lang.String name, org.w3c.dom.Node n)Writes the bean either into an Attribute, or to an Element.protected voidwriteArray(java.beans.PropertyDescriptor pd, java.lang.String name, java.lang.String itemName, java.lang.Object[] val)Writes an array of objects.voidwriteAttr(java.lang.String name, boolean value, boolean defValue)voidwriteAttr(java.lang.String name, int value)voidwriteAttr(java.lang.String name, int value, com.google.common.base.Optional<java.lang.Integer> defaultValue)voidwriteAttr(java.lang.String name, java.lang.String value)voidwriteAttr(java.lang.String name, java.lang.String value, java.lang.String defValue)protected voidwriteAttribute()The basic bean persister does not support primitive writing.protected voidwriteCollection(java.beans.PropertyDescriptor pd, java.lang.String itemName, java.util.Collection val)Writes a collection property.protected voidwriteCollection(java.lang.Class staticType, java.lang.String name, java.lang.String itemName, java.util.Collection val)protected voidwriteCollection(java.lang.Class staticType, java.lang.String name, java.lang.String itemName, java.util.Enumeration val)Writes an enumeration property.protected voidwriteElement()This default implementation will invoke defaultWriteBean, which outputs all properties described by the class' BeanInfo.protected voidwriteMap(java.beans.PropertyDescriptor pd, java.lang.String itemName, java.util.Map val)protected voidwriteMap(java.lang.Class keyType, java.lang.Class valueType, java.lang.String name, java.lang.String itemName, java.util.Map val)protected voidwriteObject(java.lang.Class implType, java.lang.String name, java.lang.Object val)Persist an object under the given name.protected voidwriteObjectPolymorphic(java.lang.String name, java.lang.Object val)Writes an object in a way that permits reconstruction of subclasses of the data type on reading.protected voidwriteObjectStatic(java.lang.String name, java.lang.Object val)Writes a static content of an object, as an attribute or an element, depending on the object's persister capabilities.voidwriteProperty(java.beans.PropertyDescriptor property)Write a value described by the property descriptor.protected voidwriteSuperclass(org.w3c.dom.Element where)This method will find and delegate to a superclass persister.
-
-
-
Method Detail
-
getPersisterRegistry
public PersisterRegistry getPersisterRegistry()
Description copied from interface:IJCPersisterGet PersistentRegistry for creating child factories.- Specified by:
getPersisterRegistryin interfaceIJCPersister- Returns:
- persistent registry. If persistent registry is not set return PersistentRegistry.getDefault()
-
setPersisterRegistry
public void setPersisterRegistry(PersisterRegistry persisterRegistry)
Description copied from interface:IJCPersisterSet PersistentRegistry for creating child factories.- Specified by:
setPersisterRegistryin interfaceIJCPersister- Parameters:
persisterRegistry- default persistent registry
-
setClassBeanInfo
public void setClassBeanInfo(java.beans.BeanInfo classBeanInfo)
- Specified by:
setClassBeanInfoin interfaceBasicPersisterInit
-
setPropertyAttributes
public void setPropertyAttributes(java.util.Map<java.lang.String,java.lang.String> propertyAttributes)
- Specified by:
setPropertyAttributesin interfaceBasicPersisterInit
-
setQName
public void setQName(javax.xml.namespace.QName qName)
- Specified by:
setQNamein interfaceBasicPersisterInit
-
setBeanClass
public void setBeanClass(java.lang.Class clazz) throws java.beans.IntrospectionException- Specified by:
setBeanClassin interfaceBasicPersisterInit- Throws:
java.beans.IntrospectionException
-
createLog
protected java.util.logging.Logger createLog()
-
addError
protected void addError(java.io.IOException err)
-
clearErrors
protected void clearErrors()
-
getBufferedErrors
public java.util.List<java.io.IOException> getBufferedErrors()
-
getEnv
public com.im.commons.progress.DFEnvironmentRO getEnv()
-
setEnv
public void setEnv(com.im.commons.progress.DFEnvironmentRO env)
-
getCurrentClassLoader
protected static java.lang.ClassLoader getCurrentClassLoader()
-
init
public IJCPersister init()
Initializes the persister. To be overriden by subclasses instead of the constructor, as the BasicBeanPersisters are instantiated using reflection :)- Specified by:
initin interfaceBasicPersisterInit
-
pushElement
protected org.w3c.dom.Element pushElement(java.lang.String name)
Generates an element and makes it "current", so write* helper methods will all use it. Do not forget to callpopElement()counterpart when done with the pushed element's contents.
-
enterElement
protected org.w3c.dom.Element enterElement(java.lang.String name, org.openide.util.Lookup context)For readers: enter the named element, and establish the supplied context. Helper read* methods will read from that element and if they delegate, they will use the context.- Returns:
- the element if it was found;
nullotherwise
-
enterElement
protected void enterElement(org.w3c.dom.Element e, org.openide.util.Lookup context)Enter the specified element and make it current. If Lookup is specified, the current context is changed to that Lookup. If null is given as a lookup, the current Lookup is retained. To clear the Lookup, pass in Lookup.EMPTY instance.
-
leaveElement
protected void leaveElement()
Leave the element entered usingenterElement(java.lang.String, org.openide.util.Lookup). The method also pops the Lookup context out of the stack.
-
getAttribute
protected final java.lang.String getAttribute(java.beans.PropertyDescriptor pd, java.lang.String propName, java.lang.String attr)Helper methods to retrieving metadata. Metadata can be either stored as a named value in the BeanInfo or, if it is not feasible to change, the persister's propertyAttributesMap can contain the value under key "<property-name>%<attribute-name>". If none of the maps contains the requested attribute, null will be returned.
-
popElement
protected void popElement()
Pops an element. Use as a counterpart forpushElement(java.lang.String)when persisting the bean.
-
setBean
protected void setBean(T bean)
Sets the bean instance. Use this method early in write implementation, so all other state methods can work with the bean. When reading, set the bean as soon as the result object is constructed.
-
getBean
protected final T getBean()
The bean instance being written or read.
-
getBeanClass
protected java.lang.Class getBeanClass()
- Returns:
- The class of the bean that will be deserialized
-
setStorage
protected void setStorage(org.w3c.dom.Element storage)
Sets the current element to a specific node. The method will reset the attribute property.
-
setNode
protected void setNode(org.w3c.dom.Node n)
-
getAttribute
protected org.w3c.dom.Attr getAttribute()
Returns the current attribute being written to or read from.
-
getStorage
protected final org.w3c.dom.Element getStorage()
Returns the current element being written to or read from.
-
setContext
protected void setContext(org.openide.util.Lookup context)
Sets a new context. This method should be used just for setting up the persister; otherwise, push and pop methods should be used to manipulate synchronously with the element and context stacks.
-
getContext
protected final org.openide.util.Lookup getContext()
Retrieves the current context. Context can be used by the persister to discover its environment, to bind the deserialized bean to. Also it can be used by the serializer to discover which information is implicitly available in the environment (e.g. serializing a field within its Entity only requires the field ID - if the Entity instance is in the environment)
-
createWriter
public IJCPersister.Writer createWriter(org.openide.util.Lookup context, java.lang.Object bean, com.im.commons.progress.DFEnvironmentRO env)
Writer factory. It clones self, and initializes the context and the bean being written.- Specified by:
createWriterin interfaceIJCPersister
-
createReader
public IJCPersister.Reader createReader(org.openide.util.Lookup context, java.lang.Class expectedType, org.w3c.dom.Node parent, com.im.commons.progress.DFEnvironmentRO env)
Reader factory. It clones itself and initializes the context, and the current XML Node- Specified by:
createReaderin interfaceIJCPersister
-
isPrimitive
public boolean isPrimitive(java.lang.Class clazz)
The Basic persister does not support primitive serialization, as it works with beans with [multiple] properties. Subclasses tailored specifically for certain bean may override this.- Specified by:
isPrimitivein interfaceIJCPersister- Returns:
- If true, the Factory is willing to write to an attribute
-
getType
public java.lang.Class getType(org.w3c.dom.Node n)
Returns the class, used to register this Persister, as the type for all handled nodes.- Specified by:
getTypein interfaceIJCPersister- Returns:
- The type of the bean to be deserialized
-
getNode
protected org.w3c.dom.Node getNode()
Retrieves the current Node.
-
write
public final org.w3c.dom.Node write(java.lang.String name, org.w3c.dom.Node n) throws java.io.IOExceptionWrites the bean either into an Attribute, or to an Element. If the passed Node is an attribute, it will try to persist the bean callingwriteAttribute(). If the persister does not support primitive writing, a child element named "name" will be created to hold the bean's state. If the passed Node is an element, the bean's state is always stored to that element. Element is written by callingwriteElement()overridable.- Specified by:
writein interfaceIJCPersister.Writer- Parameters:
name- The namen- The node- Returns:
- The node
- Throws:
java.io.IOException
-
writeAttribute
protected void writeAttribute() throws java.io.IOExceptionThe basic bean persister does not support primitive writing.- Throws:
java.io.IOException
-
writeElement
protected void writeElement() throws java.io.IOExceptionThis default implementation will invoke defaultWriteBean, which outputs all properties described by the class' BeanInfo.- Throws:
java.io.IOException
-
defaultWriteBean
public void defaultWriteBean() throws java.io.IOExceptionIterates through BeanInfo and writes all property values.- Throws:
java.io.IOException
-
getPropertyValue
protected java.lang.Object getPropertyValue(java.beans.PropertyDescriptor property) throws java.io.IOExceptionHelper method to retrieve property's value. All reflection exceptions are wrapped into IOExceptions- Throws:
java.io.IOException
-
writeProperty
public void writeProperty(java.beans.PropertyDescriptor property) throws java.io.IOExceptionWrite a value described by the property descriptor. Primitives, arrays and collections are handled specially. If the bean is a generic object, the static type information from the BeanInfo's value map is used to determine whether it can be written without type information.- Throws:
java.io.IOException
-
getClass
protected java.lang.Class getClass(java.lang.String name)
A helper method to retrieve a Class object without throwing a CNFE. CNFE is expected in this case. The passed name may be null (null will be returned).
-
writeCollection
protected void writeCollection(java.lang.Class staticType, java.lang.String name, java.lang.String itemName, java.util.Enumeration val) throws java.io.IOExceptionWrites an enumeration property. It may surround the entire collection in a wrapper element (named "name"). Each item will be either named "itemName" (if the parameter is not null), or the default name "item" will be used. If the static type is not known in advance, the object will be written in a typed way - no default name item name will be used, as the collection only contains its items, no other elements.- Parameters:
staticType- The element type, if staticname- The name of the wrapper elementitemName- The name of the "item" element where item information will be stored.val- The enumeration of elements to be stored.- Throws:
java.io.IOException
-
writeMap
protected void writeMap(java.lang.Class keyType, java.lang.Class valueType, java.lang.String name, java.lang.String itemName, java.util.Map val) throws java.io.IOException- Throws:
java.io.IOException
-
writeCollection
protected void writeCollection(java.lang.Class staticType, java.lang.String name, java.lang.String itemName, java.util.Collection val) throws java.io.IOException- Throws:
java.io.IOException
-
canInstantiate
protected boolean canInstantiate(java.lang.Class valueClazz)
-
writeCollection
protected void writeCollection(java.beans.PropertyDescriptor pd, java.lang.String itemName, java.util.Collection val) throws java.io.IOExceptionWrites a collection property.- Throws:
java.io.IOException
-
writeMap
protected void writeMap(java.beans.PropertyDescriptor pd, java.lang.String itemName, java.util.Map val) throws java.io.IOException- Throws:
java.io.IOException
-
writeArray
protected void writeArray(java.beans.PropertyDescriptor pd, java.lang.String name, java.lang.String itemName, java.lang.Object[] val) throws java.io.IOExceptionWrites an array of objects.- Throws:
java.io.IOException
-
writeObject
protected final void writeObject(java.lang.Class implType, java.lang.String name, java.lang.Object val) throws java.io.IOExceptionPersist an object under the given name. The object may be written as an attribute, or an sub-element, if the implementation type is known (statically). If the implementation type is not known in advance, the object must be written as a dynamic content, using sub-element with proper tagname and namespace URI which allows to locate the appropriate persister on deserialization. Note that dynamically typed objects cannot be stored as attributes.- Parameters:
implType- The static type, or null if the type may vary (e.g. subclasses might be used)name- The attribute/child element nameval- The object- Throws:
java.io.IOException
-
writeObjectPolymorphic
protected final void writeObjectPolymorphic(java.lang.String name, java.lang.Object val) throws java.io.IOExceptionWrites an object in a way that permits reconstruction of subclasses of the data type on reading. Such objects must be read usingreadObjectPolymorphic(java.lang.String, java.lang.Object), and are stored as a child element "name", whose sole child is a {namespace}tagname element defined by the value persister. Alternatively, the typed object's typed element is appended as a direct child, if the passed name is null.- Throws:
java.io.IOException
-
writeObjectStatic
protected final void writeObjectStatic(java.lang.String name, java.lang.Object val) throws java.io.IOExceptionWrites a static content of an object, as an attribute or an element, depending on the object's persister capabilities. Note that this object must be restored byreadObjectStatic(java.lang.Class, java.lang.String, java.lang.Object), using the specific class.- Parameters:
name- The name of the element or attributeval- The object- Throws:
java.io.IOException
-
loadObject
protected java.lang.Object loadObject(java.lang.Class clazz, org.w3c.dom.Node loadFrom, java.lang.Object prototype) throws java.io.IOExceptionLoads an object from the specified Node (attribute or element). A prototype instance may be passed to populate with state or clone.- Throws:
java.io.IOException
-
storeObject
protected void storeObject(org.w3c.dom.Element storeTo, java.lang.Object val) throws java.io.IOExceptionStores object directly in the specified element (not in its sub-elements). This is useful when a parent wants to annotate the child with additional properties- Throws:
java.io.IOException
-
createElement
public org.w3c.dom.Element createElement(java.lang.String name)
-
createAttribute
public org.w3c.dom.Attr createAttribute(java.lang.String name)
-
writeAttr
public void writeAttr(java.lang.String name, int value, com.google.common.base.Optional<java.lang.Integer> defaultValue)
-
writeAttr
public void writeAttr(java.lang.String name, int value)
-
writeAttr
public void writeAttr(java.lang.String name, boolean value, boolean defValue)
-
write
public void write(java.lang.String name, int value)
-
writeAttr
public void writeAttr(java.lang.String name, java.lang.String value, java.lang.String defValue)
-
writeAttr
public void writeAttr(java.lang.String name, java.lang.String value)
-
readAttr
public int readAttr(java.lang.String name, int defValue)
-
readAttr
public java.lang.String readAttr(java.lang.String name, java.lang.String defValue)
-
readAttr
public boolean readAttr(java.lang.String name, boolean defValue)
-
write
public void write(java.lang.String name, java.lang.String value)
-
createInstance
public T createInstance(org.openide.util.Lookup context, javax.xml.namespace.QName qName) throws java.io.IOException
- Throws:
java.io.IOException
-
writeSuperclass
protected void writeSuperclass(org.w3c.dom.Element where) throws java.io.IOExceptionThis method will find and delegate to a superclass persister.- Throws:
java.io.IOException
-
getQName
public javax.xml.namespace.QName getQName(java.lang.Object bean)
- Specified by:
getQNamein interfaceIJCPersister- Returns:
- QName of the element to be created
-
getConfiguredQName
protected javax.xml.namespace.QName getConfiguredQName()
-
createState
public org.w3c.dom.Element createState(java.lang.Object bean, org.w3c.dom.Node parent)
-
create
public java.lang.Object create(java.lang.Object o) throws java.io.IOException- Specified by:
createin interfaceIJCPersister.Reader- Throws:
java.io.IOException
-
createInstance
protected java.lang.Object createInstance(java.lang.Object o) throws java.io.IOExceptionDefault implementation: will create an instance using reflection. If the passed prototype is not null, and is assignable to the persister's bean class, the prototype object will be returned instead of a new instance. Nothing will be created if the bean does not have a default constructor.- Throws:
java.io.IOException
-
read
public final java.lang.Object read(java.lang.String name, java.lang.Object prototype) throws java.io.IOException- Specified by:
readin interfaceIJCPersister.Reader- Throws:
java.io.IOException
-
readElement
protected java.lang.Object readElement(java.lang.Object prototype) throws java.io.IOException- Throws:
java.io.IOException
-
readAttribute
protected java.lang.Object readAttribute(java.lang.Object prototype) throws java.io.IOException- Throws:
java.io.IOException
-
readObjectStatic
protected java.lang.Object readObjectStatic(java.lang.Class type, java.lang.String name, java.lang.Object prototype) throws java.io.IOExceptionReads a statically-typed Object from the current element. It may load the object from a sub-element or an attribute, depending on the object's registered Persister- Throws:
java.io.IOException
-
defaultReadBean
protected void defaultReadBean() throws java.io.IOException- Throws:
java.io.IOException
-
readBeanProperties
protected void readBeanProperties() throws java.io.IOException- Throws:
java.io.IOException
-
readBeanProperty
protected void readBeanProperty(java.beans.PropertyDescriptor pd) throws java.io.IOException- Throws:
java.io.IOException
-
readObjectPolymorphic
protected java.lang.Object readObjectPolymorphic(java.lang.String childName, java.lang.Object prototype) throws java.io.IOException- Throws:
java.io.IOException
-
throwWrappedIOException
protected void throwWrappedIOException(java.lang.String reason, java.lang.Throwable cause) throws java.io.IOException- Throws:
java.io.IOException
-
throwWrappedIOException
protected void throwWrappedIOException(java.lang.Throwable cause) throws java.io.IOException- Throws:
java.io.IOException
-
readCollection
protected java.util.Collection readCollection(java.lang.Class implClazz, java.lang.Class itemType, java.lang.String name, java.lang.String itemName, java.util.Collection prototype) throws java.io.IOException- Throws:
java.io.IOException
-
readCollection
protected <ITEM> java.util.List<ITEM> readCollection(java.lang.Class<ITEM> itemType, java.lang.String propertyName, boolean throwOnMissing) throws java.io.IOException- Throws:
java.io.IOException
-
readCollection
protected java.util.Collection readCollection(java.lang.Class implClazz, java.lang.Class itemType, java.lang.String name, java.util.Collection prototype, boolean throwOnMissing) throws java.io.IOExceptionReads a collection of items. If an item cannot be read, the whole operation fails with an exception. If the 'prototype' is not null, the method will read into that prototype collection instance rather than create a new instance. 'implClazz' provides a Class type of collection to be created. If the type isnullor is an interface anArrayListis instantiated. 'itemType' specifies the base type to be read - Persister for that type will be used to read the items. If not provided, the persister will be looked up according to the item's DOM element name.- Parameters:
implClazz- The type of the collection, or null when prototype is present or ArrayList should be useditemType- The type of the item, or null for polymorphic lookupname- The name of the wrapper DOM element, null if no wrapperprototype- The prototype collection instance- Returns:
- The deserialized Collection
- Throws:
java.io.IOException
-
readCollectionProperty
protected java.lang.Object readCollectionProperty(java.beans.PropertyDescriptor pd) throws java.io.IOException- Throws:
java.io.IOException
-
readMapProperty
protected java.lang.Object readMapProperty(java.beans.PropertyDescriptor pd) throws java.io.IOException- Throws:
java.io.IOException
-
readMap
protected java.lang.Object readMap(java.lang.Class implClazz, java.lang.Class keyType, java.lang.Class valType, java.lang.String name, java.lang.String itemName, java.util.Map prototype) throws java.io.IOException- Throws:
java.io.IOException
-
readPrimitiveProperty
protected java.lang.Object readPrimitiveProperty(java.beans.PropertyDescriptor pd) throws java.io.IOException- Throws:
java.io.IOException
-
-