|
JHotDraw 7.5.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jhotdraw.xml.JavaPrimitivesDOMFactory
public class JavaPrimitivesDOMFactory
JavaPrimitivesDOMFactory
can be used to serialize Java primitive objects
and DOMStorable
objects.
The following Java primitive types are supported. Object wrappers are automatically unwrapped into their primitive types.
You can add support for additional primitive types by overriding the methods
read
and write
.
In addition to the primitive types, this factory can store and read
DOMStorable
objects. No mapping for DOMStorable
class names is performed.
For example, if a DOMStorable
object has the class name com.example.MyClass
,
then the DOM element has the same name, that is: <com.example.MyClass>
.
Since no mapping between DOM element names and DOMStorable
class names is performed,
DOM's generated with JavaPrimitivesDOMFactory are not suited for long-term
storage of objects. This is because a DOM element can not be read back into an
object, if the class name of the object has changed.
You can implement a mapping by overriding the methods getName
,
create
, getEnumName
and getEnumValue
.
Constructor Summary | |
---|---|
JavaPrimitivesDOMFactory()
|
Method Summary | |
---|---|
java.lang.Object |
create(java.lang.String name)
Creates an object from the specified element name. |
protected java.lang.Enum |
createEnum(java.lang.String name,
java.lang.String value)
|
protected java.lang.String |
getEnumName(java.lang.Enum o)
|
protected java.lang.String |
getEnumValue(java.lang.Enum o)
|
java.lang.String |
getName(java.lang.Object o)
Returns the element name for the specified object. |
java.lang.Object |
read(DOMInput in)
Reads the specified object from DOMInput. |
void |
write(DOMOutput out,
java.lang.Object o)
Writes the specified object to DOMOutput. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JavaPrimitivesDOMFactory()
Method Detail |
---|
public java.lang.String getName(java.lang.Object o)
DOMFactory
getName
in interface DOMFactory
public java.lang.Object create(java.lang.String name)
DOMFactory
create
in interface DOMFactory
protected java.lang.String getEnumName(java.lang.Enum o)
protected java.lang.String getEnumValue(java.lang.Enum o)
protected java.lang.Enum createEnum(java.lang.String name, java.lang.String value)
public void write(DOMOutput out, java.lang.Object o) throws java.io.IOException
DOMFactory
This method is only ever called from DOMOutput. You should never call this method directly.
write
in interface DOMFactory
o
- The object to be written.
java.io.IOException
public java.lang.Object read(DOMInput in) throws java.io.IOException
DOMFactory
This method is only ever called from DOMInput. You should never call this method directly.
read
in interface DOMFactory
in
- The DOMInput object which creates the object from an element
in a DOM.
java.io.IOException
|
Copyright 1996-2010 (c) by the authors and contributors of the JHotDraw project. Some rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |