org.sapia.util.xml.confix
Class CompositeObjectFactory

java.lang.Object
  extended by org.sapia.util.xml.confix.CompositeObjectFactory
All Implemented Interfaces:
ObjectFactoryIF

public class CompositeObjectFactory
extends java.lang.Object
implements ObjectFactoryIF

This instance implements an ObjectFactoryIF that internally maps child object factories to XML namepspace prefixes OR URIs.

Author:
Jean-Cedric Desrochers
Copyright:
Copyright © 2002-2003 Sapia Open Source Software. All Rights Reserved.
License:
Read the license.txt file of the jar or visit the license page at the Sapia OSS web site

Constructor Summary
CompositeObjectFactory()
          Creates a new CompositeObjectFactory instance.
 
Method Summary
 boolean containsObjectFactory(java.lang.String aNamespaceURIorPrefix)
          Returns true if an object factory is internally mapped to the given namespace or prefix.
 ObjectFactoryIF getFactoryFor(java.lang.String aNamespaceURIorPrefix)
          Returns the child object factory internally mapped to the given namespace or prefix.
 CreationStatus newObjectFor(java.lang.String aPrefix, java.lang.String aNamespaceURI, java.lang.String anElementName, java.lang.Object aParent)
          Creates an object for the element passed in.
 void registerFactory(java.lang.String aNamespaceURIorPrefix, ObjectFactoryIF aFactory)
          Registers the object factory passed in for the namespace URI passed in.
 void setMapToPrefix(boolean mapToPrefix)
          Indicates if internal factories are mapped to namespace URIs or prefixes; if true, object factories are mapped to prefixes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeObjectFactory

public CompositeObjectFactory()
Creates a new CompositeObjectFactory instance.

Method Detail

setMapToPrefix

public void setMapToPrefix(boolean mapToPrefix)
Indicates if internal factories are mapped to namespace URIs or prefixes; if true, object factories are mapped to prefixes. By default, an instance of this class maps object factories to the URI.

Parameters:
mapToPrefix - if true, object factories are mapped to prefixes.

registerFactory

public void registerFactory(java.lang.String aNamespaceURIorPrefix,
                            ObjectFactoryIF aFactory)
Registers the object factory passed in for the namespace URI passed in.

Parameters:
aNamespaceURIorPrefix - The namespace URI or prefix to associate with the factory.
aFactory - The object factory to register.
Throws:
IllegalArgumentExcption - If a factory is already registered for the passed in namespace URI.

getFactoryFor

public ObjectFactoryIF getFactoryFor(java.lang.String aNamespaceURIorPrefix)
                              throws java.lang.IllegalArgumentException
Returns the child object factory internally mapped to the given namespace or prefix.

Parameters:
aNamespaceURIorPrefix - a XML namepsace prefix or URI.
Returns:
an ObjectFactoryIF.
Throws:
java.lang.IllegalArgumentException - if no factory can be found for the given namespace of prefix.

containsObjectFactory

public boolean containsObjectFactory(java.lang.String aNamespaceURIorPrefix)
Returns true if an object factory is internally mapped to the given namespace or prefix.

Returns:
true if an object factory is internally mapped to the given namespace or prefix.

newObjectFor

public CreationStatus newObjectFor(java.lang.String aPrefix,
                                   java.lang.String aNamespaceURI,
                                   java.lang.String anElementName,
                                   java.lang.Object aParent)
                            throws ObjectCreationException
Creates an object for the element passed in. This method in fact delegates object creation logic to the factory that is mapped to the given namespace OR prefix. Whether this method uses the namespace or prefix depends on the flag that was set through this instance's setMapToPrefix(...) method.

Specified by:
newObjectFor in interface ObjectFactoryIF
Parameters:
aPrefix - The namespace prefix of the element.
aNamespaceURI - The namespace URI of the element.
anElementName - The element name for wich to create an object.
aParent - The parent object of the object to create.
Throws:
ObjectCreationException - If an error occurs creating the object.
See Also:
setMapToPrefix(boolean)


Copyright © 2011 Sapia OSS. All Rights Reserved.