com.tensegrity.generic.persistence
Class EntityRegistry

java.lang.Object
  extended bycom.tensegrity.generic.persistence.EntityRegistry

public class EntityRegistry
extends java.lang.Object

The EntityRegistry can be used to collect frequently occuring Attribute's when it comes to storing them in XML documents. Every Attribute that appears multiple times can be replaced with a short reference to an entity. Method getEntitiesForDTD() returns the needed the Entity definitions needed for the corresponding XML document.

Version:
$Id: EntityRegistry.java,v 1.16 2006/04/26 09:24:19 BurkhardWick Exp $
Author:
Andreas Ebbert

Method Summary
 void addCandidate(Attribute attribute, java.lang.String entityName)
          Adds an Attribute as a possible candidate for XML write out to this registry.
 void addCandidate(java.lang.String name)
           
 void addCollectionAsCandidate(Attribute topLevelAttribute, java.lang.String entityName)
          Add an attribute holding an AttributeCollection with depth 1 to the list of entity candidates.
 void checkCandidate(Attribute attribute)
           
 void checkCandidates(AttributeCollection attributes)
           
static void destroy()
          Explicitly kill this instance, so that the GC can do his work.
 void dump()
          Dumps out the content of the entity pool.
static boolean getEnabled()
          Returns true, if the the accumulation of entities is enabled.
 java.lang.String getEntitiesForDTD()
          Returns the entity definitions.
 java.lang.String getEntityName(Attribute attribute)
          Returns the entity name for the given Attribute.
static EntityRegistry getInstance()
          Returns an instance of the EntityRegistry.
 boolean isEmpty()
          Indicates whether the pool for entities is empty.
 boolean isEntity(Attribute attribute)
          Returns true, if the given Attribute is an Entity.
static void setEnabled(boolean b)
          En- / disables the accumulation of entities globally.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static EntityRegistry getInstance()
Returns an instance of the EntityRegistry.

Returns:
an instance of the EntityRegistry.

destroy

public static void destroy()
Explicitly kill this instance, so that the GC can do his work. An instance is only needed during write out time.


addCandidate

public void addCandidate(Attribute attribute,
                         java.lang.String entityName)
Adds an Attribute as a possible candidate for XML write out to this registry. The entity declaration for this Attribute will get the name given by entityName.

Parameters:
attribute - the Attribute to add.
entityName - a name for this Entity.

addCollectionAsCandidate

public void addCollectionAsCandidate(Attribute topLevelAttribute,
                                     java.lang.String entityName)
Add an attribute holding an AttributeCollection with depth 1 to the list of entity candidates.
Note: Only AttributeCollection with depth 1 will be accepted.

Parameters:
topLevelAttribute - the top-level attribute holding the AttributeSet or AttributeList.
entityName - a name for this Entity.

isEntity

public boolean isEntity(Attribute attribute)
Returns true, if the given Attribute is an Entity. An Attribute is supposed to be an entity if it's in the map more than twice.

Parameters:
attribute - the Attribute to look up.
Returns:
true, if the given Attribute is an Entity.

getEntityName

public java.lang.String getEntityName(Attribute attribute)
Returns the entity name for the given Attribute. This method is needed during write out replacement of Attributes.

Parameters:
attribute - the Attribute to look up the name for.
Returns:
the entity name for the given Attribute.

getEntitiesForDTD

public java.lang.String getEntitiesForDTD()
Returns the entity definitions. The returned String can be put directly into the header of an XML-file.

Returns:
the entity definitions.

isEmpty

public boolean isEmpty()
Indicates whether the pool for entities is empty.

Returns:
true, if the entity pool is empty.

setEnabled

public static void setEnabled(boolean b)
En- / disables the accumulation of entities globally.

Parameters:
b - true enables the accumulation of entities.

getEnabled

public static boolean getEnabled()
Returns true, if the the accumulation of entities is enabled.

Returns:
true, if the the accumulation of entities is enabled.

dump

public void dump()
Dumps out the content of the entity pool. For debugging purposes.


addCandidate

public void addCandidate(java.lang.String name)

checkCandidate

public void checkCandidate(Attribute attribute)

checkCandidates

public void checkCandidates(AttributeCollection attributes)


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.