Secure iNet Factory

com.jscape.inet.ssh.types
Class SshMpint

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

public class SshMpint
extends java.lang.Object
implements java.lang.Comparable

Represents multiple precision integers in two's complement format, stored as a string, 8 bits per byte, MSB first. Negative numbers have the value 1 as the most significant bit of the first byte of the data partition. If the most significant bit would be set for a positive number, the number is preceded by a zero byte.

Version:
1.0
Author:
Alex Usun

Constructor Summary
SshMpint(java.math.BigInteger value)
          Creates a new SSH mpint instance.
 
Method Summary
 java.math.BigInteger bigIntegerValue()
          Obtains the current value as big integer.
 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.
static java.math.BigInteger readBigIntegerFrom(java.io.InputStream in)
          Reads SSH mpint value from the stream and returns it as Java big integer.
static SshMpint readFrom(java.io.InputStream in)
          Reads SSH mpint object from the stream.
static byte[] readValue(java.io.InputStream in)
          Reads a value from the specified stream.
 java.lang.String toString()
          Provides object string representation.
static void writeBigIntegerTo(java.math.BigInteger 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(byte[] 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
 

Constructor Detail

SshMpint

public SshMpint(java.math.BigInteger value)
Creates a new SSH mpint instance.

Parameters:
value - instance value
Method Detail

readValue

public static byte[] 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 a error occurs

writeValue

public static void writeValue(byte[] 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 error occurs

readBigIntegerFrom

public static java.math.BigInteger readBigIntegerFrom(java.io.InputStream in)
                                               throws java.io.IOException
Reads SSH mpint value from the stream and returns it as Java big integer.

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

readFrom

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

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

writeBigIntegerTo

public static void writeBigIntegerTo(java.math.BigInteger 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

bigIntegerValue

public java.math.BigInteger bigIntegerValue()
Obtains the current value as big integer.

Returns:
the current value as big integer.

toString

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

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

hashCode

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

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

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

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

Secure iNet Factory

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