org.openspml.v2.util.xml
Class ObjectFactory

java.lang.Object
  extended byorg.openspml.v2.util.xml.ObjectFactory

public class ObjectFactory
extends java.lang.Object

This is a singleton class that will, given a name of a Marshallable element, return an object of that type. The object will be empty.

Author:
kent.spaulding@sun.com

Date: Mar 2, 2006


Nested Class Summary
static interface ObjectFactory.MarshallableCreator
          You can register objects to create wrappers for the unmarshalling.
static interface ObjectFactory.OCEUnmarshaller
          Implement these to adapt the OpenContentElement stuff to the toolkit.
static interface ObjectFactory.ProfileRegistrar
           
 
Method Summary
 void addCreator(ObjectFactory.MarshallableCreator creator)
           
 void addOCEUnmarshaller(ObjectFactory.OCEUnmarshaller oceum)
          Need to register an unmarshaller for OpenContent - call this.
 Marshallable createMarshallable(java.lang.String name, java.lang.String uri)
          given a name of an element, create a hollow object that we can populate via a parser.
 MarshallableElement createMarshallableElement(java.lang.Class cls)
          XMLUnmarshaller implementations will use this to create objects within the core SPML schema.
static ObjectFactory getInstance()
          This is a Singleton.
 java.lang.String register(ObjectFactory.ProfileRegistrar pr)
          Used to register profiles.
 boolean removeCreator(ObjectFactory.MarshallableCreator creator)
           
 boolean removeOCEUnmarshaller(ObjectFactory.OCEUnmarshaller oceum)
          You can unregister them too.
 OpenContentElement unmarshallOpenContentElement(java.lang.Object obj)
          XMLUnmarshaller implementations need to to handle OpenContentElements.
 boolean unregister(ObjectFactory.ProfileRegistrar pr)
          Shortcut for the unregister(String profileId) method.
 boolean unregister(java.lang.String profileId)
          Given the id of the profile, unregister it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createMarshallable

public Marshallable createMarshallable(java.lang.String name,
                                       java.lang.String uri)
                                throws UnknownSpml2TypeException
given a name of an element, create a hollow object that we can populate via a parser.

Parameters:
name -
uri - (the uri of the namespace)
Returns:
a hollow Marshallable for the name and uri...
Throws:
UnknownSpml2TypeException

createMarshallableElement

public MarshallableElement createMarshallableElement(java.lang.Class cls)
                                              throws UnknownSpml2TypeException
XMLUnmarshaller implementations will use this to create objects within the core SPML schema.

Parameters:
cls -
Returns:
the hollow instance of the given class.
Throws:
UnknownSpml2TypeException

addOCEUnmarshaller

public void addOCEUnmarshaller(ObjectFactory.OCEUnmarshaller oceum)
Need to register an unmarshaller for OpenContent - call this.

Parameters:
oceum -

removeOCEUnmarshaller

public boolean removeOCEUnmarshaller(ObjectFactory.OCEUnmarshaller oceum)
You can unregister them too.

Parameters:
oceum -
Returns:
true if we found it can removed it.

unmarshallOpenContentElement

public OpenContentElement unmarshallOpenContentElement(java.lang.Object obj)
                                                throws Spml2Exception
XMLUnmarshaller implementations need to to handle OpenContentElements.

Parameters:
obj -
Returns:
null if we cannot create one, otherwise, an object from the xmlRep
Throws:
Spml2Exception

addCreator

public void addCreator(ObjectFactory.MarshallableCreator creator)
Parameters:
creator -

removeCreator

public boolean removeCreator(ObjectFactory.MarshallableCreator creator)
Parameters:
creator -
Returns:
true if removed it.

register

public java.lang.String register(ObjectFactory.ProfileRegistrar pr)
Used to register profiles. This makes it easier to put all the info about a profile into one class. e.g. if a profile use several packages and creators, one can place the code that adds them to the factory into a single Registrar and pass it along.

// DSMLProfileRegistrar adds a creator for spmldsml and dsml. ObjectFactory.getInstance().register( new DSMLProfileRegistrar());

Parameters:
pr - The registrar to use and track.

unregister

public boolean unregister(java.lang.String profileId)
Given the id of the profile, unregister it.

Parameters:
profileId -
Returns:
true iff the profileId was known and unregister was called.

unregister

public boolean unregister(ObjectFactory.ProfileRegistrar pr)
Shortcut for the unregister(String profileId) method.

Parameters:
pr - A registrar...
Returns:
true if the pr was successfully unregistered.

getInstance

public static ObjectFactory getInstance()
This is a Singleton.

Returns:
the singleton instance of this class.


Copyright © Sun Microsystems, Inc. All Rights Reserved.