public class Pack
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Pack.Converter |
private static class |
Pack.ConverterExecutor |
private static class |
Pack.QuadConverter |
| Modifier and Type | Field and Description |
|---|---|
private static org.jcodings.specific.ASCIIEncoding |
ASCII |
private static byte[] |
b64_table |
private static int[] |
b64_xtable |
private static char |
BE |
private static Pack.Converter[] |
converters |
private static java.lang.String |
ENDIANESS_CODES |
private static byte[] |
hex_table |
private static int |
IS_STAR |
private static char |
LE |
private static java.lang.String |
MAPPED_CODES |
private static java.lang.String |
NATIVE_CODES
Native pack type.
|
private static java.lang.String |
PACK_IGNORE_NULL_CODES |
private static java.lang.String |
PACK_IGNORE_NULL_CODES_WITH_MODIFIERS |
private static java.math.BigInteger |
QUAD_MAX |
private static java.math.BigInteger |
QUAD_MIN |
private static byte[] |
sHexDigits |
private static byte[] |
sNil10 |
private static byte[] |
sSp10 |
private static java.lang.String |
sTooFew |
private static java.lang.String |
UNPACK_IGNORE_NULL_CODES |
private static org.jcodings.specific.USASCIIEncoding |
USASCII |
private static org.jcodings.specific.UTF8Encoding |
UTF8 |
private static long[] |
utf8_limits |
private static byte[] |
uu_table |
| Constructor and Description |
|---|
Pack() |
| Modifier and Type | Method and Description |
|---|---|
static void |
decode(Ruby runtime,
java.nio.ByteBuffer encode,
int occurrences,
RubyArray result,
Pack.Converter converter) |
private static double |
decodeDoubleBigEndian(java.nio.ByteBuffer encode)
Decode a double in big-endian from a packed value
|
private static double |
decodeDoubleLittleEndian(java.nio.ByteBuffer encode)
Decode a double from a packed value
|
private static float |
decodeFloatBigEndian(java.nio.ByteBuffer encode)
Decode a float in big-endian from a packed value
|
private static float |
decodeFloatLittleEndian(java.nio.ByteBuffer encode)
Decode a float in little-endian from a packed value
|
private static int |
decodeIntBigEndian(java.nio.ByteBuffer encode)
Retrieve an encoded int in little endian starting at index in the
string value.
|
private static int |
decodeIntLittleEndian(java.nio.ByteBuffer encode)
Retrieve an encoded int in little endian starting at index in the
string value.
|
private static long |
decodeIntUnsignedBigEndian(java.nio.ByteBuffer encode)
Retrieve an encoded int in big endian starting at index in the string
value.
|
private static long |
decodeIntUnsignedLittleEndian(java.nio.ByteBuffer encode)
Retrieve an encoded int in little endian starting at index in the
string value.
|
private static long |
decodeLongBigEndian(java.nio.ByteBuffer encode)
Decode a long in big-endian format from a packed value
|
private static long |
decodeLongLittleEndian(java.nio.ByteBuffer encode)
Decode a long in little-endian format from a packed value
|
private static short |
decodeShortBigEndian(java.nio.ByteBuffer encode)
Decode a short in big-endian from a packed value
|
private static int |
decodeShortLittleEndian(java.nio.ByteBuffer encode)
Decode a short in little-endian from a packed value
|
private static int |
decodeShortUnsignedBigEndian(java.nio.ByteBuffer encode)
Decode a short in big-endian from a packed value
|
private static int |
decodeShortUnsignedLittleEndian(java.nio.ByteBuffer encode)
Decode a short in little-endian from a packed value
|
static int |
encode(Ruby runtime,
int occurrences,
org.jruby.util.ByteList result,
RubyArray list,
int index,
Pack.ConverterExecutor converter) |
private static void |
encodeDoubleBigEndian(org.jruby.util.ByteList result,
double d)
Encode a double in big-endian format into a packed value
|
private static void |
encodeDoubleLittleEndian(org.jruby.util.ByteList result,
double d)
Encode a double in little endian format into a packed value
|
private static void |
encodeFloatBigEndian(org.jruby.util.ByteList result,
float f)
Encode a float in big-endian format into a packed value
|
private static void |
encodeFloatLittleEndian(org.jruby.util.ByteList result,
float f)
Encode a float in little endian format into a packed value
|
private static void |
encodeIntBigEndian(org.jruby.util.ByteList result,
int s)
Encode an int in big-endian format into a packed representation.
|
private static void |
encodeIntLittleEndian(org.jruby.util.ByteList result,
int s)
Encode an int in little endian format into a packed representation.
|
private static void |
encodeLongBigEndian(org.jruby.util.ByteList result,
long l)
Encode a long in big-endian format into a packed value
|
private static void |
encodeLongLittleEndian(org.jruby.util.ByteList result,
long l)
Encode a long in little-endian format into a packed value
|
private static org.jruby.util.ByteList |
encodes(Ruby runtime,
org.jruby.util.ByteList io2Append,
byte[] charsToEncode,
int startIndex,
int length,
int charCount,
byte encodingType,
boolean tailLf)
encodes a String in base64 or its uuencode variant.
|
private static void |
encodeShortBigEndian(org.jruby.util.ByteList result,
int s)
Encode an shortin big-endian format into a packed representation.
|
private static void |
encodeShortLittleEndian(org.jruby.util.ByteList result,
int s)
Encode an short in little endian format into a packed representation.
|
private static Pack.ConverterExecutor |
executor18() |
private static Pack.ConverterExecutor |
executor19() |
private static org.jruby.util.ByteList |
grow(org.jruby.util.ByteList i2Grow,
byte[] iPads,
int iLength)
grows a stringbuffer.
|
private static long |
num2quad(IRubyObject arg) |
private static long |
num2quad19(IRubyObject arg) |
private static double |
obj2dbl(Ruby runtime,
IRubyObject o) |
private static double |
obj2dbl19(Ruby runtime,
IRubyObject o) |
private static float |
obj2flt(Ruby runtime,
IRubyObject o) |
private static float |
obj2flt19(Ruby runtime,
IRubyObject o) |
static RubyString |
pack(Ruby runtime,
RubyArray list,
org.jruby.util.ByteList formatString)
Same as pack(Ruby, RubyArray, ByteList) but defaults tainting of output to false.
|
static RubyString |
pack(Ruby runtime,
RubyArray list,
org.jruby.util.ByteList formatString,
boolean taint)
pack_pack
Template characters for Array#pack Directive Meaning
Packs the contents of arr into a binary sequence according to the directives in
aTemplateString (see preceding table).
|
static RubyString |
pack19(ThreadContext context,
Ruby runtime,
RubyArray list,
RubyString formatString) |
private static RubyString |
packCommon(Ruby runtime,
RubyArray list,
org.jruby.util.ByteList formatString,
boolean tainted,
Pack.ConverterExecutor executor) |
static org.jruby.util.ByteList |
packInt_i(org.jruby.util.ByteList result,
int s) |
private static org.jruby.util.ByteList |
qpencode(org.jruby.util.ByteList io2Append,
org.jruby.util.ByteList i2Encode,
int iLength)
encodes a String with the Quoted printable, MIME encoding (see RFC2045).
|
private static int |
safeGet(java.nio.ByteBuffer encode) |
private static int |
safeGetIgnoreNull(java.nio.ByteBuffer encode) |
private static org.jruby.util.ByteList |
shrink(org.jruby.util.ByteList i2Shrink,
int iLength)
shrinks a stringbuffer.
|
private static double |
str2dbl(Ruby runtime,
RubyString o) |
static RubyArray |
unpack(Ruby runtime,
org.jruby.util.ByteList encodedString,
org.jruby.util.ByteList formatString)
Decodes str (which may contain binary data) according to the format
string, returning an array of each value extracted.
|
static int |
unpackInt_i(java.nio.ByteBuffer enc) |
private static int |
utf8Decode(java.nio.ByteBuffer buffer)
utf8_to_uv
|
static int |
utf8Decode(Ruby runtime,
byte[] to,
int p,
int code)
rb_uv_to_utf8
|
private static final byte[] sSp10
private static final byte[] sNil10
private static final int IS_STAR
private static final org.jcodings.specific.ASCIIEncoding ASCII
private static final org.jcodings.specific.USASCIIEncoding USASCII
private static final org.jcodings.specific.UTF8Encoding UTF8
private static final java.lang.String NATIVE_CODES
private static final java.lang.String MAPPED_CODES
private static final char BE
private static final char LE
private static final java.lang.String ENDIANESS_CODES
private static final java.lang.String UNPACK_IGNORE_NULL_CODES
private static final java.lang.String PACK_IGNORE_NULL_CODES
private static final java.lang.String PACK_IGNORE_NULL_CODES_WITH_MODIFIERS
private static final java.lang.String sTooFew
private static final byte[] hex_table
private static final byte[] uu_table
private static final byte[] b64_table
private static final byte[] sHexDigits
private static final int[] b64_xtable
private static final Pack.Converter[] converters
private static final java.math.BigInteger QUAD_MIN
private static final java.math.BigInteger QUAD_MAX
private static final long[] utf8_limits
private static long num2quad(IRubyObject arg)
private static long num2quad19(IRubyObject arg)
private static float obj2flt(Ruby runtime, IRubyObject o)
private static float obj2flt19(Ruby runtime, IRubyObject o)
private static double str2dbl(Ruby runtime, RubyString o)
private static double obj2dbl(Ruby runtime, IRubyObject o)
private static double obj2dbl19(Ruby runtime, IRubyObject o)
public static int unpackInt_i(java.nio.ByteBuffer enc)
public static org.jruby.util.ByteList packInt_i(org.jruby.util.ByteList result,
int s)
private static org.jruby.util.ByteList encodes(Ruby runtime, org.jruby.util.ByteList io2Append, byte[] charsToEncode, int startIndex, int length, int charCount, byte encodingType, boolean tailLf)
io2Append - The StringBuffer which should receive the resulti2Encode - The String to encodeiLength - The max number of characters to encodeiType - the type of encoding required (this is the same type as used by the pack method)tailLf - true if the traililng "\n" is neededprivate static org.jruby.util.ByteList qpencode(org.jruby.util.ByteList io2Append,
org.jruby.util.ByteList i2Encode,
int iLength)
io2Append - The StringBuffer which should receive the resulti2Encode - The String to encodeiLength - The max number of characters to encodepublic static RubyArray unpack(Ruby runtime, org.jruby.util.ByteList encodedString, org.jruby.util.ByteList formatString)
*'') will use up all
remaining elements. sSiIlL may each be followed by an underscore (``_'') to use the underlying platform's native size for the specified type; otherwise, it uses a platform-independent consistent size.
Directives for
String#unpack
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public static int utf8Decode(Ruby runtime, byte[] to, int p, int code)
private static int utf8Decode(java.nio.ByteBuffer buffer)
private static int safeGet(java.nio.ByteBuffer encode)
private static int safeGetIgnoreNull(java.nio.ByteBuffer encode)
public static void decode(Ruby runtime, java.nio.ByteBuffer encode, int occurrences, RubyArray result, Pack.Converter converter)
public static int encode(Ruby runtime, int occurrences, org.jruby.util.ByteList result, RubyArray list, int index, Pack.ConverterExecutor converter)
private static Pack.ConverterExecutor executor18()
private static Pack.ConverterExecutor executor19()
private static final org.jruby.util.ByteList shrink(org.jruby.util.ByteList i2Shrink,
int iLength)
i2Shrink - the stringbufferiLength - how much to shrinkprivate static final org.jruby.util.ByteList grow(org.jruby.util.ByteList i2Grow,
byte[] iPads,
int iLength)
i2Grow - the buffer to growiPads - the string used as paddingiLength - how much padding is neededpublic static RubyString pack(Ruby runtime, RubyArray list, org.jruby.util.ByteList formatString, boolean taint)
| Directive | Meaning | |||||||
| @ | Moves to absolute position | |||||||
| A | ASCII string (space padded, count is width) | |||||||
| a | ASCII string (null padded, count is width) | |||||||
| B | Bit string (descending bit order) | |||||||
| b | Bit string (ascending bit order) | |||||||
| C | Unsigned char | |||||||
| c | Char | |||||||
| d | Double-precision float, native format | |||||||
| E | Double-precision float, little-endian byte order | |||||||
| e | Single-precision float, little-endian byte order | |||||||
| f | Single-precision float, native format | |||||||
| G | Double-precision float, network (big-endian) byte order | |||||||
| g | Single-precision float, network (big-endian) byte order | |||||||
| H | Hex string (high nibble first) | |||||||
| h | Hex string (low nibble first) | |||||||
| I | Unsigned integer | |||||||
| i | Integer | |||||||
| L | Unsigned long | |||||||
| l | Long | |||||||
| M | Quoted printable, MIME encoding (see RFC2045) | |||||||
| m | Base64 encoded string | |||||||
| N | Long, network (big-endian) byte order | |||||||
| n | Short, network (big-endian) byte-order | |||||||
| P | Pointer to a structure (fixed-length string) | |||||||
| p | Pointer to a null-terminated string | |||||||
| Q | Unsigned 64-bit number | |||||||
| q | 64-bit number | |||||||
| S | Unsigned short | |||||||
| s | Short | |||||||
| U | UTF-8 | |||||||
| u | UU-encoded string | |||||||
| V | Long, little-endian byte order | |||||||
| v | Short, little-endian byte order | |||||||
| X | Back up a byte | |||||||
| x | Null byte | |||||||
| Z | Same as ``A'' | |||||||
public static RubyString pack(Ruby runtime, RubyArray list, org.jruby.util.ByteList formatString)
public static RubyString pack19(ThreadContext context, Ruby runtime, RubyArray list, RubyString formatString)
private static RubyString packCommon(Ruby runtime, RubyArray list, org.jruby.util.ByteList formatString, boolean tainted, Pack.ConverterExecutor executor)
private static int decodeIntLittleEndian(java.nio.ByteBuffer encode)
encode - string to get int fromprivate static int decodeIntBigEndian(java.nio.ByteBuffer encode)
encode - string to get int fromprivate static long decodeIntUnsignedBigEndian(java.nio.ByteBuffer encode)
encode - string to get int fromprivate static long decodeIntUnsignedLittleEndian(java.nio.ByteBuffer encode)
encode - the encoded stringprivate static void encodeIntLittleEndian(org.jruby.util.ByteList result,
int s)
result - to be appended tos - the integer to encodeprivate static void encodeIntBigEndian(org.jruby.util.ByteList result,
int s)
result - to be appended tos - the integer to encodeprivate static long decodeLongBigEndian(java.nio.ByteBuffer encode)
encode - string to get int fromprivate static long decodeLongLittleEndian(java.nio.ByteBuffer encode)
encode - string to get int fromprivate static void encodeLongLittleEndian(org.jruby.util.ByteList result,
long l)
result - to pack long intol - is the long to encodeprivate static void encodeLongBigEndian(org.jruby.util.ByteList result,
long l)
result - to pack long intol - is the long to encodeprivate static double decodeDoubleLittleEndian(java.nio.ByteBuffer encode)
encode - string to get int fromprivate static double decodeDoubleBigEndian(java.nio.ByteBuffer encode)
encode - string to get int fromprivate static void encodeDoubleLittleEndian(org.jruby.util.ByteList result,
double d)
result - to pack double intod - is the double to encodeprivate static void encodeDoubleBigEndian(org.jruby.util.ByteList result,
double d)
result - to pack double intod - is the double to encodeprivate static float decodeFloatBigEndian(java.nio.ByteBuffer encode)
encode - string to get int fromprivate static float decodeFloatLittleEndian(java.nio.ByteBuffer encode)
encode - string to get int fromprivate static void encodeFloatLittleEndian(org.jruby.util.ByteList result,
float f)
result - to pack float intof - is the float to encodeprivate static void encodeFloatBigEndian(org.jruby.util.ByteList result,
float f)
result - to pack float intof - is the float to encodeprivate static int decodeShortUnsignedLittleEndian(java.nio.ByteBuffer encode)
encode - string to get int fromprivate static int decodeShortUnsignedBigEndian(java.nio.ByteBuffer encode)
encode - string to get int fromprivate static int decodeShortLittleEndian(java.nio.ByteBuffer encode)
encode - string to get int fromprivate static short decodeShortBigEndian(java.nio.ByteBuffer encode)
encode - string to get int fromprivate static void encodeShortLittleEndian(org.jruby.util.ByteList result,
int s)
result - to be appended tos - the short to encodeprivate static void encodeShortBigEndian(org.jruby.util.ByteList result,
int s)
result - to be appended tos - the short to encode