|
SAP NetWeaver '04 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.sap.netweaver.bc.rf.util.flyweight.FlyWeight
Abstract class implementing the flyweight pattern. You have to extend this class and make all methods derived from this abstract class final (except for toString())! This is necessary in order to ensure, that no class can be derived from your class overriding and thereby changing the inner mechanism to create an flyweight instance only once, return the same object on clone() etc. It is of greatest importance to ensure that both the id and the flyweight object itself are immutable! Preknown flyweight instances may be added as public final static flyweight members. If you just need to have the predefined flyweight instances, implement an appropriate private constructor, otherwise make it public:
public class Property extends FlyWeight
{
public final static Property RO = new Property( "RO" );
public final static Property MV = new Property( "MV" );
private Property ( final Serializable id )
{
super( id );
}
}
| Constructor Summary | |
protected |
FlyWeight(java.io.Serializable id,
boolean ignoreDuplicateRegistration)
Construct instance of a flyweight. |
| Method Summary | |
java.lang.Object |
clone()
Clone this flyweight. |
boolean |
equals(java.lang.Object obj)
Compare this and another object for equality. |
static java.util.List |
getAllFlyWeights(java.lang.Class flyWeightClass)
Get all so far registered flyweight instances of the given flyweight class. |
static java.util.List |
getAllFlyWeightsInherited(java.lang.Class flyWeightClass)
Get all so far registered flyweight instances of the given flyweight class and all sub classes of that class. |
static FlyWeight |
getFlyWeight(java.lang.Class flyWeightClass,
java.io.Serializable id)
Get flyweight instance by id of the given flyweight class. |
java.io.Serializable |
getFlyWeightId()
Get id of the flyweight instance. |
static FlyWeight |
getFlyWeightInherited(java.lang.Class flyWeightClass,
java.io.Serializable id)
Get flyweight instance by id of the given flyweight class and all sub classes of that class. |
int |
hashCode()
Get hashcode for this flyweight instance. |
static java.util.List |
removeAllFlyWeights(java.lang.Class flyWeightClass)
Remove all so far registered flyweight instances of the given flyweight class. |
static java.util.List |
removeAllFlyWeightsInherited(java.lang.Class flyWeightClass)
Remove all so far registered flyweight instances of the given flyweight class and all sub classes of that class. |
static FlyWeight |
removeFlyWeight(java.lang.Class flyWeightClass,
java.io.Serializable id)
Remove flyweight instance by id of the given flyweight class. |
static FlyWeight |
removeFlyWeightInherited(java.lang.Class flyWeightClass,
java.io.Serializable id)
Remove flyweight instance by id of the given flyweight class and all sub classes of that class. |
java.lang.String |
toString()
Get descriptive text for this flyweight instance. |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
protected FlyWeight(java.io.Serializable id,
boolean ignoreDuplicateRegistration)
throws java.lang.IllegalArgumentException
id - flyweight idignoreDuplicateRegistration - when true, don't throw
IllegalArgumentException exception when the id is already in usejava.lang.IllegalArgumentException - when the id is already in use| Method Detail |
public java.io.Serializable getFlyWeightId()
public java.lang.String toString()
toString in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - object to be compared againstpublic java.lang.Object clone()
clone in class java.lang.Object
public static FlyWeight getFlyWeight(java.lang.Class flyWeightClass,
java.io.Serializable id)
id - flyweight idflyWeightClass - flyweight class
public static FlyWeight getFlyWeightInherited(java.lang.Class flyWeightClass,
java.io.Serializable id)
id - flyweight idflyWeightClass - flyweight class
public static FlyWeight removeFlyWeight(java.lang.Class flyWeightClass,
java.io.Serializable id)
id - flyweight idflyWeightClass - flyweight class
public static FlyWeight removeFlyWeightInherited(java.lang.Class flyWeightClass,
java.io.Serializable id)
id - flyweight idflyWeightClass - flyweight classpublic static java.util.List getAllFlyWeights(java.lang.Class flyWeightClass)
flyWeightClass - flyweight class for which all instances should be
looked uppublic static java.util.List getAllFlyWeightsInherited(java.lang.Class flyWeightClass)
flyWeightClass - flyweight class (all sub classes of that class will
also be checked) for which all instances should be looked uppublic static java.util.List removeAllFlyWeights(java.lang.Class flyWeightClass)
flyWeightClass - flyweight class for which all instances should be
removedpublic static java.util.List removeAllFlyWeightsInherited(java.lang.Class flyWeightClass)
flyWeightClass - flyweight class (all sub classes of that class will
also be checked) for which all instances should be removed
|
SAP NetWeaver '04 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||