org.concord.biologica.engine
Class Family

java.lang.Object
  |
  +--org.xml.sax.HandlerBase
        |
        +--org.concord.biologica.engine.EngineObject
              |
              +--org.concord.biologica.engine.Family
All Implemented Interfaces:
org.xml.sax.DocumentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, java.io.Serializable

public final class Family
extends EngineObject
implements java.io.Serializable

This class represents a family of diploid organisms consisting of a female parent organism, a male parent organism and a set of child organisms.

An instance of this class is contained by one world.

An object of this class will generate the following property change events:

Version:
$Revision: 1.2 $ $Date: 2001/09/12 18:09:24 $
Author:
$Author: bdias $
See Also:
EngineProp.DELETED, EngineProp.ID, EngineProp.LOCKED_STATE, EngineProp.CHILD_ADDED, EngineProp.CHILD_REMOVED, PropertyChangeListener, Serialized Form

Fields inherited from class org.concord.biologica.engine.EngineObject
AUTOMATIC_LOCKED, AUTOMATIC_LOCKED_STRING, changes, deleted, FALSE, id, lockedState, MANUAL_AND_AUTOMATIC_LOCKED, MANUAL_AND_AUTOMATIC_LOCKED_STRING, MANUAL_LOCKED, MANUAL_LOCKED_STRING, NULL_ID, TRUE, UNLOCKED, UNLOCKED_STRING, xmlElementContext
 
Constructor Summary
Family(Organism aParentOrganismOne, Organism aParentOrganismTwo, int aNumberOfChildren)
          Create a family from a given set of 2 parents, creating the number of children specified.
Family(Organism aParentOrganismOne, Organism aParentOrganismTwo, int aNumberOfChildren, boolean onlyLiveChildren)
          Create a family from a given set of 2 parents, creating the number of children specified and also respecting whether or not the children should all be alive.
Family(Organism aParentOrganismOne, Organism aParentOrganismTwo, int aNumberOfFemaleChildren, int aNumberOfMaleChildren)
          Create a family from a given set of 2 parents, creating the number of female and male children specified.
Family(Organism aParentOrganismOne, Organism aParentOrganismTwo, int aNumberOfFemaleChildren, int aNumberOfMaleChildren, boolean onlyLiveChildren)
          Create a family from a given set of 2 parents, creating the number of female and male children specified.
Family(Organism aParentOrganismOne, Organism aParentOrganismTwo, Organism aChildOrganism)
          Create a family from a given set of 2 parents and one child.
Family(Organism aParentOrganismOne, Organism aParentOrganismTwo, java.util.Vector aChildrenVector)
          Create a family from a given set of 2 parents and optionally some children.
Family(World aWorld, java.lang.String anElementName, int anElementID, com.sun.xml.parser.Parser anXMLParser, ImportContext importContext)
          Create a new family and start handling XML parsing events to set the properties of this object.
 
Method Summary
 void addChild(Organism aChild)
          Adds a child organism to this fammmily.
 java.util.Vector addChildren(int aNumberOfChildren, boolean onlyLiveChildren)
           
 java.util.Vector addChildren(int aNumberOfFemaleChildren, int aNumberOfMaleChildren, boolean onlyLiveChildren)
           
 void characters(char[] ch, int start, int length)
          Receive notification of character data.
 void delete()
          Delete this object, notifying parent objects and deleting any child objects.
 void delete(boolean notifyChange)
           
 void delete(boolean notifyChange, boolean deleteChildren)
           
 void endElement(java.lang.String anElementName)
          Handle notification that the parsing of the given element has ended.
 int getCharacteristicCount(java.lang.String aCharacteristicName)
           
 java.util.Enumeration getChildren()
          Returns an enumeration over the children organisms of this family.
 Organism getFemaleParent()
          Returns the female parent organism.
 int getGeneration()
          Get the generation of this family.
 Organism getMaleParent()
          Returns the male parent organism.
 int getNumberOfChildren()
          Return the number of children of this family.
 World getWorld()
          Get the world containing this object.
 void ignorableWhitespace(char[] ch, int start, int length)
          Receive notification of ignorable white space character data.
 boolean isChild(Organism organism)
           
 void setAutomaticLocked(boolean automaticLocked)
          Set or unset the automatic locked state of this object, leaving other components of the locked state untouched.
 void setLockedState(int aLockedState)
          Set the locked state of the object, recursively setting the locked state of children objects.
 void setManualLocked(boolean manualLocked)
          Set or unset the manual locked state of this object, leaving other components of the locked state untouched.
 void startElement(java.lang.String anElementName, org.xml.sax.AttributeList amap)
          Handle notification that the parser has hit the start of a new element with the given name and attributes.
 java.lang.String toString()
          Return a string representation of this object, usually the object's name.
 void writeToStream(java.io.PrintWriter stream)
          Writes this object to the given stream in XML format.
 
