org.opcfoundation.ua.builtintypes
Class UnsignedInteger

java.lang.Object
  extended by java.lang.Number
      extended by org.opcfoundation.ua.builtintypes.UnsignedInteger
All Implemented Interfaces:
Serializable, Comparable<Number>

public final class UnsignedInteger
extends Number
implements Comparable<Number>

Unsigned Integer represents an integer number value between 0 .. and 0xFFFFFFFF.

There is a static instance for values between 0..1023 which can be accessed using static methods valueOf(long) or getFromBits(int)

This class is immutable - once it has been constructed its value cannot be changed.

To use int as backend use toIntBits() and getFromBits(int).

See Also:
Serialized Form

Field Summary
static long L_MAX_VALUE
          Constant L_MAX_VALUE=0xFFFFFFFFL
static long L_MIN_VALUE
          Constant L_MIN_VALUE=0L
static UnsignedInteger MAX_VALUE
          Constant MAX_VALUE
static UnsignedInteger MIN_VALUE
          Constant MIN_VALUE
static UnsignedInteger ONE
          Constant ONE
static UnsignedInteger ZERO
          Constant ZERO
 
Constructor Summary
UnsignedInteger()
          Constructor for UnsignedInteger.
UnsignedInteger(int value)
          Constructor for UnsignedInteger.
UnsignedInteger(long value)
          Constructor for UnsignedInteger.
UnsignedInteger(String value)
          Constructor for UnsignedInteger.
UnsignedInteger(UnsignedByte value)
          Constructor for UnsignedInteger.
UnsignedInteger(UnsignedInteger value)
          Constructor for UnsignedInteger.
 
Method Summary
 UnsignedInteger add(int increment)
          Add a value.
 UnsignedInteger add(long increment)
          Add a value.
 UnsignedInteger add(UnsignedInteger increment)
          Add a value.
 UnsignedInteger and(int value)
          and.
 UnsignedInteger and(long value)
          and.
 UnsignedInteger and(UnsignedInteger value)
          and.
 byte byteValue()
          
 int compareTo(Number o)
          
 UnsignedInteger dec()
          Decrease the value by one.
 double doubleValue()
          
 boolean equals(Object obj)
          
 float floatValue()
          
static UnsignedInteger getFromBits(int value)
          getFromBits.
 long getValue()
          Getter for the field value.
 int hashCode()
          
 UnsignedInteger inc()
          Increase the value by one.
 int intValue()
          
 long longValue()
          
static UnsignedInteger max(UnsignedInteger v0, UnsignedInteger v1)
          max.
static UnsignedInteger min(UnsignedInteger v0, UnsignedInteger v1)
          min.
 UnsignedInteger or(int value)
          or.
 UnsignedInteger or(long value)
          or.
 UnsignedInteger or(UnsignedInteger value)
          or.
static UnsignedInteger parseUnsignedInteger(String s)
          Parse an UnsignedInteger value from a string
static UnsignedInteger parseUnsignedInteger(String s, int radix)
          Parses the string argument as an unsigned integer similar to Integer.parseInt(String, int)
 UnsignedInteger subtract(int decrement)
          Subtract a value from this value.
 UnsignedInteger subtract(long decrement)
          Subtract a value from this value.
 UnsignedInteger subtract(UnsignedInteger decrement)
          Subtract a value from this value.
 int toIntBits()
          toIntBits.
 String toString()
          
static UnsignedInteger valueOf(long value)
          valueOf.
 
Methods inherited from class java.lang.Number
shortValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

L_MAX_VALUE

public static final long L_MAX_VALUE
Constant L_MAX_VALUE=0xFFFFFFFFL

See Also:
Constant Field Values

L_MIN_VALUE

public static final long L_MIN_VALUE
Constant L_MIN_VALUE=0L

See Also:
Constant Field Values

MAX_VALUE

public static final UnsignedInteger MAX_VALUE
Constant MAX_VALUE


MIN_VALUE

public static final UnsignedInteger MIN_VALUE
Constant MIN_VALUE


ZERO

public static final UnsignedInteger ZERO
Constant ZERO


ONE

public static final UnsignedInteger ONE
Constant ONE

Constructor Detail

UnsignedInteger

public UnsignedInteger()

Constructor for UnsignedInteger.


UnsignedInteger

public UnsignedInteger(int value)
                throws IllegalArgumentException

Constructor for UnsignedInteger.

Parameters:
value - a int.
Throws:
IllegalArgumentException - if any.

UnsignedInteger

public UnsignedInteger(long value)
                throws IllegalArgumentException

Constructor for UnsignedInteger.

Parameters:
value - a long.
Throws:
IllegalArgumentException - if any.

UnsignedInteger

public UnsignedInteger(String value)
                throws IllegalArgumentException

Constructor for UnsignedInteger.

Parameters:
value - a String object.
Throws:
IllegalArgumentException - if any.

UnsignedInteger

public UnsignedInteger(UnsignedInteger value)

Constructor for UnsignedInteger.

Parameters:
value - a UnsignedInteger object.

UnsignedInteger

public UnsignedInteger(UnsignedByte value)

Constructor for UnsignedInteger.

Parameters:
value - a UnsignedByte object.
Method Detail

getFromBits

public static UnsignedInteger getFromBits(int value)

getFromBits.

