JHotDraw 7.4.1

org.jhotdraw.xml
Class DefaultDOMFactory

java.lang.Object
  extended by org.jhotdraw.xml.DefaultDOMFactory
All Implemented Interfaces:
DOMFactory
Direct Known Subclasses:
DrawFigureFactory, NetFactory, PertFactory

public class DefaultDOMFactory
extends java.lang.Object
implements DOMFactory

DefaultDOMFactory can be used to serialize DOMStorable objects in a DOM with the use of a mapping between Java class names and DOM element names.

Version:
$Id: DefaultDOMFactory.java 604 2010-01-09 12:00:29Z rawcoder $
Author:
Werner Randelshofer.

Constructor Summary
DefaultDOMFactory()
          Creates a new instance.
 
Method Summary
 void addEnum(java.lang.String value, java.lang.Enum e)
          Adds an Enum value to the DOMFactory.
 void addEnumClass(java.lang.String name, java.lang.Class c)
          Adds an Enum class to the DOMFactory.
 void addStorable(java.lang.String name, DOMStorable prototype)
          Adds a DOMStorable prototype to the DOMFactory.
 void addStorableClass(java.lang.String name, java.lang.Class c)
          Adds a DOMStorable class to the DOMFactory.
 java.lang.Object create(java.lang.String name)
          Creates a DOMStorable object.
 java.lang.Enum createEnum(java.lang.String name, java.lang.String value)
          Creates an enum from the specified element name.
 java.lang.String getEnumName(java.lang.Enum e)
          Returns the element tag name for the specified Enum class.
 java.lang.String getEnumValue(java.lang.Enum e)
          Returns the enum tag name for the specified Enum instance.
 java.lang.String getName(DOMStorable o)
          Returns the element name for the specified object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDOMFactory

public DefaultDOMFactory()
Creates a new instance.

Method Detail

addStorableClass

public void addStorableClass(java.lang.String name,
                             java.lang.Class c)
Adds a DOMStorable class to the DOMFactory.


addStorable

public void addStorable(java.lang.String name,
                        DOMStorable prototype)
Adds a DOMStorable prototype to the DOMFactory.


addEnumClass

public void addEnumClass(java.lang.String name,
                         java.lang.Class c)
Adds an Enum class to the DOMFactory.


addEnum

public void addEnum(java.lang.String value,
                    java.lang.Enum e)
Adds an Enum value to the DOMFactory.


create

public java.lang.Object create(java.lang.String name)
Creates a DOMStorable object.

Specified by:
create in interface DOMFactory

getName

public java.lang.String getName(DOMStorable o)
Description copied from interface: DOMFactory
Returns the element name for the specified object. Note: The element names "string", "int", "float", "long", "double", "boolean", "enum" and "null" are reserved and must not be returned by this operation.

Specified by:
getName in interface DOMFactory

getEnumName

public java.lang.String getEnumName(java.lang.Enum e)
Description copied from interface: DOMFactory
Returns the element tag name for the specified Enum class.

Specified by:
getEnumName in interface DOMFactory

getEnumValue

public java.lang.String getEnumValue(java.lang.Enum e)
Description copied from interface: DOMFactory
Returns the enum tag name for the specified Enum instance.

Specified by:
getEnumValue in interface DOMFactory

createEnum

public java.lang.Enum createEnum(java.lang.String name,
                                 java.lang.String value)
Description copied from interface: DOMFactory
Creates an enum from the specified element name.

Specified by:
createEnum in interface DOMFactory

Copyright 1996-2010 (c) by the authors and contributors of the JHotDraw project.
Some rights reserved.