com.rubecula.jquantity
Class Manifest

java.lang.Object
  extended bycom.rubecula.util.Item
      extended bycom.rubecula.jquantity.BaseNumber
          extended bycom.rubecula.jquantity.Manifest
All Implemented Interfaces:
Arithmetical, Auditable, java.lang.Comparable, Fuzzy, Identifiable, Integral, Millable, Presentable, java.io.Serializable

public class Manifest
extends BaseNumber
implements Integral

This class defines a "manifest" constant (a whole number which cannot be changed). Its identification is self-evident.

In terms of information content, this object is a wrapper around a long, but it conforms also to BaseNumber. It does not have the range of the BigInteger as it is designed solely for normal known constants.
Note that it would have been preferable to extend Long instead of reference a long value, however Long is a final class and thus cannot be extended.

Version:
$Revision: 1.15 $
Author:
Robin Hillyard
See Also:
Serialized Form

Field Summary
private  long _Value
          This is the value of this constant.
static Manifest $__1
          Manifest constant -1.
static Manifest $_c
          Manifest constant: speed of light in meter/sec
static Manifest $0
          Manifest constant 0.
static Manifest $1
          Manifest constant 1.
static Manifest $10
          Manifest constant 10.
(package private) static long $10L
           
static Manifest $12
          Manifest constant 12.
static Manifest $2
          Manifest constant 2.
static Manifest $3
          Manifest constant 3.
static Manifest $4
          Manifest constant 4.
static Manifest $6
          Manifest constant 6.
 
Fields inherited from class com.rubecula.jquantity.BaseNumber
 
Fields inherited from class com.rubecula.util.Item
JQUANTITY_TEST
 
Fields inherited from interface com.rubecula.jquantity.Fuzzy
$DistGaussian, $DistInvalid, $DistNone, $DistUniform, $Names
 
Constructor Summary
Manifest(long value)
          Primary constructor to create a Manifest from a long.
Manifest(java.lang.String string)
          Constructor to create a Manifest from a decimal String.
Manifest(java.lang.String string, int radix)
          Constructor to create a Manifest from a String defined by radix.
 
Method Summary
 java.lang.String audit()
          Method to return a detailed (unlabeled) string from an arithmetical object for debugging purposes.
 void audit(java.io.PrintStream out, java.lang.String label)
          Method to write the detailed (labeled) account of this object to print stream out.
 java.lang.String audit(java.lang.String label)
          Method to return a detailed string from an arithmetical object for debugging purposes.
 int compareTo(java.lang.Integer o)
          Method to fulfill contract defined by Comparable.
 int compareTo(java.lang.Long o)
          Method to fulfill contract defined by Comparable.
 int compareTo(Manifest o)
          Method to fulfill contract defined by Comparable.
 BaseNumber difference(BaseNumber subtrahend)
          Method to yield the difference of this less a BaseNumber (subtrahend).
 double doubleValue()
          Method to fulfill contract defined by Number.
protected  Manifest factored(long factor)
           
 float floatValue()
          Returns the value of the specified number as a float.
 java.lang.String getIdentifier()
          Method to fulfill contract defined by Auditable.
 int intValue()
          Method to fulfill contract defined by Number and Integral.
 boolean isInfinite()
          Method to fulfill contract defined by Arithmetical.
 boolean isInteger()
          Method to fulfill contract defined by Arithmetical.
 boolean isPowerOfTen()
          Method to determine if this is a power of ten and ten only.
 boolean isUnity()
          Method to fulfill contract defined by Arithmetical.
 long longValue()
          Method to fulfill contract defined by Number and Integral.
 Presentable makePresentableInstance(Presentation presentation)
          Instance method to convert a Presentation into a Presentable.
 BaseNumber minus()
          Method to fulfill contract defined by BaseNumber.
 BaseNumber pow(int power)
          Method to raise this to the power power return the result.
 Presentation present(AttrMap attributes)
          Convert this Presentable object into a Presentation, according to the set of attributes provided.
 BaseNumber product(BaseNumber multiplicand)
          Method to multiply multiplicand by this and return their product as the result.
 BaseNumber scaled(long factor)
          Method to multiply multiplicand by this and return their product as the result.
 int signum()
          Method to fulfill contract defined by Arithmetical and Integral.
 BaseNumber sum(BaseNumber addend)
          Method to add addend to this and return their sum as the result.
 java.math.BigInteger toBigInteger()
          Convert this into a BigInteger.
 java.lang.String toString()
          This is the default toString method for all Items.
 
