org.concord.biologica.engine
Class SpeciesImageColumn

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

public final class SpeciesImageColumn
extends EngineObject
implements java.io.Serializable, java.beans.PropertyChangeListener

This class represents a column of a SpeciesImage. Specifically, this object maintains an understanding of what species characteristics are valid for this column of a SpeciesImage.

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

Version:
$Revision: 1.1.1.1 $ $Date: 2001/04/28 00:39:15 $
Author:
$Author: ed $
See Also:
EngineProp.CHARACTERISTIC_ADDED_TO_COLUMN, EngineProp.CHARACTERISTIC_REMOVED_FROM_COLUMN, EngineProp.GENDER, EngineProp.DELETED, EngineProp.ID, EngineProp.LOCKED_STATE, EngineProp.NAME, 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
SpeciesImageColumn(SpeciesImage aSpeciesImage, java.lang.String aName)
          Creates a new species image column.
SpeciesImageColumn(SpeciesImage aSpeciesImage, java.lang.String anElementName, int anElementID, com.sun.xml.parser.Parser anXMLParser, ImportContext importContext)
          Create a new SpeciesImageColumn and start handling XML parsing events to set the properties of this object.
 
Method Summary
 void addCharacteristic(Characteristic aCharacteristic)
          Adds a characteristic to the column.
 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 endElement(java.lang.String anElementName)
          Handle notification that the parsing of the given element has ended.
 java.util.Enumeration getCharacteristics()
          Returns an enumeration over the vector of characteristics in this column.
 int getGender()
          Return the gender of images in this column, which will be one of Species.FEMALE_AND_MALE, Species.FEMALE_ONLY or Species.MALE_ONLY.
 java.lang.String getGenderAsString()
          Return the gender of images in this column, which will be one of Species.FEMALE_AND_MALE_STRING, Species.FEMALE_ONLY_STRING or Species.MALE_ONLY_STRING.
 java.lang.String getName()
          Return the name of this species image column.
 int getNumberOfCharacteristics()
          Return the number of characteristics in this column.
 Species getSpecies()
          Return the Species of this object.
 SpeciesImage getSpeciesImage()
          Return the SpeciesImage of this object.
 World getWorld()
          Get the world containing this object.
 void ignorableWhitespace(char[] ch, int start, int length)
          Receive notification of ignorable white space character data.
 void propertyChange(java.beans.PropertyChangeEvent event)
          Handle property change events
 boolean removeCharacteristic(Characteristic aCharacteristic)
          Removes a characteristic from the column.
 void replaceCharacteristic(Characteristic oldCharacteristic, Characteristic newCharacteristic)
          Replace the given old Characteristic with the given new Characteristic.
 void setGender(int aGender)
          Set the gender of the images in this column.
 void setGenderAsString(java.lang.String aGenderString)
          Set the gender of the images in this column as a string.
 void setName(java.lang.String aName)
          Set the name of this species image column.
 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.
 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, setAutomaticLocked, setID, setLockedState, setLockedStateAsString, setManualLocked
 
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

SpeciesImageColumn

public SpeciesImageColumn(SpeciesImage aSpeciesImage,
                          java.lang.String aName)
Creates a new species image column.

Parameters:
aSpeciesImage - SpeciesImage - the species image containing this object, may not be null
aName - String - the species image column name, may not be null
Throws:
java.lang.IllegalArgumentException - - input argument(s) illegal

SpeciesImageColumn

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

Parameters:
aSpeciesImage - SpeciesImage - the enclosing species image for this new species image column
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

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 successful, a property change event is generated for the property named EngineProp.DELETED.

Overrides:
delete in class EngineObject

delete

public void delete(boolean notifyChange)

toString

public java.lang.String toString()
Return a string representation of this object.

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

getSpeciesImage

public SpeciesImage getSpeciesImage()
Return the SpeciesImage of this object.

Returns:
SpeciesImage - SpeciesImage of this object, never null

getSpecies

public Species getSpecies()
Return the Species of this object.

Returns:
Species - the species of this object, 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.

getName

public java.lang.String getName()
Return the name of this species image column. May be null.

Returns:
String - name of this species image column, may not be null.

setName

public void setName(java.lang.String aName)
Set the name of this species image column.

