JHotDraw 6.0b1

org.jhotdraw.contrib.html
Class ContentProducerRegistry

java.lang.Object
  extended by org.jhotdraw.contrib.html.ContentProducerRegistry
All Implemented Interfaces:
java.io.Serializable, Storable

public class ContentProducerRegistry
extends java.lang.Object
implements java.io.Serializable, Storable

ContentProducerRegistry acts as a repository for ContentProducers. It allows for registries to be organized in a hierarchy, so that a specific producer request will travel upwards in the hierarchy until eventually a suitable producer is found.
Producers are registered associated with the class of the object they are suitable to produce contents for, but ContentProducerRegistry allows for class hierarchy searches. What this means is that for two classes A and B, B being a subclass of A, if a producer is registered for class B it will be used, otherwise the producer registered for class A will be used instead. ContentProducerRegistry will always select the super class closest in the class hierarchy, so if several producers are registered for classes in a derivation hierarchy, the producer registered for the class closest to the requested class will be selected.

See Also:
Serialized Form

Constructor Summary
ContentProducerRegistry()
          Constructor for the ContentProducerRegistry object
ContentProducerRegistry(ContentProducerRegistry parent)
          Constructor for the ContentProducerRegistry object
 
Method Summary
 ContentProducer getContentProducer(java.lang.Class targetClass)
          Finds the most appropriate producer for the target class.
static ContentProducer getDefaultContentProducer(java.lang.Class targetClass)
          Gets the ContentProducer attribute of the HTMLTextAreaFigure object
 ContentProducer getExactContentProducer(java.lang.Class targetClass)
          Finds the exact producer for the target class, ie: no class hierarchy search
static ContentProducer getExactDefaultContentProducer(java.lang.Class targetClass)
          Gets the exact application global Producer for the target class, ie: no class hierarchy search
 ContentProducerRegistry getParent()
          Gets the parent attribute of the ContentProducerRegistry object
protected  ContentProducer getSuperClassContentProducer(java.lang.Class targetClass, java.lang.Class closestClass)
          Gets the producers for the closest super class of the target class
 boolean isAutonomous()
          Gets the autonomous status of the ContentProducerRegistry object
 void read(StorableInput dr)
          Storable inoput support
 ContentProducer registerContentProducer(java.lang.Class targetClass, ContentProducer producer)
          Registers a producer
static ContentProducer registerDefaultContentProducer(java.lang.Class targetClass, ContentProducer producer)
          Registers an application global producer
 void setAutonomous()
          Sets the autonomous attribute of the ContentProducerRegistry object.
 void setParent(ContentProducerRegistry newParent)
          Sets the parent attribute of the ContentProducerRegistry object
 void unregisterContentProducer(java.lang.Class targetClass, ContentProducer producer)
          Unregisters a producer
static void unregisterDefaultContentProducer(java.lang.Class targetClass, ContentProducer producer)
          Unregisters ie: removes a registered producer for a target class.
A check is made to ensure the removed producer is the current producer for the target class.
 void write(StorableOutput dw)
          Storable write support
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentProducerRegistry

public ContentProducerRegistry()
Constructor for the ContentProducerRegistry object


ContentProducerRegistry

public ContentProducerRegistry(ContentProducerRegistry parent)
Constructor for the ContentProducerRegistry object

Parameters:
parent - the parent for this producer
Method Detail

setAutonomous

public void setAutonomous()
Sets the autonomous attribute of the ContentProducerRegistry object. Similar to setting the parent to null
An autonomous registry does not have a parent hierarchy so resolution of search requests stop do not propagate.

See Also:
setParent(ContentProducerRegistry)

isAutonomous

public boolean isAutonomous()
Gets the autonomous status of the ContentProducerRegistry object

Returns:
The autonomous value

setParent

public void setParent(ContentProducerRegistry newParent)
Sets the parent attribute of the ContentProducerRegistry object

Parameters:
newParent - The new parent value
See Also:
setAutonomous()

getParent

public ContentProducerRegistry getParent()
Gets the parent attribute of the ContentProducerRegistry object

Returns:
The parent value

registerDefaultContentProducer

public static ContentProducer registerDefaultContentProducer(java.lang.Class targetClass,
                                                             ContentProducer producer)
Registers an application global producer

Parameters:
producer - the registered producer
targetClass - The class associated with the producer
Returns:
the previous producer registered for the target class

unregisterDefaultContentProducer

public static void unregisterDefaultContentProducer(java.lang.Class targetClass,
                                                    ContentProducer producer)
Unregisters ie: removes a registered producer for a target class.
A check is made to ensure the removed producer is the current producer for the target class. If not, the request is ignored.

Parameters:
producer - the producer to unregister
targetClass - the target class

getDefaultContentProducer

public static ContentProducer getDefaultContentProducer(java.lang.Class targetClass)
Gets the ContentProducer attribute of the HTMLTextAreaFigure object

Parameters:
targetClass - the target class
Returns:
the previous producer registered for the target class

getExactDefaultContentProducer

public static ContentProducer getExactDefaultContentProducer(java.lang.Class targetClass)
Gets the exact application global Producer for the target class, ie: no class hierarchy search

Parameters:
targetClass - the target class
Returns:
The producer

registerContentProducer

public ContentProducer registerContentProducer(java.lang.Class targetClass,
                                               ContentProducer producer)
Registers a producer

Parameters:
producer - the producer to register
targetClass - the target class
Returns:
the previous producer registered for the target class

unregisterContentProducer

public void unregisterContentProducer(java.lang.Class targetClass,
                                      ContentProducer producer)
Unregisters a producer

Parameters:
producer - the producer to unregister
targetClass - the target class

getContentProducer

public ContentProducer getContentProducer(java.lang.Class targetClass)
Finds the most appropriate producer for the target class. Will search first for exact producers, ie: no class hierarchy search, then if none found, will do a class compatible search

Parameters:
targetClass - The target class
Returns:
The producer

getExactContentProducer

public ContentProducer getExactContentProducer(java.lang.Class targetClass)
Finds the exact producer for the target class, ie: no class hierarchy search

Parameters:
targetClass - The target class
Returns:
The producer

getSuperClassContentProducer

protected ContentProducer getSuperClassContentProducer(java.lang.Class targetClass,
                                                       java.lang.Class closestClass)
Gets the producers for the closest super class of the target class

Parameters:
targetClass - The target class
Returns:
The producer

write

public void write(StorableOutput dw)
Storable write support

Specified by:
write in interface Storable
Parameters:
dw - the storable output

read

public void read(StorableInput dr)
          throws java.io.IOException
Storable inoput support

Specified by:
read in interface Storable
Parameters:
dr - storable input
Throws:
java.io.IOException - thrown by called methods

JHotDraw 6.0b1