Methods inherited from class org.concord.biologica.engine.EngineObject
addPropertyChangeListener, getID, getLockedState, getLockedStateAsString, isAutomaticLocked, isDeleted, isLocked, isManualLocked, notifySelected, release, removePropertyChangeListener, setID, setLockedStateAsString
 
Methods inherited from class org.xml.sax.HandlerBase
endDocument, error, fatalError, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, startDocument, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Family

public Family(Organism aParentOrganismOne,
              Organism aParentOrganismTwo,
              java.util.Vector aChildrenVector)
Create a family from a given set of 2 parents and optionally some children.

Parameters:
aParentOrganismOne - Organism - a parent organism, can be male or female, may not be null or NO_SEX
aParentOrganismTwo - Organism - a parent organism, must be other sex of anOrganismOne, may not be null or NO_SEX
aChildrenVector - Vector - a vector of children organisms, may be null or empty
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal

Family

public Family(Organism aParentOrganismOne,
              Organism aParentOrganismTwo,
              Organism aChildOrganism)
Create a family from a given set of 2 parents and one child. This is a convenience method equivalent to the above constructor. This constructor just takes a single child, making it easier for the meiosis / fertilization code to create a family.

Parameters:
aParentOrganismOne - Organism - a parent organism, can be male or female, may not be null or NO_SEX
aParentOrganismTwo - Organism - a parent organism, must be other sex of anOrganismOne, may not be null or NO_SEX
aChildOrganism - Organism - a child organism, may be null
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal

Family

public Family(Organism aParentOrganismOne,
              Organism aParentOrganismTwo,
              int aNumberOfChildren,
              boolean onlyLiveChildren)
Create a family from a given set of 2 parents, creating the number of children specified and also respecting whether or not the children should all be alive.

Parameters:
aParentOrganismOne - Organism - a parent organism, can be male or female, may not be null or NO_SEX
aParentOrganismTwo - Organism - a parent organism, must be other sex of anOrganismOne, may not be null or NO_SEX
aNumberOfChildren - int - the number of children to be created
onlyLiveChildren - boolean - only create live children
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal

Family

public Family(Organism aParentOrganismOne,
              Organism aParentOrganismTwo,
              int aNumberOfChildren)
Create a family from a given set of 2 parents, creating the number of children specified. Children will NOT be limited to alive.

Parameters:
aParentOrganismOne - Organism - a parent organism, can be male or female, may not be null or NO_SEX
aParentOrganismTwo - Organism - a parent organism, must be other sex of anOrganismOne, may not be null or NO_SEX
aNumberOfChildren - int - the number of children to be created
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal

Family

public Family(Organism aParentOrganismOne,
              Organism aParentOrganismTwo,
              int aNumberOfFemaleChildren,
              int aNumberOfMaleChildren,
              boolean onlyLiveChildren)
Create a family from a given set of 2 parents, creating the number of female and male children specified.

Parameters:
aParentOrganismOne - Organism - a parent organism, can be male or female, may not be null or NO_SEX
aParentOrganismTwo - Organism - a parent organism, must be other sex of anOrganismOne, may not be null or NO_SEX
aNumberOfFemaleChildren - int - the number of female children to be created
aNumberOfMaleChildren - int - the number of male children to be created
onlyLiveChildren - boolean - only create live children
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal

Family

public Family(Organism aParentOrganismOne,
              Organism aParentOrganismTwo,
              int aNumberOfFemaleChildren,
              int aNumberOfMaleChildren)
Create a family from a given set of 2 parents, creating the number of female and male children specified. Children will NOT be limited to alive.

Parameters:
aParentOrganismOne - Organism - a parent organism, can be male or female, may not be null or NO_SEX
aParentOrganismTwo - Organism - a parent organism, must be other sex of anOrganismOne, may not be null or NO_SEX
aNumberOfFemaleChildren - int - the number of female children to be created
aNumberOfMaleChildren - int - the number of male children to be created
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal

Family

public Family(World aWorld,
              java.lang.String anElementName,
              int anElementID,
              com.sun.xml.parser.Parser anXMLParser,
              ImportContext importContext)
Create a new family and start handling XML parsing events to set the properties of this object.

Parameters:
aWorld - World - the enclosing world for this new species
anElementName - String - the element name
anElementID - int - the element id
anXMLParser - com.sun.xml.parser.Parser - the element parser
importContext - ImportContext - import context for mapping ids from file to this world
Throws:
java.lang.IllegalArgumentException - - input arguments illegal
Method Detail

addChildren

public java.util.Vector addChildren(int aNumberOfChildren,
                                    boolean onlyLiveChildren)

addChildren

public java.util.Vector addChildren(int aNumberOfFemaleChildren,
                                    int aNumberOfMaleChildren,
                                    boolean onlyLiveChildren)

startElement

public void startElement(java.lang.String anElementName,
                         org.xml.sax.AttributeList amap)
                  throws org.xml.sax.SAXException
Handle notification that the parser has hit the start of a new element with the given name and attributes.

