sbrt.shell.text.chem
Class ChemSpeciesFormatV1

java.lang.Object
  extended by sbrt.shell.text.chem.ChemSpeciesFormatV1
All Implemented Interfaces:
ChemSpeciesFormat, Format, Formatter<java.lang.String>, Parser<java.lang.String>, SimpleFormat<java.lang.String>

public final class ChemSpeciesFormatV1
extends java.lang.Object
implements ChemSpeciesFormat

This class is a concrete implemenation of ChemSpeciesFormat. This format considers chemical species to be String objects, which are referred to as species names. Species names cannot contain any whitespace characters (spaces, tabs, or newlines) and their length must be greater than 0.

Author:
This class was written and documented by Jeremiah Wright while in the Wagner lab.

Constructor Summary
ChemSpeciesFormatV1()
           
 
Method Summary
 java.lang.String format(java.lang.String speciesName)
          Returns the provided chemical species name after ensuring it conforms to this format.
 java.lang.String parse(java.lang.String speciesName)
          Parses the provided string and returns its corresponding species name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChemSpeciesFormatV1

public ChemSpeciesFormatV1()
Method Detail

format

public java.lang.String format(java.lang.String speciesName)
Returns the provided chemical species name after ensuring it conforms to this format.

Specified by:
format in interface Formatter<java.lang.String>
Parameters:
speciesName - the species name to be checked.
Returns:
the provided species name.
Throws:
java.lang.IllegalArgumentException - if the provided species name does not conform to this format.
java.lang.NullPointerException - if the provided string is null.

parse

public java.lang.String parse(java.lang.String speciesName)
Parses the provided string and returns its corresponding species name.

Specified by:
parse in interface Parser<java.lang.String>
Parameters:
speciesName - the string to be parsed.
Returns:
a copy of the provided string with leading and trailing white space removed, or the provided string if it has no leading or trailing white space.
Throws:
FormatException - if the provided string is not a valid species name.
java.lang.NullPointerException - if the provided string is null.