org.aisb.bio.things
Class Monomer

java.lang.Object
  extended byorg.aisb.bio.things.Monomer
Direct Known Subclasses:
AminoAcid, Nucleotide

public class Monomer
extends java.lang.Object

This abstract class defines monomers. Typical examples include amino acids, bases, or monosacharides.

The basic idea is that you never create the objects yourself. Exactly one object is created for each monomer, and references to it are handed out upon request. This allows for a very small number of object creations, and allows the "=" operator to actually do the right thing when these objects are used.

Once we're using Java 1.5, we can use typesafe enumerations and the special collection implementations that work on them to make this blazingly efficient; for the moment we'll concentrate on clarity instead of performance.

(This isn't working quite right when I've got multiple subclasses yet. Works just fine when there's only one subclass, and that's all we need for the first assignment, so I'll worry about fixing that aspect of it later. Might have to make a distinct object factory class. I'll figure it out, but not by 2005-02-01.)

Author:
Doug DeJulio

Constructor Summary
Monomer(java.lang.Class type, java.lang.String name, java.lang.Character code, int number)
          This should only be invoked by subclasses.
 
Method Summary
static Monomer getByCode(char code)
          Given the one-character code of a monomer, return the representation of that monomer.
static Monomer getByCode(java.lang.Character code)
          Given the one-character code of a monomer, return the representation of that monomer.
static Monomer getByName(java.lang.String name)
          Given the name of a monomer, perhaps such as "tyrosine" or "fructose", return the representation of that monomer.
static Monomer getByNumber(int number)
          Given the numberic code for a monomer, return the representation of that monomer.
static Monomer getByNumber(java.lang.Integer number)
          Given the numberic code for a monomer, return the representation of that monomer.
 java.lang.Character getCode()
           
 java.lang.String getName()
           
 int getNumber()
           
 java.lang.Object getProperty(java.lang.String name)
          Get a property from a monomer by name.
static int getQuantity()
           
 java.lang.Class getType()
           
 void setProperty(java.lang.String name, java.lang.Object value)
          Assign a named property to this monomer.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Monomer

public Monomer(java.lang.Class type,
               java.lang.String name,
               java.lang.Character code,
               int number)
This should only be invoked by subclasses.

Parameters:
name - A human-readable name for the monomer, like "Adenine".
code - A code for the monomer, like "A".
number - An integer representing the monomer, like "7", "0x10", or "0210".
Method Detail

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
Assign a named property to this monomer. This can be used for things like hydrophobic moment, molecular weight, whatever. It's application specific.

Parameters:
name - The name of the property.
value - The value of the property.

getProperty

public java.lang.Object getProperty(java.lang.String name)
Get a property from a monomer by name. It'll only work if the property has been set.

Parameters:
name - The name of the property.
Returns:
The value of the property.

getByName

public static Monomer getByName(java.lang.String name)
Given the name of a monomer, perhaps such as "tyrosine" or "fructose", return the representation of that monomer.

Parameters:
name - The name of the monomer.
Returns:
The object representing the monomer.

getByCode

public static Monomer getByCode(char code)
Given the one-character code of a monomer, return the representation of that monomer.

Parameters:
code - The code for the monomer.
Returns:
The object representing the monomer.

getByCode

public static Monomer getByCode(java.lang.Character code)
Given the one-character code of a monomer, return the representation of that monomer.

Parameters:
code - The code for the monomer.
Returns:
The object representing the monomer.

getByNumber

public static Monomer getByNumber(int number)
Given the numberic code for a monomer, return the representation of that monomer.

Parameters:
number - The code for the monomer.
Returns:
The object representing the monomer.

getByNumber

public static Monomer getByNumber(java.lang.Integer number)
Given the numberic code for a monomer, return the representation of that monomer.

Parameters:
number - The code for the monomer.
Returns:
The object representing the monomer.

getQuantity

public static int getQuantity()

getName

public java.lang.String getName()
Returns:
The monomer's name.

getCode

public java.lang.Character getCode()
Returns:
The monomer's one-character code.

getNumber

public int getNumber()
Returns:
The monomer's numeric code.

getType

public java.lang.Class getType()
Returns:
The monomer's type (eg. nucleotide, amino acid), coded by the reference to the Class for that monomer.