com.foxsmart.ic.lang
Class Hexadecimal

java.lang.Object
  extended by java.lang.Number
      extended by com.foxsmart.ic.lang.Hexadecimal
All Implemented Interfaces:
java.io.Serializable

public class Hexadecimal
extends java.lang.Number
implements java.io.Serializable

This class represents a hexadecimal value.

See Also:
Serialized Form

Constructor Summary
Hexadecimal()
          Constructs a hexadecimmal object with the value of 0.
Hexadecimal(java.lang.Integer value)
          Constructs a hexadecimal object based on an integer value.
Hexadecimal(java.lang.Long value)
          Constructs a hexadecimal object based on a long value.
Hexadecimal(java.lang.String value)
          Constructs a hexadecimal object based on a string representation of the value (e.g.
 
Method Summary
 java.lang.Object clone()
          Clones this hexadecimal object.
 int compareTo(java.lang.Object object)
          Compares this objejct to the passed in object.
 double doubleValue()
          Gets the value as a double.
 boolean equals(java.lang.Object object)
          Returns whether the passed in object is equal to this object.
 float floatValue()
          Gets the value as a float.
 boolean getPrependHexIdentifier()
          Gets whether the hexadecimal identifier will be prepended to the returned value of the toString method.
 boolean getUppercase()
          Returns whether the toString method will return upper case or not.
 int getWidth()
          Gets the width.
 int hashCode()
          Returns the hash code for this object.
 int intValue()
          Gets the value as an integer.
 long longValue()
          Gets the value as a long.
static void main(java.lang.String[] args)
          Test driver.
 void setPrependHexIdentifier(boolean hexIdentifier)
          Sets whether the hexadecimal identifier "0x" will be prepended to the returned value of the toString method.
 void setUppercase(boolean uppercase)
          Determines whether the toString return value will be in upper case or lower case.
 void setWidth(int width)
          Sets the forced width of the returned hexadecimal string (i.e.
 java.lang.String toString()
          Displays the string representation of this value in hexadecimal.
 
Methods inherited from class java.lang.Number
byteValue, shortValue
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Hexadecimal

public Hexadecimal()
Constructs a hexadecimmal object with the value of 0.


Hexadecimal

public Hexadecimal(java.lang.Long value)
Constructs a hexadecimal object based on a long value.

Parameters:
value - The value as an long.

Hexadecimal

public Hexadecimal(java.lang.Integer value)
Constructs a hexadecimal object based on an integer value.

Parameters:
value - The value as an integer.

Hexadecimal

public Hexadecimal(java.lang.String value)
            throws java.lang.NumberFormatException
Constructs a hexadecimal object based on a string representation of the value (e.g. 0xFFFF).

Parameters:
value - The value as a string.
Throws:
java.lang.NumberFormatException - if the string can't be converted to a value.
Method Detail

longValue

public long longValue()
Gets the value as a long.

Specified by:
longValue in class java.lang.Number
Returns:
The value as a long.

intValue

public int intValue()
Gets the value as an integer. If the value is greater than a long, appropriate conversion will take place (see Long.intValue()).

Specified by:
intValue in class java.lang.Number
Returns:
The value as an integer.

doubleValue

public double doubleValue()
Gets the value as a double.

Specified by:
doubleValue in class java.lang.Number
Returns:
The value as a double.

floatValue

public float floatValue()
Gets the value as a float.

Specified by:
floatValue in class java.lang.Number
Returns:
The value as a float.

hashCode

public int hashCode()
Returns the hash code for this object.

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code.

compareTo

public int compareTo(java.lang.Object object)
Compares this objejct to the passed in object.

Parameters:
object - The object to compare.
Returns:
the value 0 if the argument Hexadecimal is equal to this Long; a value less than 0 if this Hexadecimal is numerically less than the Hexadecimal argument; and a value greater than 0 if this Hexadecimal is numerically greater than the Hexadecimal argument.

equals

public boolean equals(java.lang.Object object)
Returns whether the passed in object is equal to this object.

Overrides:
equals in class java.lang.Object
Parameters:
object - The object to compare.
Returns:
True if equal or false if not.

toString

public java.lang.String toString()
Displays the string representation of this value in hexadecimal.

Overrides:
toString in class java.lang.Object
Returns:
The string representation.

clone

public java.lang.Object clone()
Clones this hexadecimal object.

Overrides:
clone in class java.lang.Object

setUppercase

public void setUppercase(boolean uppercase)
Determines whether the toString return value will be in upper case or lower case. The default is upper case.

Parameters:
uppercase - Set to true for upper case or false for lower case.

getUppercase

public boolean getUppercase()
Returns whether the toString method will return upper case or not.

Returns:
True if all upper case or false if lower case.

setPrependHexIdentifier

public void setPrependHexIdentifier(boolean hexIdentifier)
Sets whether the hexadecimal identifier "0x" will be prepended to the returned value of the toString method. The default is true.

Parameters:
hexIdentifier - The hexadecimal identifier.

getPrependHexIdentifier

public boolean getPrependHexIdentifier()
Gets whether the hexadecimal identifier will be prepended to the returned value of the toString method.

Returns:
The hexadecimal identifier setting.

setWidth

public void setWidth(int width)
Sets the forced width of the returned hexadecimal string (i.e. the number of zeros that will be appended to the end of the string). Set to 0 to just convert the value as is (the default). If the value of the string representation is greater than the width, no additional zeros will be appended.

Parameters:
width - the width to set.

getWidth

public int getWidth()
Gets the width.

Returns:
The width.

main

public static void main(java.lang.String[] args)
Test driver.

Parameters:
args - The arguments.


Copyright © 2005-2008 Fox Smart, Inc. All Rights Reserved.