Parameters:
value - a int.
Returns:
a UnsignedInteger object.

valueOf

public static UnsignedInteger valueOf(long value)

valueOf.

Parameters:
value - a long.
Returns:
a UnsignedInteger object.

max

public static UnsignedInteger max(UnsignedInteger v0,
                                  UnsignedInteger v1)

max.

Parameters:
v0 - a UnsignedInteger object.
v1 - a UnsignedInteger object.
Returns:
a UnsignedInteger object.

min

public static UnsignedInteger min(UnsignedInteger v0,
                                  UnsignedInteger v1)

min.

Parameters:
v0 - a UnsignedInteger object.
v1 - a UnsignedInteger object.
Returns:
a UnsignedInteger object.

getValue

public long getValue()

Getter for the field value.

Returns:
a long.

byteValue

public byte byteValue()

Overrides:
byteValue in class Number

doubleValue

public double doubleValue()

Specified by:
doubleValue in class Number

floatValue

public float floatValue()

Specified by:
floatValue in class Number

toIntBits

public int toIntBits()

toIntBits.

Returns:
a int.

intValue

public int intValue()

Specified by:
intValue in class Number

longValue

public long longValue()

Specified by:
longValue in class Number

hashCode

public int hashCode()

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

toString

public String toString()

Overrides:
toString in class Object

and

public UnsignedInteger and(UnsignedInteger value)

and.

Parameters:
value - a UnsignedInteger object.
Returns:
a UnsignedInteger object.

and

public UnsignedInteger and(int value)

and.

Parameters:
value - a int.
Returns:
a UnsignedInteger object.

and

public UnsignedInteger and(long value)

and.

Parameters:
value - a long.
Returns:
a UnsignedInteger object.

or

public UnsignedInteger or(UnsignedInteger value)

or.

Parameters:
value - a UnsignedInteger object.
Returns:
a UnsignedInteger object.

or

public UnsignedInteger or(int value)

or.

Parameters:
value - a int.
Returns:
a UnsignedInteger object.

or

public UnsignedInteger or(long value)

or.

Parameters:
value - a long.
Returns:
a UnsignedInteger object.

compareTo

public int compareTo(Number o)

Specified by:
compareTo in interface Comparable<Number>

parseUnsignedInteger

public static UnsignedInteger parseUnsignedInteger(String s)
                                            throws NumberFormatException,
                                                   IllegalArgumentException
Parse an UnsignedInteger value from a string

Parameters:
s - the string to parse, assumed to contain a positive Long value
Returns:
the respective UnsignedInteger
Throws:
NumberFormatException - if the string cannot be parsed into an integer value
IllegalArgumentException - if the parsed value does not fit in the range of UnsignedInteger

parseUnsignedInteger

public static UnsignedInteger parseUnsignedInteger(String s,
                                                   int radix)
                                            throws NumberFormatException,
                                                   IllegalArgumentException
Parses the string argument as an unsigned integer similar to Integer.parseInt(String, int)

Parameters:
s - the string to parse, assumed to contain a positive Long value
radix - the radix to be used while parsing s.
Returns:
the respective UnsignedInteger
Throws:
NumberFormatException - if the string cannot be parsed into an integer value
IllegalArgumentException - if the parsed value does not fit in the range of UnsignedInteger

inc

public UnsignedInteger inc()
Increase the value by one. Note that this object is not changed, but a new one is created.

Returns:
a new UnsignedInteger, increased by 1 from this one.

dec

public UnsignedInteger dec()
Decrease the value by one. Note that this object is not changed, but a new one is created.

Returns:
a new UnsignedInteger, decreased by 1 from this one.
Throws:
IllegalArgumentException - if the value was 0 before the call

add

public UnsignedInteger add(int increment)
Add a value. Note that this object is not changed, but a new one is created.

Parameters:
increment - the value to add to the current value
Returns:
a new UnsignedInteger, increased by increment from this one.

add

public UnsignedInteger add(long increment)
Add a value. Note that this object is not changed, but a new one is created.

Parameters:
increment - the value to add to the current value
Returns:
a new UnsignedInteger, increased by increment from this one.

add

public UnsignedInteger add(UnsignedInteger increment)
Add a value. Note that this object is not changed, but a new one is created.

Parameters:
increment - the value to add to the current value
Returns:
a new UnsignedInteger, increased by increment from this one.

subtract

public UnsignedInteger subtract(int decrement)
Subtract a value from this value. Note that this object is not changed, but a new one is created.

Parameters:
decrement - the value to subtract from the current value
Returns:
a new UnsignedInteger, decreased by decrement from this one.
Throws:
IllegalArgumentException - if the decrement is bigger than the current value

subtract

public UnsignedInteger subtract(long decrement)
Subtract a value from this value. Note that this object is not changed, but a new one is created.

Parameters:
decrement - the value to subtract from the current value
Returns:
a new UnsignedInteger, decreased by decrement from this one.
Throws:
IllegalArgumentException - if the decrement is bigger than the current value

subtract

public UnsignedInteger subtract(UnsignedInteger decrement)
Subtract a value from this value. Note that this object is not changed, but a new one is created.

Parameters:
decrement - the value to subtract from the current value
Returns:
a new UnsignedInteger, decreased by decrement from this one.
Throws:
IllegalArgumentException - if the decrement is bigger than the current value


Copyright © 2018. All rights reserved.