|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jruby.util.Convert
Constructor Summary | |
Convert()
|
Method Summary | |
static byte[] |
append(byte[] bytes,
byte value)
|
static int |
arraySize(int x)
Requires positive x. |
static int |
arraySize(long x)
Requires positive x. |
static java.math.BigInteger |
byteArrayToBigInteger(byte[] bytes,
int begin,
int buflen,
int base,
boolean strict)
Converts a byte array to a BigInteger value, using the specified base. |
static double |
byteArrayToDouble(byte[] bytes,
int begin,
int buflen,
boolean strict)
Converts a byte array containing a RubyString representation of a double value to a double. |
static long |
byteArrayToLong(byte[] bytes,
int begin,
int buflen,
int base,
boolean strict)
Converts a byte array to a primitive long value, using the specified base. |
static java.math.BigInteger |
byteListToBigInteger(ByteList bytes)
|
static java.math.BigInteger |
byteListToBigInteger(ByteList bytes,
int base)
|
static java.math.BigInteger |
byteListToBigInteger(ByteList bytes,
int base,
boolean raise)
Converts a ByteList to a BigInteger value, using the specified base. |
static double |
byteListToDouble(ByteList bytes)
|
static double |
byteListToDouble(ByteList bytes,
boolean strict)
Converts a ByteList containing a RubyString representation of a double value to a double. |
static long |
byteListToLong(ByteList bytes)
|
static long |
byteListToLong(ByteList bytes,
int base)
|
static long |
byteListToLong(ByteList bytes,
int base,
boolean raise)
Converts a ByteList to a primitive long value, using the specified base. |
static byte[] |
copy(byte[] bytes)
Returns a copy of the array, or the array itelf if its length == 0. |
static byte[] |
delete(byte[] bytes,
int pos,
boolean copy)
Deletes the byte at the specified position, shifting all bytes to the right of it left by one byte. |
static byte[] |
delete(byte[] bytes,
int pos,
int length,
boolean copy)
|
static byte[] |
doubleToByteArray(double d)
|
static byte[] |
fill(byte[] bytes,
int pos,
int length,
byte value)
Fills the array with the specified value, starting at the specified position, for the specified length. |
static void |
getCharBytes(int i,
int index,
byte[] buf)
Places characters representing the integer i into the character array buf. |
static void |
getCharBytes(long i,
int index,
byte[] buf)
Places characters representing the integer i into the character array buf. |
static void |
getChars(long i,
int index,
char[] buf)
|
static byte[] |
insert(byte[] bytes,
int pos,
byte[] value,
boolean copy)
Inserts the value array at the specified position. |
static byte[] |
insert(byte[] bytes,
int pos,
byte value,
boolean copy)
Inserts a single byte at the specified position. |
static ByteList |
intToBinaryByteList(int i)
|
static byte[] |
intToBinaryBytes(int i)
|
static byte[] |
intToByteArray(int i)
|
static byte[] |
intToByteArray(int i,
int radix,
boolean upper)
|
static ByteList |
intToByteList(int i)
Returns a ByteList object representing the
specified integer. |
static ByteList |
intToByteList(int i,
int radix)
Returns a ByteList object representing the
specified integer, using the specified radix. |
static byte[] |
intToCharBytes(int i)
|
static ByteList |
intToHexByteList(int i)
|
static ByteList |
intToHexByteList(int i,
boolean upper)
|
static byte[] |
intToHexBytes(int i)
|
static byte[] |
intToHexBytes(int i,
boolean upper)
|
static ByteList |
intToOctalByteList(int i)
|
static byte[] |
intToOctalBytes(int i)
|
static byte[] |
intToRawUnsignedBytes(int i,
int shift)
Convert the integer to an unsigned number. |
static byte[] |
intToUnsignedBytes(int i,
int shift,
boolean upper)
Convert the integer to an unsigned number. |
static ByteList |
longToBinaryByteList(long i)
|
static byte[] |
longToBinaryBytes(long i)
|
static byte[] |
longToByteArray(long i)
|
static byte[] |
longToByteArray(long i,
int radix,
boolean upper)
|
static ByteList |
longToByteList(long i)
Returns a ByteList object representing the specified
long . |
static ByteList |
longToByteList(long i,
int radix)
|
static byte[] |
longToCharBytes(long i)
|
static char[] |
longToChars(long i)
|
static ByteList |
longToHexByteList(long i)
|
static ByteList |
longToHexByteList(long i,
boolean upper)
|
static byte[] |
longToHexBytes(long i)
|
static byte[] |
longToHexBytes(long i,
boolean upper)
|
static ByteList |
longToOctalByteList(long i)
|
static byte[] |
longToOctalBytes(long i)
|
static byte[] |
longToRawUnsignedBytes(long i,
int shift)
Convert the long to an unsigned number. |
static byte[] |
longToUnsignedBytes(long i,
int shift,
boolean upper)
Convert the long to an unsigned number. |
static int |
skipLeadingWhitespace(byte[] bytes)
|
static int |
skipTrailingWhitespace(byte[] bytes)
|
static byte[] |
trim(byte[] bytes)
Trims whitespace (any bytes <= 0x20) from the beginning and end of the array. |
static byte[] |
twosComplementToBinaryBytes(byte[] in)
|
static byte[] |
twosComplementToHexBytes(byte[] in,
boolean upper)
|
static byte[] |
twosComplementToOctalBytes(byte[] in)
|
static byte[] |
twosComplementToUnsignedBytes(byte[] in,
int shift,
boolean upper)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Convert()
Method Detail |
public static final ByteList intToByteList(int i)
ByteList
object representing the
specified integer. The argument is converted to signed decimal
representation and returned as a ByteList.
i
- an integer to be converted.
public static final byte[] intToByteArray(int i)
public static final ByteList intToByteList(int i, int radix)
ByteList
object representing the
specified integer, using the specified radix. The argument is
converted to signed decimal representation and returned as a ByteList.
i
- an integer to be converted.radix
- the radix to use in the ByteList representation.
public static final byte[] intToByteArray(int i, int radix, boolean upper)
public static final ByteList longToByteList(long i)
ByteList
object representing the specified
long
. The argument is converted to signed decimal
representation and returned as a ByteList.
i
- a long
to be converted.
public static final byte[] longToByteArray(long i)
public static final ByteList longToByteList(long i, int radix)
public static final byte[] longToByteArray(long i, int radix, boolean upper)
public static final byte[] intToCharBytes(int i)
public static final byte[] longToCharBytes(long i)
public static final char[] longToChars(long i)
public static final void getCharBytes(int i, int index, byte[] buf)
public static final void getCharBytes(long i, int index, byte[] buf)
public static final void getChars(long i, int index, char[] buf)
public static final int arraySize(long x)
public static final int arraySize(int x)
public static final byte[] intToBinaryBytes(int i)
public static final byte[] intToOctalBytes(int i)
public static final byte[] intToHexBytes(int i)
public static final byte[] intToHexBytes(int i, boolean upper)
public static final ByteList intToBinaryByteList(int i)
public static final ByteList intToOctalByteList(int i)
public static final ByteList intToHexByteList(int i)
public static final ByteList intToHexByteList(int i, boolean upper)
public static final byte[] longToBinaryBytes(long i)
public static final byte[] longToOctalBytes(long i)
public static final byte[] longToHexBytes(long i)
public static final byte[] longToHexBytes(long i, boolean upper)
public static final ByteList longToBinaryByteList(long i)
public static final ByteList longToOctalByteList(long i)
public static final ByteList longToHexByteList(long i)
public static final ByteList longToHexByteList(long i, boolean upper)
public static final byte[] intToRawUnsignedBytes(int i, int shift)
public static final byte[] intToUnsignedBytes(int i, int shift, boolean upper)
public static final byte[] longToRawUnsignedBytes(long i, int shift)
public static final byte[] longToUnsignedBytes(long i, int shift, boolean upper)
public static final long byteListToLong(ByteList bytes, int base, boolean raise)
bytes
- base
- raise
-
java.lang.NumberFormatException
public static final long byteListToLong(ByteList bytes, int base)
public static final long byteListToLong(ByteList bytes)
public static final java.math.BigInteger byteListToBigInteger(ByteList bytes, int base, boolean raise)
Intended to be called after byteListToLong if that method fails.
bytes
- base
-
NumberFormatException,
- IllegalArgumentExceptionpublic static final java.math.BigInteger byteListToBigInteger(ByteList bytes, int base)
public static final java.math.BigInteger byteListToBigInteger(ByteList bytes)
public static final long byteArrayToLong(byte[] bytes, int begin, int buflen, int base, boolean strict)
bytes
- buflen
- the effective length of the array (may be less than bytes.length)base
- strict
-
NumberFormatException,
- IllegalArgumentExceptionpublic static final java.math.BigInteger byteArrayToBigInteger(byte[] bytes, int begin, int buflen, int base, boolean strict)
Intended to be called after byteArrayToLong if that method fails.
bytes
- buflen
- the effective length of the array (may be less than bytes.length)base
-
NumberFormatException,
- IllegalArgumentExceptionpublic static final double byteListToDouble(ByteList bytes, boolean strict)
bytes
- the ByteList containing the RubyString value to convertstrict
- if true, strict rules (as required by Float(str)) are enforced;
otherwise, the laxer rules of str.to_f are employed.
public static final double byteListToDouble(ByteList bytes)
public static final double byteArrayToDouble(byte[] bytes, int begin, int buflen, boolean strict)
bytes
- the array containing the RubyString value to convertbuflen
- the length of the array to be usedstrict
- if true, strict rules (as required by Float(str)) are enforced;
otherwise, the laxer rules of str.to_f are employed.
public static final byte[] doubleToByteArray(double d)
public static final byte[] twosComplementToBinaryBytes(byte[] in)
public static final byte[] twosComplementToOctalBytes(byte[] in)
public static final byte[] twosComplementToHexBytes(byte[] in, boolean upper)
public static final byte[] twosComplementToUnsignedBytes(byte[] in, int shift, boolean upper)
public static final int skipLeadingWhitespace(byte[] bytes)
public static final int skipTrailingWhitespace(byte[] bytes)
public static final byte[] trim(byte[] bytes)
bytes
- the array to be trimmed
public static final byte[] delete(byte[] bytes, int pos, boolean copy)
bytes
- the array to 'delete' a byte frompos
- the offset of the byte to deletecopy
- if true, a new copy of the array will be created, with
the original preservedpublic static final byte[] delete(byte[] bytes, int pos, int length, boolean copy)
public static final byte[] insert(byte[] bytes, int pos, byte value, boolean copy)
bytes
- pos
- value
- copy
-
public static final byte[] insert(byte[] bytes, int pos, byte[] value, boolean copy)
bytes
- pos
- value
- copy
-
public static final byte[] append(byte[] bytes, byte value)
public static final byte[] fill(byte[] bytes, int pos, int length, byte value)
bytes
- pos
- length
- value
-
public static final byte[] copy(byte[] bytes)
bytes
-
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |