|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.aisb.bio.things.Monomer
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.)
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 |
public Monomer(java.lang.Class type, java.lang.String name, java.lang.Character code, int number)
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 |
public void setProperty(java.lang.String name, java.lang.Object value)
name
- The name of the property.value
- The value of the property.public java.lang.Object getProperty(java.lang.String name)
name
- The name of the property.
public static Monomer getByName(java.lang.String name)
name
- The name of the monomer.
public static Monomer getByCode(char code)
code
- The code for the monomer.
public static Monomer getByCode(java.lang.Character code)
code
- The code for the monomer.
public static Monomer getByNumber(int number)
number
- The code for the monomer.
public static Monomer getByNumber(java.lang.Integer number)
number
- The code for the monomer.
public static int getQuantity()
public java.lang.String getName()
public java.lang.Character getCode()
public int getNumber()
public java.lang.Class getType()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |