Top Inners Fields Constructors Methods
org.jruby.util

public Class Pack

extends Object
Class Inheritance
Imports
java.math.BigInteger, java.nio.ByteBuffer, .ByteOrder, org.jcodings.specific.ASCIIEncoding, .USASCIIEncoding, .UTF8Encoding, org.jruby.*, org.jruby.platform.Platform, org.jruby.runtime.Block, .ThreadContext, org.jruby.runtime.builtin.IRubyObject, org.jruby.util.io.EncodingUtils

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
private abstract static class
private static class
Pack.PackInts

Introduced to allow outlining cases in #packCommon that update both of these values.

private abstract static class

Field Summary

Modifier and TypeField and Description
private static final ASCIIEncoding
private static final byte[]
public static final int[]
private static final char
private static final Pack.Converter[]
private static final String
private static final int
private static final char
private static final String
private static final String
NATIVE_CODES

Native pack type.

public static final byte[]
private static final byte[]
private static final byte[]
private static final String
private static final int
private static final int
UNPACK_ARRAY

Unpack modes

private static final int
private static final USASCIIEncoding
private static final UTF8Encoding
private static final long[]
private static final byte[]

Constructor Summary

AccessConstructor and Description
public
Pack()

Method Summary

Modifier and TypeMethod and Description
private static int
adjustEncInfo(int type, int enc_info)

private static void
appendOrYield(ThreadContext context, Block block, RubyArray<T extends IRubyObject> result, IRubyObject item, int mode)

private static IRubyObject
appendOrYield(ThreadContext context, Block block, RubyArray<T extends IRubyObject> result, ByteList item, int mode)

public static IRubyObject
decode(ThreadContext context, ByteBuffer encode, int occurrences, RubyArray<T extends IRubyObject> result, Block block, Pack.Converter converter, int mode)

public static void
decode(ThreadContext context, Ruby runtime, ByteBuffer encode, int occurrences, RubyArray<T extends IRubyObject> result, Block block, Pack.Converter converter)
Deprecated

private static double

Returns:

the double value
decodeDoubleBigEndian
(ByteBuffer
string to get int from
encode
)

Decode a double in big-endian from a packed value

private static double

Returns:

the double value
decodeDoubleLittleEndian
(ByteBuffer
string to get int from
encode
)

Decode a double from a packed value

private static float

Returns:

the double value
decodeFloatBigEndian
(ByteBuffer
string to get int from
encode
)

Decode a float in big-endian from a packed value

private static float

Returns:

the double value
decodeFloatLittleEndian
(ByteBuffer
string to get int from
encode
)

Decode a float in little-endian from a packed value

private static int

Returns:

the decoded integer
decodeIntBigEndian
(ByteBuffer
string to get int from
encode
)

Retrieve an encoded int in little endian starting at index in the string value.

private static int

Returns:

the decoded integer
decodeIntLittleEndian
(ByteBuffer
string to get int from
encode
)

Retrieve an encoded int in little endian starting at index in the string value.

private static long

Returns:

the decoded integer
decodeIntUnsignedBigEndian
(ByteBuffer
string to get int from
encode
)

Retrieve an encoded int in big endian starting at index in the string value.

private static long

Returns:

the decoded integer
decodeIntUnsignedLittleEndian
(ByteBuffer
the encoded string
encode
)

Retrieve an encoded int in little endian starting at index in the string value.

private static long

Returns:

the long value
decodeLongBigEndian
(ByteBuffer
string to get int from
encode
)

Decode a long in big-endian format from a packed value

private static long

Returns:

the long value
decodeLongLittleEndian
(ByteBuffer
string to get int from
encode
)

Decode a long in little-endian format from a packed value

private static short

Returns:

the short value
decodeShortBigEndian
(ByteBuffer
string to get int from
encode
)

Decode a short in big-endian from a packed value

private static int

Returns:

the short value
decodeShortLittleEndian
(ByteBuffer
string to get int from
encode
)

Decode a short in little-endian from a packed value

private static int

Returns:

the short value
decodeShortUnsignedBigEndian
(ByteBuffer
string to get int from
encode
)

Decode a short in big-endian from a packed value

private static int

Returns:

the short value
decodeShortUnsignedLittleEndian
(ByteBuffer
string to get int from
encode
)

Decode a short in little-endian from a packed value

private static int
encode(ThreadContext context, int occurrences, ByteList result, RubyArray<T extends IRubyObject> list, int index, Pack.ConverterExecutor converter)

private static void
encodeDoubleBigEndian(ByteList
to pack double into
result
,
double
is the double to encode
d
)

Encode a double in big-endian format into a packed value

private static void
encodeDoubleLittleEndian(ByteList
to pack double into
result
,
double
is the double to encode
d
)

Encode a double in little endian format into a packed value

private static void
encodeFloatBigEndian(ByteList
to pack float into
result
,
float
is the float to encode
f
)

Encode a float in big-endian format into a packed value

private static void
encodeFloatLittleEndian(ByteList
to pack float into
result
,
float
is the float to encode
f
)

Encode a float in little endian format into a packed value

private static void
encodeIntBigEndian(ByteList
to be appended to
result
,
int
the integer to encode
s
)

Encode an int in big-endian format into a packed representation.

private static void
encodeIntLittleEndian(ByteList
to be appended to
result
,
int
the integer to encode
s
)

Encode an int in little endian format into a packed representation.

private static void
encodeLongBigEndian(ByteList
to pack long into
result
,
long
is the long to encode
l
)

Encode a long in big-endian format into a packed value

private static void
encodeLongLittleEndian(ByteList
to pack long into
result
,
long
is the long to encode
l
)

Encode a long in little-endian format into a packed value

private static ByteList

Returns:

the io2Append buffer
encodes
(ThreadContext context, ByteList
The StringBuffer which should receive the result
io2Append
,
byte[]
The String to encode
charsToEncode
,
int startIndex, int
The max number of characters to encode
length
,
int charCount, byte
the type of encoding required (this is the same type as used by the pack method)
encodingType
,
boolean
true if the traililng "\n" is needed
tailLf
)

encodes a String in base64 or its uuencode variant.

private static void
encodeShortBigEndian(ByteList
to be appended to
result
,
int
the short to encode
s
)

Encode an shortin big-endian format into a packed representation.

private static void
encodeShortLittleEndian(ByteList
to be appended to
result
,
int
the short to encode
s
)

Encode an short in little endian format into a packed representation.

private static void
encodeUM(ThreadContext context, ByteList lCurElemString, int occurrences, boolean ignoreStar, char type, ByteList result)

private static Pack.ConverterExecutor
public static int
getDirective(ThreadContext context, String mode, ByteList formatString, ByteBuffer encode)

private static final ByteList

Returns:

the padded buffer
grow
(ByteList
the buffer to grow
i2Grow
,
byte[]
the string used as padding
iPads
,
int
how much padding is needed
iLength
)

grows a stringbuffer.

private static boolean
isSpace(int type)

private static long
private static double
private static float
public static RubyString
pack(ThreadContext context, RubyArray<T extends IRubyObject> list, RubyString formatString, RubyString buffer)

public static RubyString
pack(Ruby runtime, RubyArray<T extends IRubyObject> list, ByteList formatString)
Deprecated

public static RubyString
pack(ThreadContext context, Ruby runtime, RubyArray<T extends IRubyObject> list, RubyString formatString)
Deprecated

private static void
pack_at(ByteList result, int occurrences)

private static void
pack_h(ThreadContext context, RubyArray<T extends IRubyObject> list, ByteList result, Pack.PackInts packInts, int type, int occurrences, boolean isStar)

private static void
pack_h_aAZ(ByteList result, int type, ByteList lCurElemString, int occurrences)

private static void
pack_h_B(ByteList result, ByteList lCurElemString, int occurrences)

private static void
pack_h_b(ByteList result, ByteList lCurElemString, int occurrences)

private static void
pack_h_H(ByteList result, ByteList lCurElemString, int occurrences)

private static void
pack_h_h(ByteList result, ByteList lCurElemString, int occurrences)

private static void
pack_h_inner(ByteList result, int type, ByteList lCurElemString, int occurrences)

private static void
pack_M(ThreadContext context, RubyArray<T extends IRubyObject> list, ByteList result, Pack.PackInts packInts, int occurrences)

private static void
pack_m(ThreadContext context, RubyArray<T extends IRubyObject> list, ByteList result, Pack.PackInts packInts, char type, int occurrences, boolean ignoreStar)

private static void
pack_U(ThreadContext context, RubyArray<T extends IRubyObject> list, ByteList result, Pack.PackInts packInts, int occurrences)

private static void
pack_w(ThreadContext context, RubyArray<T extends IRubyObject> list, ByteList result, Pack.PackInts packInts, int occurrences)

private static void
pack_X(ThreadContext context, ByteList result, int occurrences)

private static RubyString
packCommon(ThreadContext context, RubyArray<T extends IRubyObject> list, ByteList formatString, Pack.ConverterExecutor executor, RubyString buffer)

