Secure iNet Factory

com.jscape.inet.ssh.types
Class SshUint32

java.lang.Object
  extended by com.jscape.inet.ssh.types.SshUint32
All Implemented Interfaces:
java.lang.Comparable

public final class SshUint32
extends java.lang.Object
implements java.lang.Comparable

SSH2 uint32. Represents a 32-bit unsigned integer. Stored as four bytes in the order of decreasing significance (network byte order).

Version:
1.0
Author:
Alex Usun

Field Summary
static int LENGTH
          Type's length in bytes.
static long MAX_VALUE
          A constant holding the maximum value a SSH uint32 can have, 4294967295.
static long MIN_VALUE
          A constant holding the minimum value a SSH uint32 can have, 0.
 
Constructor Summary
SshUint32(long value)
          Creates a new SSH uint32 instance.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares this object with the specified object for order.
 boolean equals(java.lang.Object o)
          Compares two objects for the logical equality.
 int hashCode()
          Computes object's hash code.
 int intValue()
          Obtains the current value as integer.
 long longValue()
          Obtains the current value as long.
static SshUint32 readFrom(java.io.InputStream in)
          Reads SSH uint32 object from the stream.
static int readIntFrom(java.io.InputStream in)
          Reads SSH uint32 value from the stream and returns it as Java integer value.
static long readLongFrom(java.io.InputStream in)
          Reads SSH uint32 value from the stream and returns it as Java long value.
static long readValue(java.io.InputStream in)
          Reads a value from the specified stream.
static int restore(byte[] buffer, int offset)
           
static void store(int val, byte[] data, int offset)
           
 java.lang.String toString()
          Provides object string representation.
static void writeIntTo(int value, java.io.OutputStream out)
          Writes the specified value to the stream.
static void writeLongTo(long value, java.io.OutputStream out)
          Writes the specified value to the stream.
 void writeTo(java.io.OutputStream out)
          Writes the current SSH uint32 value to the stream.
static void writeValue(long value, java.io.OutputStream out)
          Writes the specified value to the stream.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_VALUE

public static final long MIN_VALUE
A constant holding the minimum value a SSH uint32 can have, 0.

See Also:
Constant Field Values

MAX_VALUE

public static final long MAX_VALUE
A constant holding the maximum value a SSH uint32 can have, 4294967295.

See Also:
Constant Field Values

LENGTH

public static final int LENGTH
Type's length in bytes.

See Also:
Constant Field Values
Constructor Detail

SshUint32

public SshUint32(long value)
Creates a new SSH uint32 instance.

Parameters:
value - instance value
Method Detail

readValue

public static long readValue(java.io.InputStream in)
                      throws java.io.IOException
Reads a value from the specified stream.

Parameters:
in - input stream
Returns:
read value
Throws:
java.io.IOException - if an I/O error occurs

writeValue

public static void writeValue(long value,
                              java.io.OutputStream out)
                       throws java.io.IOException
Writes the specified value to the stream.

Parameters:
value - value to write
out - output stream
Throws:
java.io.IOException - if an I/O error occurs

readLongFrom

public static long readLongFrom(java.io.InputStream in)
                         throws java.io.IOException
Reads SSH uint32 value from the stream and returns it as Java long value.

Parameters:
in - input stream
Returns:
readed long value
Throws:
java.io.IOException - if I/O error occurs

readIntFrom

public static int readIntFrom(java.io.InputStream in)
                       throws java.io.IOException
Reads SSH uint32 value from the stream and returns it as Java integer value.

Parameters:
in - input stream
Returns:
readed integer value
Throws:
java.io.IOException - if I/O error occurs

readFrom

public static SshUint32 readFrom(java.io.InputStream in)
                          throws java.io.IOException
Reads SSH uint32 object from the stream.

Parameters:
in - input stream
Returns:
readed SSH uint32 object
Throws:
java.io.IOException - if I/O error occurs

writeLongTo

public static void writeLongTo(long value,
                               java.io.OutputStream out)
                        throws java.io.IOException
Writes the specified value to the stream. Actually only the four lower bytes of the specified value will be written.

Parameters:
value - value to write
out - output stream
Throws:
java.io.IOException - if I/O error occurs

writeIntTo

public static void writeIntTo(int value,
                              java.io.OutputStream out)
                       throws java.io.IOException
Writes the specified value to the stream.

Parameters:
value - value to write
out - output stream
Throws:
java.io.IOException - if I/O error occurs

intValue

public int intValue()
Obtains the current value as integer.

Returns:
the current value as integer.

longValue

public long longValue()
Obtains the current value as long.

Returns:
the current value as long.

toString

public java.lang.String toString()
Provides object string representation.

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

equals

public boolean equals(java.lang.Object o)
Compares two objects for the logical equality.

Overrides:
equals in class java.lang.Object
Parameters:
o - object to compare
Returns:
true if objects are logically equal; false otherwise

hashCode

public int hashCode()
Computes object's hash code.

Overrides:
hashCode in class java.lang.Object
Returns:
object's hash code

compareTo

public int compareTo(java.lang.Object o)
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.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - object to be compared
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

writeTo

public void writeTo(java.io.OutputStream out)
             throws java.io.IOException
Writes the current SSH uint32 value to the stream.

Parameters:
out - output stream
Throws:
java.io.IOException - if I/O error occurs

restore

public static int restore(byte[] buffer,
                          int offset)

store

public static void store(int val,
                         byte[] data,
                         int offset)

Secure iNet Factory

Copyright © JSCAPE LLC. 1999-2011. All Rights Reserved