|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sun.tdk.sampleapi.Quote
Represents (immutable) stock quote.
Constructor Summary | |
Quote(java.lang.String name,
java.util.Date time,
int price,
int change,
int high,
int low,
int open,
int prev)
Creates a new Quote object. |
Method Summary | |
static java.lang.String |
convert(int intNum)
Convert an int to a String
with the decimal placed back in (divide by 10000). |
int |
getChange()
Returns the change in the stock in 1/10000 of a dollar. |
int |
getHigh()
Returns the 52-week high for the stock. |
int |
getLow()
Returns the 52-week low for the stock. |
java.lang.String |
getName()
Returns the name of the stock. |
int |
getOpen()
Returns the opening price of the stock. |
int |
getPrevious()
Returns the previous high for the stock. |
int |
getPrice()
Returns the price of the last trade of the stock. |
java.lang.String |
getStringChange()
Returns the string representation of change with the decimal placed
back in the correct position. |
java.lang.String |
getStringHigh()
Returns the String representation of the 52-week high with the decimal
placed back in the correct position. |
java.lang.String |
getStringLow()
Returns the String representation of the 52-week low with the decimal
placed back in the correct position. |
java.lang.String |
getStringOpen()
Returns the String representation of the opening price with
the decimal placed back in the correct position. |
java.lang.String |
getStringPrevious()
Returns the String representation of previous with the decimal
placed back in the correct position. |
java.lang.String |
getStringPrice()
Returns the string representation of the price with the decimal placed back in the correct position. |
java.util.Date |
getTime()
Returns the time of the last trade. |
static int |
makeInt(java.lang.String source)
Takes a String representation of a floating point number
and makes an int out of it. |
java.lang.String |
toString()
Returns the String representation of this quote in the format
getName()+" "+getStringPrice()+" at "+getTime()+" "+ getStringChange(). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Quote(java.lang.String name, java.util.Date time, int price, int change, int high, int low, int open, int prev)
time
can be null
.
name
- Name of the stocktime
- Time of the last trade, can be null
price
- Price of the stockchange
- Change in 1/10000 of a dollarhigh
- 52-week highlow
- 52-week lowopen
- Opening price on the dayprev
- Previous high
java.lang.NullPointerException
- if the specified name is null
Method Detail |
public static int makeInt(java.lang.String source) throws java.lang.NumberFormatException
Takes a String
representation of a floating point number
and makes an int
out of it.
Since there is no floating point support on some limited devices
(for example, pagers), we have to convert the decimal numbers into
Integer
s.
We do this by:
convert(int)
method.
int
Example: 100 -> 1000000 (/10000 = 100)
Example: 345.67 -> 3456700 (/10000 = 345.67)
Example: 3.45678 -> 34567 (/10000 = 3.4567)
Example: 1234567 -> 12345670000 (doesn't fit into int
,
results in NumberFormatException)
source
- The String
value to convert
to an int
int
value of the string (trimmed to 4 fractional digits and
multiplied by 10000)
java.lang.NumberFormatException
- If the source is
null
or after applying specified operations the value does
not represent a valid int
convert(int)
public java.lang.String getName()
public java.util.Date getTime()
public int getPrice()
public int getChange()
public int getHigh()
public int getLow()
public int getOpen()
public int getPrevious()
public static java.lang.String convert(int intNum)
int
to a String
with the decimal placed back in (divide by 10000).
Example: -100 -> -0.01 Example: 34567 -> 3.4567
intNum
- The int
value to convert
to a String
String
value of the int
makeInt(String)
public java.lang.String getStringPrice()
public java.lang.String getStringChange()
change
with the decimal placed
back in the correct position.
public java.lang.String getStringHigh()
String
representation of the 52-week high with the decimal
placed back in the correct position.
public java.lang.String getStringLow()
String
representation of the 52-week low with the decimal
placed back in the correct position.
public java.lang.String getStringOpen()
String
representation of the opening price with
the decimal placed back in the correct position.
public java.lang.String getStringPrevious()
String
representation of previous with the decimal
placed back in the correct position.
public java.lang.String toString()
String
representation of this quote in the format
getName()+" "+getStringPrice()+" at "+getTime()+" "+ getStringChange().
Overrides Object.toString
.
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |