braju.com
Java printf & scanf (beta)

com.braju.beta.lang
Class ShortVariable

java.lang.Object
  |
  +--java.lang.Number
        |
        +--com.braju.beta.lang.NumberVariable
              |
              +--com.braju.beta.lang.ShortVariable
All Implemented Interfaces:
java.io.Serializable, Variable

public final class ShortVariable
extends NumberVariable
implements Variable

Wraps a short and provides methods to convert the value to and from several datatypes [JDK1.0.2 compatible].

See Also:
Serialized Form

Field Summary
static short MAX_VALUE
          The maximum value a short can have.
static short MIN_VALUE
          The minimum value a short can have.
static int PREFIX
          When converting a short to a String using another bases, i.e.
static java.lang.Class TYPE
          The class of this static object [...].
 
Fields inherited from class com.braju.beta.lang.NumberVariable
ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, LEADING_ZEROS, NO_FLAGS, SIGN_ALWAYS, SIGN_MINUS, SIGN_SPACE
 
Constructor Summary
ShortVariable()
           
ShortVariable(short sh)
          Wraps a short into an object just like java.lang.Short does, but provides some additional methods.
 
Method Summary
 byte byteValue()
          Return the wrapped value as a byte.
 double doubleValue()
          Return the wrapped value as a double.
 boolean equals(java.lang.Object obj)
          Compare this object with another object [...].
 float floatValue()
          Return the wrapped value as a float.
 java.lang.Object get()
           
 int hashCode()
          Return a hash code for this object based on the wrapped value.
 int intValue()
          Return the wrapped value as an int.
 long longValue()
          Return the wrapped value as a long.
static void main(java.lang.String[] args)
           
static ShortVariable[] newArray(int length)
          Creates an array of length instance of this class.
 void set(java.lang.Object o)
           
 void set(short sh)
          Set a new value [...].
 short shortValue()
          Return the wrapped value as a short.
static java.lang.String toBinaryString(short value)
          Convert a short into a String using the binaries base {0,1} [...].
static java.lang.String toBinaryString(short value, int minWidth, int flags)
          Convert a short into a String using the binaries base {0,1} and specified minimum width and control flags [...].
static java.lang.String toHexString(short value)
          Convert a short into a String using the hexadecimal base {0-9,a-f} [...].
static java.lang.String toHexString(short value, int minWidth, int flags)
          Convert a short into a String using the hexadecimal base {0-9,a-f} and specified minimum width and control flags [...].
static java.lang.String toOctalString(short value)
          Convert a short into a String using the octal base {0-7} [...].
static java.lang.String toOctalString(short value, int minWidth, int flags)
          Convert a short into a String using the octal base {0-7} and specified minimum width and control flags [...].
 java.lang.String toString()
          Return the wrapped short as a String.
static java.lang.String toString(short value)
          Convert a short into a string.
static java.lang.String toString(short value, int minWidth, int flags)
          Convert a short into a string using specified minimum width and control flags [...].
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_VALUE

public static final short MIN_VALUE
The minimum value a short can have.

MAX_VALUE

public static final short MAX_VALUE
The maximum value a short can have.

TYPE

public static final java.lang.Class TYPE
The class of this static object [...]. Provides a convenient way to check or compare the type.

PREFIX

public static final int PREFIX
When converting a short to a String using another bases, i.e. binary, hexadecimal etc, this constant controls that there should be a prefix added in front, i.e. 0b, 0x etc.
Constructor Detail

ShortVariable

public ShortVariable()

ShortVariable

public ShortVariable(short sh)
Wraps a short into an object just like java.lang.Short does, but provides some additional methods.
Method Detail

newArray

public static ShortVariable[] newArray(int length)
Creates an array of length instance of this class.

set

public void set(short sh)
Set a new value [...]. This is better than creating a new object all the time.

set

public void set(java.lang.Object o)
Specified by:
set in interface Variable
Overrides:
set in class NumberVariable

get

public java.lang.Object get()
Specified by:
get in interface Variable
Overrides:
get in class NumberVariable

byteValue

public byte byteValue()
Return the wrapped value as a byte.
Overrides:
byteValue in class java.lang.Number

shortValue

public short shortValue()
Return the wrapped value as a short.
Overrides:
shortValue in class java.lang.Number

intValue

public int intValue()
Return the wrapped value as an int.
Overrides:
intValue in class java.lang.Number

longValue

public long longValue()
Return the wrapped value as a long.
Overrides:
longValue in class java.lang.Number

floatValue

public float floatValue()
Return the wrapped value as a float.
Overrides:
floatValue in class java.lang.Number

doubleValue

public double doubleValue()
Return the wrapped value as a double.
Overrides:
doubleValue in class java.lang.Number

toBinaryString

public static java.lang.String toBinaryString(short value)
Convert a short into a String using the binaries base {0,1} [...]. No prefix is added.

toBinaryString

public static java.lang.String toBinaryString(short value,
                                              int minWidth,
                                              int flags)
Convert a short into a String using the binaries base {0,1} and specified minimum width and control flags [...]. With the control flags you can specify the alignment and/or the optional prefix (0b).

toOctalString

public static java.lang.String toOctalString(short value)
Convert a short into a String using the octal base {0-7} [...]. No prefix is added.

toOctalString

public static java.lang.String toOctalString(short value,
                                             int minWidth,
                                             int flags)
Convert a short into a String using the octal base {0-7} and specified minimum width and control flags [...]. With the control flags you can specify the alignment and/or the optional prefix (0).

toHexString

public static java.lang.String toHexString(short value)
Convert a short into a String using the hexadecimal base {0-9,a-f} [...]. No prefix is added.

toHexString

public static java.lang.String toHexString(short value,
                                           int minWidth,
                                           int flags)
Convert a short into a String using the hexadecimal base {0-9,a-f} and specified minimum width and control flags [...]. With the control flags you can specify the alignment and/or the optional prefix (0x).

toString

public static java.lang.String toString(short value,
                                        int minWidth,
                                        int flags)
Convert a short into a string using specified minimum width and control flags [...]. With the control flags you can specify the alignment and control the sign.

toString

public static java.lang.String toString(short value)
Convert a short into a string.

toString

public java.lang.String toString()
Return the wrapped short as a String.
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Return a hash code for this object based on the wrapped value.
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Compare this object with another object [...]. If the objects are equal (in some sence) true is returned, otherwise false. If the object is compare to a null-object, false is always returned. Not all types of objects can be compared with a ShortVariable object. Currently ShortVariable objects can be compared with all java.lang.Number objects including all com.braju.lang.NumberVariable objects.
Overrides:
equals in class java.lang.Object

main

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

braju.com
Java printf & scanf (beta)

Copyright 1997-2000, Henrik Bengtsson.