Methods inherited from class com.rubecula.jquantity.BaseNumber
abs, bestModel, BestModel, byteValue, characteristic, Characteristic, getBound, getBoundAbs, getModel, impartFuzziness, isEqual, isExact, isUncertain, isZero, shortValue, valueOf, valueOf, valueOfLog10
 
Methods inherited from class com.rubecula.util.Item
compareTo, Debug, getClassNameShort, getType, IsDebug, present, SetDebug, test, test, Wrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.rubecula.jquantity.Integral
isExact, isZero
 

Field Detail

$0

public static final Manifest $0
Manifest constant 0.


$1

public static final Manifest $1
Manifest constant 1.


$2

public static final Manifest $2
Manifest constant 2.


$3

public static final Manifest $3
Manifest constant 3.


$4

public static final Manifest $4
Manifest constant 4.


$6

public static final Manifest $6
Manifest constant 6.


$10L

static final long $10L
See Also:
Constant Field Values

$10

public static final Manifest $10
Manifest constant 10.


$12

public static final Manifest $12
Manifest constant 12.


$__1

public static final Manifest $__1
Manifest constant -1.


$_c

public static final Manifest $_c
Manifest constant: speed of light in meter/sec


_Value

private final long _Value
This is the value of this constant.

Constructor Detail

Manifest

public Manifest(long value)
Primary constructor to create a Manifest from a long.

Parameters:
value - long: the value for the new object.

Manifest

public Manifest(java.lang.String string)
Constructor to create a Manifest from a decimal String.

Parameters:
string - the value for the new object.

Manifest

public Manifest(java.lang.String string,
                int radix)
Constructor to create a Manifest from a String defined by radix.

Parameters:
string - the representation of the value in base radix
radix - the radix defining the string representation.
Method Detail

minus

public BaseNumber minus()
Method to fulfill contract defined by BaseNumber. Method to yield a copy of this but with the sign changed.

Specified by:
minus in interface Integral
Specified by:
minus in class BaseNumber
Returns:
negative version of this.

sum

public BaseNumber sum(BaseNumber addend)
               throws InvalidOperandException
Method to add addend to this and return their sum as the result.
NOTE: it is a requirement of this method that the class of the result is the same as the class of this so that the result can be safely cast to the original class.

Specified by:
sum in class BaseNumber
Parameters:
addend - the number to add to this.
Returns:
the sum of this and addend.
Throws:
InvalidOperandException - operands are not compatible for the sum operation.

difference

public BaseNumber difference(BaseNumber subtrahend)
                      throws InvalidOperandException
Method to yield the difference of this less a BaseNumber (subtrahend).
NOTE: it is a requirement of this method that the class of the result is the same as the class of this so that the result can be safely cast to the original class.

Overrides:
difference in class BaseNumber
Parameters:
subtrahend - the number to subtract from this.
Returns:
the difference of this less subtrahend.
Throws:
InvalidOperandException - operands are not compatible for the difference operation.
See Also:
BaseNumber.sum(BaseNumber), BaseNumber.minus()

product

public BaseNumber product(BaseNumber multiplicand)
                   throws InvalidOperandException
Method to multiply multiplicand by this and return their product as the result.
NOTE: it is a requirement of this method that the class of the result is the same as the class of this so that the result can be safely cast to the original class.

Specified by:
product in class BaseNumber
Parameters:
multiplicand - the number to multiply by this.
Returns:
the product of this and multiplicand.
Throws:
InvalidOperandException

scaled

public BaseNumber scaled(long factor)
Method to multiply multiplicand by this and return their product as the result.
NOTE: it is a requirement of this method that the class of the result is the same as the class of this so that the result can be safely cast to the original class.

Specified by:
scaled in class BaseNumber
Parameters:
factor - the number to multiply by this.
Returns:
the product of this and multiplicand.

pow

public BaseNumber pow(int power)
Method to raise this to the power power return the result.
NOTE: it is a requirement of this method that the class of the result is the same as the class of this so that the result can be safely cast to the original class. May throw a runtime exception if the result is too big to be stored in a Long; or if the power is negative.

Specified by:
pow in class BaseNumber
Parameters:
power - the exponent for this.
Returns:
the value of this raised to the power power.

signum

public int signum()
Method to fulfill contract defined by Arithmetical and Integral.

Specified by:
signum in interface Arithmetical
Returns:
int: the sign of this 0: zero, 1: positive, -1: negative.

isInteger

public boolean isInteger()
Method to fulfill contract defined by Arithmetical.

Specified by:
isInteger in interface Arithmetical
Returns:
boolean: true (always).

isInfinite

public boolean isInfinite()
Method to fulfill contract defined by Arithmetical.

Specified by:
isInfinite in interface Arithmetical
Returns:
long: the value of this.

isUnity