When this method is successful, a property change event is fired for the property named EngineProp.NAME.

Parameters:
aName - String - the new name of this species image column, may not be null
Throws:
java.lang.IllegalArgumentException - - input argument illegal
ObjectDeletedException - - object is deleted and cannot be modified
ObjectLockedException - - object is locked and cannot be modified

getGender

public int getGender()
Return the gender of images in this column, which will be one of Species.FEMALE_AND_MALE, Species.FEMALE_ONLY or Species.MALE_ONLY.

Returns:
int - gender aspect of this species image column
See Also:
Species.FEMALE_AND_MALE, Species.FEMALE_ONLY, Species.MALE_ONLY

getGenderAsString

public java.lang.String getGenderAsString()
Return the gender of images in this column, which will be one of Species.FEMALE_AND_MALE_STRING, Species.FEMALE_ONLY_STRING or Species.MALE_ONLY_STRING. Returns a string.

Returns:
int - gender aspect of this species image column
See Also:
Species.FEMALE_AND_MALE_STRING, Species.FEMALE_ONLY_STRING, Species.MALE_ONLY_STRING

setGender

public void setGender(int aGender)
Set the gender of the images in this column.

The new gender must be one of Species.FEMALE_AND_MALE, Species.FEMALE_ONLY or Species.MALE_ONLY.

When this method is successful, a property change event is fired for the property named EngineProp.GENDER.

Parameters:
aGender - int - the new gender of this species image column
Throws:
java.lang.IllegalArgumentException - - input argument illegal
ObjectDeletedException - - object is deleted and cannot be modified
ObjectLockedException - - object is locked and cannot be modified
See Also:
Species.FEMALE_AND_MALE, Species.FEMALE_ONLY, Species.MALE_ONLY

setGenderAsString

public void setGenderAsString(java.lang.String aGenderString)
Set the gender of the images in this column as a string.

The new gender must be one of Species.FEMALE_AND_MALE_STRING, Species.FEMALE_ONLY_STRING or Species.MALE_ONLY_STRING.

When this method is successful, a property change event is fired for the property named EngineProp.GENDER.

Parameters:
aGenderString - String - the new gender of this species image column as a string
Throws:
java.lang.IllegalArgumentException - - input argument illegal
ObjectDeletedException - - object is deleted and cannot be modified
ObjectLockedException - - object is locked and cannot be modified
See Also:
Species.FEMALE_AND_MALE_STRING, Species.FEMALE_ONLY_STRING, Species.MALE_ONLY_STRING

getCharacteristics

public java.util.Enumeration getCharacteristics()
Returns an enumeration over the vector of characteristics in this column.

Returns:
Enumeration - an enumeration over the characteristics in this column

getNumberOfCharacteristics

public int getNumberOfCharacteristics()
Return the number of characteristics in this column.

Returns:
int - the number of characteristics in this column

addCharacteristic

public void addCharacteristic(Characteristic aCharacteristic)
Adds a characteristic to the column.

Parameters:
aCharacteristic - Characteristic - a new characteristic, may not be null
Throws:
java.lang.IllegalArgumentException - - input argument illegal

removeCharacteristic

public boolean removeCharacteristic(Characteristic aCharacteristic)
Removes a characteristic from the column.

Parameters:
aCharacteristic - Characteristic - a characteristic, may not be null
Returns:
boolean indicating whether or not the characteristic was found and removed
Throws:
java.lang.IllegalArgumentException - - input argument illegal

replaceCharacteristic

public void replaceCharacteristic(Characteristic oldCharacteristic,
                                  Characteristic newCharacteristic)
Replace the given old Characteristic with the given new Characteristic. The key here is that we should maintain the position, so the old and new characteristics have the same order in this object.

If the oldCharacteristic is null or not found, then we just add the newCharacteristic on to the end of the list of characteristics.

If the newCharacteristic is null, then we just remove the oldCharacteristic.

If both the oldCharacteristic and the newCharacteristic are null or not found, do nothing.

Parameters:
Characteristic - oldCharacteristic - characteristic to remove, may be null
Characteristic - newCharacteristic - characteristic to add, may be null

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Handle property change events
Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
event - PropertyChangeEvent - the property change event

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