Secure iNet Factory

com.jscape.inet.ssh.types
Class SshByte

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

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

SSH2 byte. A byte represents an arbitrary 8-bit value (octet) in range [0..255].

Version:
1.0
Author:
Alex Usun

Field Summary
static int LENGTH
          Type's length in bytes.
static int MAX_VALUE
          A constant holding the maximum value a SSH byte can have, 255.
static int MIN_VALUE
          A constant holding the minimum value a SSH byte can have, 0.
 
Constructor Summary
SshByte(int value)
          Creates a new SSH byte 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.
static SshByte readFrom(java.io.InputStream in)
          Reads SSH byte object from the stream.
static int readIntFrom(java.io.InputStream in)
          Reads SSH byte value from the stream and returns it as Java integer value.
static int readValue(java.io.InputStream in)
          Reads a value from the specified stream.
static int restore(byte[] buffer, 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.
 void writeTo(java.io.OutputStream out)
          Writes the current SSH byte value to the stream.
static void writeValue(int 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 int MIN_VALUE
A constant holding the minimum value a SSH byte can have, 0.

See Also:
Constant Field Values

MAX_VALUE

public static final int MAX_VALUE
A constant holding the maximum value a SSH byte can have, 255.

See Also:
Constant Field Values

LENGTH

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

See Also:
Constant Field Values
Constructor Detail

SshByte

public SshByte(int value)
Creates a new SSH byte instance.

Parameters:
value - instance value
Method Detail

readValue

public static int 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(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 an I/O error occurs

readIntFrom

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

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

readFrom

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

Parameters:
in - input stream
Returns:
readed SSH byte object
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. Actually only the lower byte of the specified value will be written.

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.

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 byte 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)

Secure iNet Factory

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