For internal elements (elements that are non-EngineObject instance variables of this object), call xmlElementContext.startElement() and xmlElementContext will receive the remaining element notifications. For external elements (elements that are EngineObject instance variables of this object), create an object of the appropriate class and that object will receive the remaining element notifications.

Overrides:
startElement in class org.xml.sax.HandlerBase
Parameters:
anElementName - String - name of element
amap - AttributeList - an attribute list

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Receive notification of character data.
Overrides:
characters in class org.xml.sax.HandlerBase
Parameters:
ch - char[] - characters
start - int - start of string
length - int - length of string

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws org.xml.sax.SAXException
Receive notification of ignorable white space character data.
Overrides:
ignorableWhitespace in class org.xml.sax.HandlerBase
Parameters:
ch - char[] - characters
start - int - start of string
length - int - length of string

endElement

public void endElement(java.lang.String anElementName)
                throws org.xml.sax.SAXException
Handle notification that the parsing of the given element has ended.
Overrides:
endElement in class org.xml.sax.HandlerBase
Parameters:
anElementName - String - the element name

delete

public void delete()
Delete this object, notifying parent objects and deleting any child objects.

When this method is called, a property change event is generated for the property named EngineProp.DELETED.

Overrides:
delete in class EngineObject

delete

public void delete(boolean notifyChange)

delete

public void delete(boolean notifyChange,
                   boolean deleteChildren)

setAutomaticLocked

public void setAutomaticLocked(boolean automaticLocked)
Set or unset the automatic locked state of this object, leaving other components of the locked state untouched. Recursively sets the automatic locked state of children of this object.

When this property is changed, a property change event is fired for the property named EngineProp.LOCKED_STATE.

Overrides:
setAutomaticLocked in class EngineObject
Parameters:
automaticLocked - boolean - object should be automatic locked (true) or not (false)

setManualLocked

public void setManualLocked(boolean manualLocked)
Set or unset the manual locked state of this object, leaving other components of the locked state untouched. Recursively sets the manual locked state of children of this object.

When this property is changed, a property change event is fired for the property named EngineProp.LOCKED_STATE.

Overrides:
setManualLocked in class EngineObject
Parameters:
manualLocked - boolean - object should be manually locked (true) or not (false)

setLockedState

public void setLockedState(int aLockedState)
Set the locked state of the object, recursively setting the locked state of children objects.

When this property is changed, a property change event is fired for the property named EngineProp.LOCKED_STATE.

Overrides:
setLockedState in class EngineObject
Parameters:
aLockedState - int - new locked state of this object
Throws:
java.lang.IllegalArgumentException - - new locked state invalid

toString

public java.lang.String toString()
Return a string representation of this object, usually the object's name.

Overrides:
toString in class EngineObject
Returns:
String - string representation of object

getFemaleParent

public Organism getFemaleParent()
Returns the female parent organism.

Returns:
Organism - female parent organism, never null

getMaleParent

public Organism getMaleParent()
Returns the male parent organism.

Returns:
Organism - male parent organism, never null

getWorld

public World getWorld()
Get the world containing this object.

Overrides:
getWorld in class EngineObject
Returns:
World - the world containing this object, never null.

getChildren

public java.util.Enumeration getChildren()
Returns an enumeration over the children organisms of this family.

If there are no children in this family, an enumeration with no elements is returned.

If there are children in this family, the vector of children is cloned and an enumeration over that clone is returned. This enables you to safely modify the family and its children while using the enumeration.

Returns:
Enumeration - an enumeration over the vector of children of this family, never null

getGeneration

public int getGeneration()
Get the generation of this family.

Parameters:
int - - generation of this family (e.g. 1, 2, 3 as in F1, F2, F3)

getCharacteristicCount

public int getCharacteristicCount(java.lang.String aCharacteristicName)

isChild

public boolean isChild(Organism organism)

getNumberOfChildren

public int getNumberOfChildren()
Return the number of children of this family.

Returns:
int - the number of children of this family

addChild

public void addChild(Organism aChild)
Adds a child organism to this fammmily. Does not check if this child or an equivalent child already has been added to this family.

Parameters:
aChild - Organism - the child organism to add to this family, may not be null
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal

writeToStream

public void writeToStream(java.io.PrintWriter stream)
                   throws java.io.IOException
Writes this object to the given stream in XML format. Usually this method is used to write the object to a file for saving it, but that is potentially not the only use.

We could supply a default implementation that knows how to write the id value. But that convenience is not chosen because it's never correct to use just this implementation of these methods, so I'd rather have a compilation fail if a derived class fails to implement this method.

The inverse of this method is a constructor that takes a org.xml.sax.Parser argument and other arguments.

Overrides:
writeToStream in class EngineObject
Parameters:
stream - PrintWriter - print stream
Throws:
java.lang.IllegalArgumentException - - input arguments illegal
java.io.IOException - - an IO error occurred in java libraries