com.rubecula.darwin.domain.environment
Class TraitMap_

java.lang.Object
  extended by net.sf.tostring0.AToString
      extended by com.rubecula.darwin.domain.environment.TraitMap_
All Implemented Interfaces:
CacheSignature, Censusible, TraitMap, net.sf.tostring0.Identifiable, net.sf.tostring0.IToString
Direct Known Subclasses:
Phenotype_, TraitMap_ReadOnly

public abstract class TraitMap_
extends net.sf.tostring0.AToString
implements TraitMap

Abstract class to define base methods and fields for a String-keyed map of Variant objects. TODO whereas in practice the keys are the character keys, and whereas we use a phenotype cache which is based on TraitMap, we should change the initialization of the traits field to be a TreeMap, which will thus give us the traits, ordered by character key.

Author:
Robin Hillyard

Field Summary
 
Fields inherited from interface net.sf.tostring0.IToString
ANGBR_OPEN, ANGBRA_CLSE, BRA_CLSE, BRA_OPEN, BRCE_OPEN, BRCS_CLSE, COLON, LIST_SEPARATOR, MAX_ELEMENTS_DEFAULT, S_MT, S_PERCENT, SEPARATOR, SPACE
 
Constructor Summary
protected TraitMap_()
           
 
Method Summary
 boolean censusMe(Census census, java.lang.Object context)
          Method to census this object.
 boolean equals(java.lang.Object o)
           
 java.util.Collection<? extends Censusible> getCensusibleChildren()
          Method to return a list of censusible children of this object.
 java.lang.String getIdentifier()
           
 java.util.Set<java.lang.String> getKeys()
           
 java.lang.String getSignature()
           
 Trait getTrait(java.lang.String character)
          XXX
 java.util.Collection<Trait> getTraits()
          TEST
 int hashCode()
           
protected  void put(java.lang.String key, Trait value)
           
 int size()
          Method to get the number of traits in this map.
 
Methods inherited from class net.sf.tostring0.AToString
toString, toString, toStringBrief, toStringId
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TraitMap_

protected TraitMap_()
Method Detail

censusMe

public boolean censusMe(Census census,
                        java.lang.Object context)
Description copied from interface: Censusible
Method to census this object.

Specified by:
censusMe in interface Censusible
Parameters:
census - the census object which will present the results of taking this census
context - an arbitrary object which can be used by the census object to provide appropriate context for this object.
Returns:
true if we should continue censusing this object at deeper levels. If the result is false, then we do not call Censusible.getCensusibleChildren().
See Also:
Censusible.censusMe(com.rubecula.darwin.domain.helper.Census, java.lang.Object)

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

getCensusibleChildren

public java.util.Collection<? extends Censusible> getCensusibleChildren()
Description copied from interface: Censusible
Method to return a list of censusible children of this object.

Specified by:
getCensusibleChildren in interface Censusible
Returns:
either null or an ArrayList of censusible objects.
See Also:
Censusible.getCensusibleChildren()

getIdentifier

public java.lang.String getIdentifier()
Specified by:
getIdentifier in interface net.sf.tostring0.Identifiable
Returns:
the signature for this TraitMap
See Also:
Identifiable.getIdentifier()

getKeys

public java.util.Set<java.lang.String> getKeys()
Specified by:
getKeys in interface TraitMap
Returns:
the set of trait keys

getSignature

public java.lang.String getSignature()
Specified by:
getSignature in interface CacheSignature
Returns:
the traits as a String made up of character ":" variant "," ... variant. That is to say something which uniquely describes this TraitMap and can be used for determine a cache key.
See Also:
CacheSignature.getSignature()

getTrait

public Trait getTrait(java.lang.String character)
XXX

Specified by:
getTrait in interface TraitMap
Returns:
the Variant corresponding to name.
See Also:
TraitMap.getTrait(java.lang.String)

getTraits

public java.util.Collection<Trait> getTraits()
TEST

Specified by:
getTraits in interface TraitMap
Returns:
the set of traits.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

size

public int size()
Description copied from interface: TraitMap
Method to get the number of traits in this map. TODO consider eliminating this -- use getTraits().size() instead.

Specified by:
size in interface TraitMap
Returns:
the number of traits in this TraitMap
See Also:
TraitMap.size()

put

protected void put(java.lang.String key,
                   Trait value)
            throws DarwinException
Parameters:
key - the character key for this trait
value - the trait
Throws:
DarwinException - if the key is already present. This should never happen but if your application really thinks this is OK, then you can catch the exception. But you'll still only have one value for the trait.


Copyright © 2010 Rubecula Software, LLC. All Rights Reserved.