|
com.im.df.api 5.9 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.im.df.api.util.xml.BasicPersister<T>
public class BasicPersister<T>
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
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.im.df.api.util.xml.StateFactory |
|---|
StateFactory.EnvReporter, StateFactory.FinishableBean, StateFactory.Reader, StateFactory.Writer |
| Constructor Summary | |
|---|---|
BasicPersister()
|
|
| Method Summary | |
|---|---|
protected void |
addError(IOException err)
|
protected boolean |
canInstantiate(Class valueClazz)
|
protected void |
clearErrors()
|
Object |
create(Object o)
|
Attr |
createAttribute(String name)
|
Element |
createElement(String name)
|
T |
createInstance(Lookup context,
QName qName)
|
protected Object |
createInstance(Object o)
Default implementation: will create an instance using reflection. |
protected Logger |
createLog()
|
StateFactory.Reader |
createReader(Lookup context,
Class expectedType,
Node parent,
DFEnvironmentRO env)
Reader factory. |
Element |
createState(Object bean,
Node parent)
|
StateFactory.Writer |
createWriter(Lookup context,
Object bean,
DFEnvironmentRO env)
Writer factory. |
protected void |
defaultReadBean()
|
void |
defaultWriteBean()
Iterates through BeanInfo and writes all property values |
protected void |
enterElement(Element e,
Lookup context)
Enter the specified element and make it current. |
protected Element |
enterElement(String name,
Lookup context)
For readers: enter the named element, and establish the supplied Context. |
protected Attr |
getAttribute()
Returns the current attribute being written to or read from |
protected String |
getAttribute(PropertyDescriptor pd,
String propName,
String attr)
Helper methods to retrieving metadata. |
protected T |
getBean()
The bean instance being written or read |
protected Class |
getBeanClass()
|
List<IOException> |
getBufferedErrors()
|
protected Class |
getClass(String name)
A helper method to retrieve a Class object without throwing a CNFE. |
protected QName |
getConfiguredQName()
|
protected Lookup |
getContext()
Retrieves the current context. |
protected static ClassLoader |
getCurrentClassLoader()
|
DFEnvironmentRO |
getEnv()
|
protected Node |
getNode()
Retrieves the current Node |
protected Object |
getPropertyValue(PropertyDescriptor property)
Helper method to retrieve property's value. |
QName |
getQName(Object bean)
|
protected Element |
getStorage()
Returns the current element being written to or read from |
Class |
getType(Node n)
Returns the class, used to register this Persister, as the type for all handled nodes. |
StateFactory |
init()
Initializes the persister. |
boolean |
isPrimitive(Class clazz)
The Basic persister does not support primitive serialization, as it works with beans with [multiple] properties. |
protected void |
leaveElement()
Leave the element entered using enterElement(java.lang.String, org.openide.util.Lookup). |
protected Object |
loadObject(Class clazz,
Node loadFrom,
Object prototype)
Loads an object from the specified Node (attribute or element). |
protected void |
popElement()
Pops an element. |
protected Element |
pushElement(String name)
Generates an element and makes it "current", so write* helper methods will all use it. |
Object |
read(String name,
Object prototype)
|
boolean |
readAttr(String name,
boolean defValue)
|
int |
readAttr(String name,
int defValue)
|
String |
readAttr(String name,
String defValue)
|
protected Object |
readAttribute(Object prototype)
|
protected void |
readBeanProperties()
|
protected void |
readBeanProperty(PropertyDescriptor pd)
|
protected Collection |
readCollection(Class implClazz,
Class itemType,
String name,
String itemName,
Collection prototype)
|
protected Collection |
readCollection(Class implClazz,
Class itemType,
String name,
String itemName,
Collection prototype,
boolean throwOnMissing)
Reads a collection of items. |
protected Object |
readCollectionProperty(PropertyDescriptor pd)
|
protected Object |
readElement(Object prototype)
|
protected Object |
readMap(Class implClazz,
Class keyType,
Class valType,
String name,
String itemName,
Map prototype)
|
protected Object |
readMapProperty(PropertyDescriptor pd)
|
protected Object |
readObjectPolymorphic(String childName,
Object prototype)
|
protected Object |
readObjectStatic(Class type,
String name,
Object prototype)
Reads a statically-typed Object from the current element. |
protected Object |
readPrimitiveProperty(PropertyDescriptor pd)
|
protected void |
setBean(T bean)
Sets the bean instance. |
void |
setBeanClass(Class clazz)
|
void |
setClassBeanInfo(BeanInfo classBeanInfo)
|
protected void |
setContext(Lookup context)
Sets a new context. |
void |
setEnv(DFEnvironmentRO env)
|
protected void |
setNode(Node n)
|
void |
setPropertyAttributes(Map<String,String> propertyAttributes)
|
void |
setQName(QName qName)
|
protected void |
setStorage(Element storage)
Sets the current element to a specific node. |
protected void |
storeObject(Element storeTo,
Object val)
Stores object directly in the specified element (not in its sub-elements). |
protected void |
throwWrappedIOException(String reason,
Throwable cause)
|
protected void |
throwWrappedIOException(Throwable cause)
|
void |
write(String name,
int value)
|
Node |
write(String name,
Node n)
Writes the bean either into an Attribute, or to an Element. |
void |
write(String name,
String value)
|
protected void |
writeArray(PropertyDescriptor pd,
String name,
String itemName,
Object[] val)
Writes an array of objects |
void |
writeAttr(String name,
boolean value,
boolean defValue)
|
void |
writeAttr(String name,
int value)
|
void |
writeAttr(String name,
int value,
int defValue)
|
void |
writeAttr(String name,
String value)
|
void |
writeAttr(String name,
String value,
String defValue)
|
protected void |
writeAttribute()
The basic bean persister does not support primitive writing |
protected void |
writeCollection(Class staticType,
String name,
String itemName,
Collection val)
|
protected void |
writeCollection(Class staticType,
String name,
String itemName,
Enumeration val)
Writes an enumeration property. |
protected void |
writeCollection(PropertyDescriptor pd,
String itemName,
Collection val)
Writes a collection property |
protected void |
writeElement()
This default implementation will invoke defaultWriteBean, which outputs all properties described by the class' BeanInfo |
protected void |
writeMap(Class keyType,
Class valueType,
String name,
String itemName,
Map val)
|
protected void |
writeMap(PropertyDescriptor pd,
String itemName,
Map val)
|
protected void |
writeObject(Class implType,
String name,
Object val)
Persist an object under the given name. |
protected void |
writeObjectPolymorphic(String name,
Object val)
Writes an object in a way that permits reconstruction of subclasses of the data type on reading. |
protected void |
writeObjectStatic(String name,
Object val)
Writes a static content of an object, as an attribute or an element, depending on the object's persister capabilities. |
void |
writeProperty(PropertyDescriptor property)
Write a value described by the property descriptor. |
protected void |
writeSuperclass(Element where)
This method will find and delegate to a superclass persister. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public BasicPersister()
| Method Detail |
|---|
public void setClassBeanInfo(BeanInfo classBeanInfo)
setClassBeanInfo in interface BasicPersisterInitpublic void setPropertyAttributes(Map<String,String> propertyAttributes)
setPropertyAttributes in interface BasicPersisterInitpublic void setQName(QName qName)
setQName in interface BasicPersisterInit
public void setBeanClass(Class clazz)
throws IntrospectionException
setBeanClass in interface BasicPersisterInitIntrospectionExceptionprotected Logger createLog()
protected void addError(IOException err)
protected void clearErrors()
public List<IOException> getBufferedErrors()
public DFEnvironmentRO getEnv()
public void setEnv(DFEnvironmentRO env)
protected static ClassLoader getCurrentClassLoader()
public StateFactory init()
init in interface BasicPersisterInitprotected Element pushElement(String name)
popElement() counterpart
when done with the pushed element's contents.
protected Element enterElement(String name,
Lookup context)
protected void enterElement(Element e,
Lookup context)
protected void leaveElement()
enterElement(java.lang.String, org.openide.util.Lookup). The method also
pops the Lookup context out of the stack.
protected final String getAttribute(PropertyDescriptor pd,
String propName,
String attr)
protected void popElement()
pushElement(java.lang.String)
when persisting the bean.
protected void setBean(T bean)
protected final T getBean()
protected Class getBeanClass()
protected void setStorage(Element storage)
protected void setNode(Node n)
protected Attr getAttribute()
protected final Element getStorage()
protected void setContext(Lookup context)
protected final Lookup getContext()
public StateFactory.Writer createWriter(Lookup context,
Object bean,
DFEnvironmentRO env)
createWriter in interface StateFactory
public StateFactory.Reader createReader(Lookup context,
Class expectedType,
Node parent,
DFEnvironmentRO env)
createReader in interface StateFactorypublic boolean isPrimitive(Class clazz)
isPrimitive in interface StateFactorypublic Class getType(Node n)
getType in interface StateFactoryprotected Node getNode()
public final Node write(String name,
Node n)
throws IOException
writeAttribute().
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 calling writeElement() overridable.
write in interface StateFactory.Writername - The namen - The node
IOException
protected void writeAttribute()
throws IOException
IOException
protected void writeElement()
throws IOException
IOException
public void defaultWriteBean()
throws IOException
IOException
protected Object getPropertyValue(PropertyDescriptor property)
throws IOException
IOException
public void writeProperty(PropertyDescriptor property)
throws IOException
IOExceptionprotected Class getClass(String name)
protected void writeCollection(Class staticType,
String name,
String itemName,
Enumeration val)
throws IOException
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.
IOException
protected void writeMap(Class keyType,
Class valueType,
String name,
String itemName,
Map val)
throws IOException
IOException
protected void writeCollection(Class staticType,
String name,
String itemName,
Collection val)
throws IOException
IOExceptionprotected boolean canInstantiate(Class valueClazz)
protected void writeCollection(PropertyDescriptor pd,
String itemName,
Collection val)
throws IOException
IOException
protected void writeMap(PropertyDescriptor pd,
String itemName,
Map val)
throws IOException
IOException
protected void writeArray(PropertyDescriptor pd,
String name,
String itemName,
Object[] val)
throws IOException
IOException
protected final void writeObject(Class implType,
String name,
Object val)
throws IOException
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
IOException
protected final void writeObjectPolymorphic(String name,
Object val)
throws IOException
readObjectPolymorphic(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.
IOException
protected final void writeObjectStatic(String name,
Object val)
throws IOException
readObjectStatic(java.lang.Class, java.lang.String, java.lang.Object), using the specific
class.
name - The name of the element or attributeval - The object
IOException
protected Object loadObject(Class clazz,
Node loadFrom,
Object prototype)
throws IOException
IOException
protected void storeObject(Element storeTo,
Object val)
throws IOException
IOExceptionpublic Element createElement(String name)
public Attr createAttribute(String name)
public void writeAttr(String name,
int value,
int defValue)
public void writeAttr(String name,
int value)
public void writeAttr(String name,
boolean value,
boolean defValue)
public void write(String name,
int value)
public void writeAttr(String name,
String value,
String defValue)
public void writeAttr(String name,
String value)
public int readAttr(String name,
int defValue)
public String readAttr(String name,
String defValue)
public boolean readAttr(String name,
boolean defValue)
public void write(String name,
String value)
public T createInstance(Lookup context,
QName qName)
throws IOException
IOException
protected void writeSuperclass(Element where)
throws IOException
IOExceptionpublic QName getQName(Object bean)
getQName in interface StateFactoryprotected QName getConfiguredQName()
public Element createState(Object bean,
Node parent)
public Object create(Object o)
throws IOException
create in interface StateFactory.ReaderIOException
protected Object createInstance(Object o)
throws IOException
IOException
public final Object read(String name,
Object prototype)
throws IOException
read in interface StateFactory.ReaderIOException
protected Object readElement(Object prototype)
throws IOException
IOException
protected Object readAttribute(Object prototype)
throws IOException
IOException
protected Object readObjectStatic(Class type,
String name,
Object prototype)
throws IOException
IOException
protected void defaultReadBean()
throws IOException
IOException
protected void readBeanProperties()
throws IOException
IOException
protected void readBeanProperty(PropertyDescriptor pd)
throws IOException
IOException
protected Object readObjectPolymorphic(String childName,
Object prototype)
throws IOException
IOException
protected void throwWrappedIOException(String reason,
Throwable cause)
throws IOException
IOException
protected void throwWrappedIOException(Throwable cause)
throws IOException
IOException
protected Collection readCollection(Class implClazz,
Class itemType,
String name,
String itemName,
Collection prototype)
throws IOException
IOException
protected Collection readCollection(Class implClazz,
Class itemType,
String name,
String itemName,
Collection prototype,
boolean throwOnMissing)
throws IOException
null or is an interface an ArrayList is 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.
implClazz - The type of the collection, or null when prototype is presentitemType - The type of the item, or null for polymorphic lookupname - The name of the wrapper DOM element, null if no wrapperitemName - NOT USED !??!prototype - The prototype collection instance
IOException
protected Object readCollectionProperty(PropertyDescriptor pd)
throws IOException
IOException
protected Object readMapProperty(PropertyDescriptor pd)
throws IOException
IOException
protected Object readMap(Class implClazz,
Class keyType,
Class valType,
String name,
String itemName,
Map prototype)
throws IOException
IOException
protected Object readPrimitiveProperty(PropertyDescriptor pd)
throws IOException
IOException
|
com.im.df.api 5.9 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||