com.rubecula.darwin.domain.genetics
Class Allele_

java.lang.Object
  extended by net.sf.tostring0.AToString
      extended by com.rubecula.darwin.domain.helper.Attribute_
          extended by com.rubecula.darwin.domain.genetics.Allele_
All Implemented Interfaces:
Allele, Attribute, Basic, CacheSignature, Censusible, net.sf.tostring0.Identifiable, net.sf.tostring0.IToString
Direct Known Subclasses:
Allele_Binary, Allele_Number

public abstract class Allele_
extends Attribute_
implements Allele

This abstract provides base operations for implementations of Allele, which are specific, competing genes which may appear at a Locus.

In general, an allele can have a key and a value, both being objects. If the key is null, then the value, reduced to a String, serves as its key. Normally, known alleles are defined via configuration. But new alleles (mutants) can arise during an evolution. For these, there is an AlleleFactory.

In all cases, however, an Allele is immutable regarding its value. Once constructed, the value cannot be changed. The value of the (parent) locus is set once and once only.

Version:
$Revision: 1.29 $
Author:
Robin Hillyard

Field Summary
protected static org.apache.commons.logging.Log LOG
          The logger for this class.
 
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 Allele_(java.lang.Object value)
          Constructor of an Allele_ based on a specific value.
protected Allele_(java.lang.Object key, java.lang.Object value)
          Primary Private constructor of an Allele_ based on a specific value.
 
Method Summary
 boolean censusMe(Census census, java.lang.Object context)
          Method to census this object.
 java.util.Collection<? extends Censusible> getCensusibleChildren()
          Method to return a list of censusible children of this object.
 Locus getLocus()
          Return the value of locus.
 java.lang.String getSignature()
           
protected  int getStringChars()
           
 void setLocus(Locus locus)
          Set the value of the locus for this Allele.
 void setStringChars(int stringChars)
          Set the number of characters that we should see when we create a string of this Allele.
 void setValue(java.lang.Object value)
          set the field Attribute_.value.
 java.lang.String toString(boolean showDetail, boolean showClass, boolean showIdentifier, boolean includeParent, boolean includeChildren, java.lang.String prefix, boolean recurse, int maxElements, int maxChars)
           
 
Methods inherited from class com.rubecula.darwin.domain.helper.Attribute_
equals, getAttribute, getIdentifier, getValue, hashCode
 
Methods inherited from class net.sf.tostring0.AToString
toString, toStringBrief, toStringId
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.rubecula.darwin.domain.helper.Attribute
getAttribute, getValue
 
Methods inherited from interface net.sf.tostring0.IToString
toStringBrief, toStringId
 
Methods inherited from interface com.rubecula.darwin.domain.helper.Basic
getBases
 
Methods inherited from interface net.sf.tostring0.Identifiable
getIdentifier
 

Field Detail

LOG

protected static final org.apache.commons.logging.Log LOG
The logger for this class.

Constructor Detail

Allele_

protected Allele_(java.lang.Object value)
Constructor of an Allele_ based on a specific value. The key will be the value, in the form of a String. XXX this constructor is used only by unit tests.

Parameters:
value - the value for the new Allele_, as an Object.

Allele_

protected Allele_(java.lang.Object key,
                  java.lang.Object value)
Primary Private constructor of an Allele_ based on a specific value.

Parameters:
key - the key for the new Allele_, as an Object.
value - the value for the new Allele_, as an Object.
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)

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()

getLocus

public Locus getLocus()
Return the value of locus.

Specified by:
getLocus in interface Allele
Returns:
the locus to which this allele can belong.
See Also:
Allele.getLocus()

getSignature

public java.lang.String getSignature()
Specified by:
getSignature in interface CacheSignature
Returns:
a "signature" for this object which can be used to form part of a cache key. The signature is similar in a sense to the hash code but typically, it is based more on mutable components of an object than is the hash code.
See Also:
CacheSignature.getSignature()

setLocus

public void setLocus(Locus locus)
Set the value of the locus for this Allele. This is not set in the constructor. TODO why is it not set in the constructor?

Specified by:
setLocus in interface Allele
See Also:
Allele.setLocus(com.rubecula.darwin.domain.helper.Locus)

setStringChars

public void setStringChars(int stringChars)
Set the number of characters that we should see when we create a string of this Allele. By default, the number is 1. We only increase it to N+1 if there are allele identifiers that share the first N characters.

Parameters:
stringChars - the stringChars to set

setValue

public void setValue(java.lang.Object value)
Description copied from class: Attribute_
set the field Attribute_.value.

Specified by:
setValue in interface Attribute
Overrides:
setValue in class Attribute_
Parameters:
value - the new value for the attribute.
See Also:
Attribute_.setValue(java.lang.Object)

toString

public java.lang.String toString(boolean showDetail,
                                 boolean showClass,
                                 boolean showIdentifier,
                                 boolean includeParent,
                                 boolean includeChildren,
                                 java.lang.String prefix,
                                 boolean recurse,
                                 int maxElements,
                                 int maxChars)
Specified by:
toString in interface net.sf.tostring0.IToString
Overrides:
toString in class Attribute_
See Also:
Attribute_.toString(boolean, boolean, boolean, boolean, boolean, java.lang.String, boolean, int, int)

getStringChars

protected int getStringChars()
Returns:
the stringChars


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