org.opcfoundation.ua.builtintypes
Class UnsignedLong

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

public final class UnsignedLong
extends Number
implements Comparable<Number>

Unsigned Long represents an integer number value between 0 .. and 0xFFFFFFFFFFFFFFFF.

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

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

To use int as backend use toLongBits() and getFromBits(long).

See Also:
Serialized Form

Field Summary
static NodeId ID
          Constant ID
static UnsignedLong MAX_VALUE
          Constant MAX_VALUE
static UnsignedLong MIN_VALUE
          Constant MIN_VALUE
static UnsignedLong ONE
          Constant ONE
static int SIZE
          Constant SIZE=64
static UnsignedLong ZERO
          Constant ZERO
 
Constructor Summary
UnsignedLong(BigInteger value)
          Constructor for UnsignedLong.
UnsignedLong(int value)
          Constructor for UnsignedLong.
UnsignedLong(long value)
          Construct UnsignedLong from long.
UnsignedLong(String value)
          Constructor for UnsignedLong.
 
Method Summary
 UnsignedLong add(long increment)
          Add a value.
 UnsignedLong add(UnsignedLong increment)
          Add a value.
 BigInteger bigIntegerValue()
          bigIntegerValue.
 int compareTo(Number o)
          compareTo.
 UnsignedLong dec()
          Decrease the value by one.
 double doubleValue()
          
 boolean equals(Object obj)
          
 float floatValue()
          
static UnsignedLong getFromBits(long bits)
          Create unsigned long from 64 bits
 int hashCode()
          
 UnsignedLong inc()
          Increase the value by one.
 int intValue()
          
 long longValue()
          
static UnsignedLong parseUnsignedLong(String s)
          Parse an UnsignedLong value from a string
static UnsignedLong parseUnsignedLong(String s, int radix)
          Parses the string argument as an unsigned long similar to Integer.parseInt(String, int)
 UnsignedLong subtract(long decrement)
          Subtract a value from this value.
 UnsignedLong subtract(UnsignedLong decrement)
          Subtract a value from this value.
 long toLongBits()
          toLongBits.
 String toString()
          
static UnsignedLong valueOf(long value)
          Get cached or create new instance
 
Methods inherited from class java.lang.Number
byteValue, shortValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ID

public static final NodeId ID
Constant ID


SIZE

public static final int SIZE
Constant SIZE=64

See Also:
Constant Field Values

MAX_VALUE

public static final UnsignedLong MAX_VALUE
Constant MAX_VALUE


MIN_VALUE

public static final UnsignedLong MIN_VALUE
Constant MIN_VALUE


ZERO

public static final UnsignedLong ZERO
Constant ZERO


ONE

public static final UnsignedLong ONE
Constant ONE

Constructor Detail

UnsignedLong

public UnsignedLong(BigInteger value)
             throws IllegalArgumentException

Constructor for UnsignedLong.

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

UnsignedLong

public UnsignedLong(int value)

Constructor for UnsignedLong.

Parameters:
value - a int.

UnsignedLong

public UnsignedLong(long value)
Construct UnsignedLong from long. If long is negative, its upper bit is intrepreted as 0x8000000000000000.

Parameters:
value - a long.

UnsignedLong

public UnsignedLong(String value)

Constructor for UnsignedLong.

Parameters:
value - a String object.
Method Detail

getFromBits

public static UnsignedLong getFromBits(long bits)
Create unsigned long from 64 bits

Parameters:
bits - a long.
Returns:
new or cached instance

valueOf

public static UnsignedLong valueOf(long value)
Get cached or create new instance

Parameters:
value - a long.
Returns:
new or cached instance

bigIntegerValue

public BigInteger bigIntegerValue()

bigIntegerValue.

Returns:
a BigInteger object.

doubleValue

public double doubleValue()

Specified by:
doubleValue in class Number

floatValue

public float floatValue()

Specified by:
floatValue in class Number

intValue

public int intValue()

Specified by:
intValue in class Number

longValue

public long longValue()

Specified by:
longValue in class Number

compareTo

public int compareTo(Number o)

compareTo.

Specified by:
compareTo in interface Comparable<Number>
Parameters:
o - a Number object.
Returns:
a int.

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

toString

public String toString()

Overrides:
toString in class Object

toLongBits

public long toLongBits()

toLongBits.

Returns:
a long.

parseUnsignedLong

public static UnsignedLong parseUnsignedLong(String s)
Parse an UnsignedLong value from a string

Parameters:
s - the string to parse, assumed to contain a positive Long value
Returns:
the respective UnsignedInteger

parseUnsignedLong

public static UnsignedLong parseUnsignedLong(String s,
                                             int radix)
                                      throws NumberFormatException,
                                             IllegalArgumentException
Parses the string argument as an unsigned long 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 UnsignedLong
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 UnsignedLong inc()
Increase the value by one. Note that this object is not changed, but a new one is created.

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

dec

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

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

add

public UnsignedLong 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 UnsignedLong, increased by increment from this one.

add

public UnsignedLong add(UnsignedLong 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 UnsignedLong, increased by increment from this one.

subtract

public UnsignedLong 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 UnsignedLong, decreased by decrement from this one.
Throws:
IllegalArgumentException - if the decrement is bigger than the current value

subtract

public UnsignedLong subtract(UnsignedLong 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 UnsignedLong, decreased by decrement from this one.
Throws:
IllegalArgumentException - if the decrement is bigger than the current value


Copyright © 2018. All rights reserved.