|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Number
codesimian.NumberStack
@Deprecated public class NumberStack
This class became almost obsolete when CS stopped being a subclass of Number,
although CS still can be cast to Number, but often the dynamic properties are lost.
A stack of Numbers. Number functions return the same call on the top value.
WARNING: Be careful not to put
this NumberStack inside itsself, or some other cycle.
It does not have infinite-loop-protection (CSs do),
but if it contains only CSs (CS extends Number)
and they have that protection option on,
then they can stop the infinite-loops.
NumberStack makes the syntax for specifying complex OPTIONS easy.
Just use a Number variable and set its first value in my constructor.
NumberStack is often used as a stack of default values for a certain option.
Others can push and pop their own options without damaging anyone else's options.
If you do this: Number n = new NumberStack(...),
instead of: NumberStack n = new NumberStack(...),
then: users of your class might not know it is a NumberStack,
and they can simply replace it with new Integer(5) for example.
If they suspect its a NumberStack, they can check its type and push/pop.
It has almost the simplicity of a primitive type, but supports complex behavior.
Example:
Number defaultSize = new NumberStack(7.3);
int size = defaultSize.intValue(); //7, not 7.3
((NumberStack)defaultSize) .push((byte)3);
. //defaultSize returns 3
. CS complexValue = CS.compile("*(?xSize ?ySize ?zSize)");
. ((NumberStack)defaultSize) .push(complexValue);
. . //defaultSize returns complexValue.doubleValue() or .intValue() etc
. ((NumberStack)defaultSize) .pop();
. //defaultSize returns 3
((NumberStack)defaultSize) .pop();
//defaultSize returns 7.3
Nested Class Summary | |
---|---|
static class |
NumberStack.NeverEmpty
Deprecated. replaces pop() with peek() if pop() would empty the stack. |
Field Summary | |
---|---|
protected java.util.List<java.lang.Number> |
stack
Deprecated. Default: new java.util.ArrayList |
Constructor Summary | |
---|---|
NumberStack()
Deprecated. |
|
NumberStack(byte pushMe)
Deprecated. |
|
NumberStack(double pushMe)
Deprecated. |
|
NumberStack(float pushMe)
Deprecated. |
|
NumberStack(int pushMe)
Deprecated. |
|
NumberStack(long pushMe)
Deprecated. |
|
NumberStack(java.lang.Number pushMe)
Deprecated. |
|
NumberStack(short pushMe)
Deprecated. |
Method Summary | |
---|---|
byte |
byteValue()
Deprecated. returns the byte value of the top Number on this stack |
double |
doubleValue()
Deprecated. |
float |
floatValue()
Deprecated. |
int |
intValue()
Deprecated. |
long |
longValue()
Deprecated. |
java.lang.Number |
peek()
Deprecated. |
java.lang.Number |
pop()
Deprecated. |
void |
push(byte pushMe)
Deprecated. |
void |
push(double pushMe)
Deprecated. |
void |
push(float pushMe)
Deprecated. |
void |
push(int pushMe)
Deprecated. |
void |
push(long pushMe)
Deprecated. |
void |
push(java.lang.Number pushMe)
Deprecated. |
void |
push(short pushMe)
Deprecated. |
short |
shortValue()
Deprecated. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.List<java.lang.Number> stack
Constructor Detail |
---|
public NumberStack()
public NumberStack(java.lang.Number pushMe)
public NumberStack(byte pushMe)
public NumberStack(short pushMe)
public NumberStack(int pushMe)
public NumberStack(long pushMe)
public NumberStack(float pushMe)
public NumberStack(double pushMe)
Method Detail |
---|
public void push(java.lang.Number pushMe)
public void push(byte pushMe)
public void push(short pushMe)
public void push(int pushMe)
public void push(long pushMe)
public void push(float pushMe)
public void push(double pushMe)
public java.lang.Number peek()
public java.lang.Number pop()
public byte byteValue()
byteValue
in class java.lang.Number
public short shortValue()
shortValue
in class java.lang.Number
public int intValue()
intValue
in class java.lang.Number
public long longValue()
longValue
in class java.lang.Number
public float floatValue()
floatValue
in class java.lang.Number
public double doubleValue()
doubleValue
in class java.lang.Number
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |