xtc.type
Class Constant

java.lang.Object
  extended by xtc.type.Constant

public class Constant
extends java.lang.Object

Representation of a type's constant value. A constant value may be one of the following:

This class treats a zero as a null value. It also treats a zero as a boolean false value and any other number as a boolean true value.

Version:
$Revision: 1.11 $
Author:
Robert Grimm

Nested Class Summary
static class Constant.Kind
          The kind.
 
Constructor Summary
Constant(java.lang.Object value)
          Create a new constant value.
 
Method Summary
 java.math.BigInteger bigIntValue()
          Get this constant's value as a big integer.
 double doubleValue()
          Get this constant's value as a double.
 Constant.Kind getKind()
          Get this constant's kind.
 java.lang.Object getValue()
          Get this constant's value.
 boolean isNull()
          Determine whether this constant represents a null value.
 boolean isNumber()
          Determine whether this constant's value can be treated as a number.
 boolean isReference()
          Determine whether this constant's value is a reference.
 boolean isString()
          Determine whether this constant's value is a string.
 boolean isTrue()
          Determine whether this constant represents a boolean true value.
 long longValue()
          Get this constant's value as a long.
 Reference refValue()
          Get this constant's value as a reference.
 java.lang.String stringValue()
          Get this constant's value as a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Constant

public Constant(java.lang.Object value)
Create a new constant value.

Parameters:
value - The value.
Throws:
java.lang.IllegalArgumentException - Signals an invalid value.
Method Detail

getKind

public Constant.Kind getKind()
Get this constant's kind.

Returns:
The kind.

isNumber

public boolean isNumber()
Determine whether this constant's value can be treated as a number.

Returns:
true if this constant's kind is an integer, big integer, double, or character.

isString

public boolean isString()
Determine whether this constant's value is a string.

Returns:
true if this constant's value is a string.

isReference

public boolean isReference()
Determine whether this constant's value is a reference.

Returns:
true if this constant's value is a reference.

getValue

public java.lang.Object getValue()
Get this constant's value.

Returns:
The value.

longValue

public long longValue()
Get this constant's value as a long.

Returns:
The value as a long.
Throws:
java.lang.IllegalStateException - Signals that this constant cannot be converted to a long.

bigIntValue

public java.math.BigInteger bigIntValue()
Get this constant's value as a big integer.

Returns:
The value as a big integer.
Throws:
java.lang.IllegalStateException - Signals that this constant cannot be converted to a big integer.

doubleValue

public double doubleValue()
Get this constant's value as a double.

Returns:
The value as a double.
Throws:
java.lang.IllegalStateException - Signals that this constant cannot be converted to a double.

refValue

public Reference refValue()
Get this constant's value as a reference.

Returns:
The value as a reference.
Throws:
java.lang.IllegalStateException - Signals that this constant is not a reference.

stringValue

public java.lang.String stringValue()
Get this constant's value as a string.

Returns:
The value as a string.
Throws:
java.lang.IllegalStateException - Signals that this constant is not a string.

isTrue

public boolean isTrue()
Determine whether this constant represents a boolean true value.

Returns:
true if this constant represents true.

isNull

public boolean isNull()
Determine whether this constant represents a null value.

Returns:
true if this constant represents null.


Copyright © 2012. All Rights Reserved.