public boolean isUnity()
Method to fulfill contract defined by Arithmetical.

Specified by:
isUnity in interface Arithmetical
Returns:
boolean: true if this has value = 1.

intValue

public int intValue()
Method to fulfill contract defined by Number and Integral.

Specified by:
intValue in interface Integral
Specified by:
intValue in class BaseNumber
Returns:
int: the value of this.
Throws:
java.lang.ArithmeticException - : may lose precision.

longValue

public long longValue()
Method to fulfill contract defined by Number and Integral.

Specified by:
longValue in interface Integral
Specified by:
longValue in class BaseNumber
Returns:
long: the value of this.

toBigInteger

public java.math.BigInteger toBigInteger()
Convert this into a BigInteger.

Specified by:
toBigInteger in interface Integral
Returns:
the BigInteger equivalent of this.

isPowerOfTen

public boolean isPowerOfTen()
Method to determine if this is a power of ten and ten only.

Specified by:
isPowerOfTen in interface Integral
Returns:
true if this can be successively divided exactly by ten until 1 is the only remaining factor.

floatValue

public float floatValue()
Description copied from class: BaseNumber
Returns the value of the specified number as a float. This may involve rounding.

Specified by:
floatValue in class BaseNumber
Returns:
float: the value of this.
Throws:
java.lang.ArithmeticException - : may lose precision.

doubleValue

public double doubleValue()
Method to fulfill contract defined by Number.

Specified by:
doubleValue in class BaseNumber
Returns:
long: the value of this.

getIdentifier

public java.lang.String getIdentifier()
Method to fulfill contract defined by Auditable.

Specified by:
getIdentifier in interface Identifiable
Returns:
String: the identifier for this, i.e. the string representation of its value.

compareTo

public int compareTo(java.lang.Long o)
Method to fulfill contract defined by Comparable. Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Parameters:
o - the Long with which to compare this, must be either Long or Integer.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
java.lang.UnsupportedOperationException - if the specified object's type prevents it from being compared to this Object.

compareTo

public int compareTo(Manifest o)
Method to fulfill contract defined by Comparable. Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Parameters:
o - the Manifest with which to compare this.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
java.lang.UnsupportedOperationException - if the specified object's type prevents it from being compared to this Object.

compareTo

public int compareTo(java.lang.Integer o)
Method to fulfill contract defined by Comparable. Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Parameters:
o - the Integer with which to compare this.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
java.lang.UnsupportedOperationException - if the specified object's type prevents it from being compared to this Object.

present

public Presentation present(AttrMap attributes)
                     throws PresentationException
Convert this Presentable object into a Presentation, according to the set of attributes provided. Supported attributes include:
Radix
Integer/String the value of the radix

Specified by:
present in interface Presentable
Parameters:
attributes - a map of the attributes desired for this presentation.
Returns:
an appropriate instance of Presentation.
Throws:
PresentationException

makePresentableInstance

public Presentable makePresentableInstance(Presentation presentation)
Instance method to convert a Presentation into a Presentable. Ideally, this would be a class method, but such a method cannot be defined in an interface. Nor can it be defined in an abstract class with the intention of overriding it in a subclass. Polymorphism just doesn't work that way.
Therefore, the present value (as in fields) of the instance is essentially ignored - only the methods are important.

Specified by:
makePresentableInstance in interface Presentable
Parameters:
presentation - a presentation of a number which you want to convert into a number.
Returns:
a number in the form of a Presentable.

audit

public java.lang.String audit(java.lang.String label)
Method to return a detailed string from an arithmetical object for debugging purposes.

Specified by:
audit in interface Auditable
Parameters:
label - String: the label to associate with the data.
Returns:
the detailed string.

audit

public java.lang.String audit()
Method to return a detailed (unlabeled) string from an arithmetical object for debugging purposes.

Specified by:
audit in interface Auditable
Overrides:
audit in class Item
Returns:
the detailed string.
See Also:
Auditable.audit(String)

audit

public void audit(java.io.PrintStream out,
                  java.lang.String label)
Method to write the detailed (labeled) account of this object to print stream out.

Specified by:
audit in interface Auditable
Overrides:
audit in class Item
Parameters:
out - PrintStream: the output stream.
label - String: the label to be used.
See Also:
Auditable.audit(String), Item.getClassNameShort(), PrintStream.println(String)

toString

public java.lang.String toString()
Description copied from class: Item
This is the default toString method for all Items. Specific classes will override as appropriate.

Overrides:
toString in class Item
Returns:
a String representing this Item by first converting it to a Presentation and then rendering that with no length constraint.
See Also:
Item.present(), Presentation.toString()

factored

protected Manifest factored(long factor)