public static ByteList
packInt_i(ByteList result, int s)

public static int
private static final ByteList

Returns:

the stringbuffer
shrink
(ByteList
the stringbuffer
i2Shrink
,
int
how much to shrink
iLength
)

shrinks a stringbuffer.

private static int
private static void
unknownDirective(ThreadContext context, String mode, int type, ByteList formatString)

public static RubyArray<T extends IRubyObject>
unpack(ThreadContext context, ByteList encodedString, ByteList formatString)

public static RubyArray<T extends IRubyObject>

Returns:

unpacked array
unpack
(ThreadContext context, RubyString encoded, ByteList formatString)

public static RubyArray<T extends IRubyObject>
unpack(Ruby runtime, ByteList encodedString, ByteList formatString)
Deprecated

public static IRubyObject
unpack1WithBlock(ThreadContext context, RubyString encoded, ByteList formatString, Block block)

public static IRubyObject
unpack1WithBlock(ThreadContext context, RubyString encoded, ByteList formatString, long offset, Block block)

private static IRubyObject
unpack_a(ThreadContext context, Block block, RubyArray<T extends IRubyObject> result, ByteBuffer encode, int occurrences, int mode)

private static IRubyObject
unpack_A(ThreadContext context, Block block, RubyArray<T extends IRubyObject> result, ByteBuffer encode, int occurrences, int mode)

private static void
unpack_at(ThreadContext context, ByteList encodedString, ByteBuffer encode, int occurrences)

private static IRubyObject
unpack_B(ThreadContext context, Block block, RubyArray<T extends IRubyObject> result, ByteBuffer encode, int occurrences, int mode)

private static IRubyObject
unpack_b(ThreadContext context, Block block, RubyArray<T extends IRubyObject> result, ByteBuffer encode, int occurrences, int mode)

private static IRubyObject
unpack_H(ThreadContext context, Block block, RubyArray<T extends IRubyObject> result, ByteBuffer encode, int occurrences, int mode)

private static IRubyObject
unpack_h(ThreadContext context, Block block, RubyArray<T extends IRubyObject> result, ByteBuffer encode, int occurrences, int mode)

private static IRubyObject
unpack_M(ThreadContext context, Block block, RubyArray<T extends IRubyObject> result, ByteBuffer encode, int mode)

private static IRubyObject
unpack_m(ThreadContext context, Block block, RubyArray<T extends IRubyObject> result, ByteBuffer encode, int occurrences, int mode)

private static int
unpack_m_nonzeroOccurrences(ByteBuffer encode, byte[] lElem, int a, int b, int c, int index)

private static int
unpack_m_zeroOccurrences(ThreadContext context, ByteBuffer encode, byte[] lElem, int a, int b, int c, int index, int s)

private static IRubyObject
unpack_U(ThreadContext context, Block block, RubyArray<T extends IRubyObject> result, ByteBuffer encode, int occurrences, int mode)

private static IRubyObject
unpack_u(ThreadContext context, Block block, RubyArray<T extends IRubyObject> result, ByteBuffer encode, int mode)

private static IRubyObject
unpack_w(ThreadContext context, Block block, RubyArray<T extends IRubyObject> result, ByteBuffer encode, int occurrences, int mode)

private static void
unpack_x(ThreadContext context, ByteBuffer encode, int occurrences)

private static void
unpack_X(ThreadContext context, ByteBuffer encode, int occurrences)

private static IRubyObject
unpack_Z(ThreadContext context, Block block, RubyArray<T extends IRubyObject> result, ByteBuffer encode, int occurrences, int mode)

private static RubyString
public static int
private static IRubyObject
unpackInternal(ThreadContext context, RubyString encoded, ByteList formatString, int mode, long offset, Block block)

public static RubyArray<T extends IRubyObject>
unpackWithBlock(ThreadContext context, RubyString encoded, ByteList formatString, Block block)

Decodes str (which may contain binary data) according to the format string, returning an array of each value extracted.

public static RubyArray<T extends IRubyObject>
unpackWithBlock(ThreadContext context, RubyString encoded, ByteList formatString, long offset, Block block)

public static RubyArray<T extends IRubyObject>
unpackWithBlock(ThreadContext context, Ruby runtime, ByteList encodedString, ByteList formatString, Block block)
Deprecated

public static int
utf8Decode(Ruby runtime, byte[] to, int p, int code)

rb_uv_to_utf8

private static int
utf8Decode(ByteBuffer buffer)

utf8_to_uv

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait