|
Venice 0.7beta | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mov.quote.Symbol
public class Symbol
An immutable representation of a stock symbol, e.g. CBA
or WBC
.
Previously the stock symbol was stored as a String but this created the
question of whether it should be stored in lower or upper case.
Unfortunately, due to development drift, even though the stock symbols were
always displayed in upper case, they were stored in lower case. Often
a "missing" conversion meant the symbol was displayed in lower case or
worse it was stored in upper case which could cause the stock symbol to
become "invisible".
By creating a single class we reduce the amount of toUpperCase()
and
toLowerCase()
calls required, and have a single place to store symbol
parsing code.
To reduce memory, symbols are stored canonically. That is there is a single
object for each symbol. For example the string symbol "CBA" would be represented by
a single class, no matter where it was used. So instead of instantiating a new
symbol class, you find the canonical object using the find(java.lang.String)
method.
Field Summary | |
---|---|
static int |
MAXIMUM_SYMBOL_LENGTH
The maximum valid length for a symbol. |
static int |
MINIMUM_SYMBOL_LENGTH
The minimum valid length for a symbol |
Method Summary | |
---|---|
char |
charAt(int offset)
Return the character at the given offset. |
java.lang.Object |
clone()
Create a clone of this symbol. |
int |
compareTo(java.lang.Object object)
Compare this symbol to the given symbol. |
boolean |
equals(java.lang.Object object)
Compare this symbol to the given symbol. |
static Symbol |
find(java.lang.String string)
Return the canonical symbol instance of the given symbol string. |
java.lang.String |
get()
Return the symbol string. |
int |
hashCode()
Calculate the hash code for this symbol. |
int |
length()
Return the length of the symbol. |
static java.util.SortedSet |
toSortedSet(java.lang.String string,
boolean checkExists)
Convert a string containing a list of symbols separated by spaces or commas into a sorted set of symbols with duplicates removed. |
java.lang.String |
toString()
Convert the symbol to a string. |
static Symbol |
toSymbol(java.lang.String string)
Convert a string containing a single symbol into a quote symbol. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int MINIMUM_SYMBOL_LENGTH
public static final int MAXIMUM_SYMBOL_LENGTH
Method Detail |
---|
public static Symbol find(java.lang.String string) throws SymbolFormatException
string
- a string containing a single symbol
SymbolFormatException
- if the string doesn't contain a valid quotepublic java.lang.String get()
public int length()
public char charAt(int offset)
offset
- the character offset
public static java.util.SortedSet toSortedSet(java.lang.String string, boolean checkExists) throws SymbolFormatException
string
- a comma or space separated list of symbolscheckExists
- set this flag to TRUE
to make sure
that the symbols are in the current quote source
SymbolFormatException
- if the string doesn't contain a
list of valid quotespublic static Symbol toSymbol(java.lang.String string) throws SymbolFormatException
find(java.lang.String)
as it performs better
error checking and checks that the symbol exists.
string
- a string containing a single symbol
SymbolFormatException
- if the string doesn't contain a valid quotepublic java.lang.Object clone()
clone
in class java.lang.Object
public int compareTo(java.lang.Object object)
compareTo
in interface java.lang.Comparable
object
- symbol to compare
0
if the symbols are equal;
1
if this symbol is after the specified symbol or
-1
if this symbol is before the specified symbol.public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
object
- the symbol to compare
true
if they are equalpublic int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
get()
method.
toString
in class java.lang.Object
|
Venice 0.7beta | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |