com.android.dex.util.ByteInput Java Examples
The following examples show how to use
com.android.dex.util.ByteInput.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Leb128.java From buck with Apache License 2.0 | 6 votes |
/** * Reads an unsigned integer from {@code in}. */ public static int readUnsignedLeb128(ByteInput in) { int result = 0; int cur; int count = 0; do { cur = in.readByte() & 0xff; result |= (cur & 0x7f) << (count * 7); count++; } while (((cur & 0x80) == 0x80) && count < 5); if ((cur & 0x80) == 0x80) { throw new DexException("invalid LEB128 sequence"); } return result; }
Example #2
Source File: Leb128.java From buck with Apache License 2.0 | 6 votes |
/** * Reads an signed integer from {@code in}. */ public static int readSignedLeb128(ByteInput in) { int result = 0; int cur; int count = 0; int signBits = -1; do { cur = in.readByte() & 0xff; result |= (cur & 0x7f) << (count * 7); signBits <<= 7; count++; } while (((cur & 0x80) == 0x80) && count < 5); if ((cur & 0x80) == 0x80) { throw new DexException("invalid LEB128 sequence"); } // Sign extend if appropriate if (((signBits >> 1) & result) != 0 ) { result |= signBits; } return result; }
Example #3
Source File: Leb128.java From Box with Apache License 2.0 | 6 votes |
/** * Reads an signed integer from {@code in}. */ public static int readSignedLeb128(ByteInput in) { int result = 0; int cur; int count = 0; int signBits = -1; do { cur = in.readByte() & 0xff; result |= (cur & 0x7f) << (count * 7); signBits <<= 7; count++; } while (((cur & 0x80) == 0x80) && count < 5); if ((cur & 0x80) == 0x80) { throw new DexException("invalid LEB128 sequence"); } // Sign extend if appropriate if (((signBits >> 1) & result) != 0 ) { result |= signBits; } return result; }
Example #4
Source File: Leb128.java From Box with Apache License 2.0 | 6 votes |
/** * Reads an unsigned integer from {@code in}. */ public static int readUnsignedLeb128(ByteInput in) { int result = 0; int cur; int count = 0; do { cur = in.readByte() & 0xff; result |= (cur & 0x7f) << (count * 7); count++; } while (((cur & 0x80) == 0x80) && count < 5); if ((cur & 0x80) == 0x80) { throw new DexException("invalid LEB128 sequence"); } return result; }
Example #5
Source File: Leb128.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** * Reads an signed integer from {@code in}. */ public static int readSignedLeb128(ByteInput in) { int result = 0; int cur; int count = 0; int signBits = -1; do { cur = in.readByte() & 0xff; result |= (cur & 0x7f) << (count * 7); signBits <<= 7; count++; } while (((cur & 0x80) == 0x80) && count < 5); if ((cur & 0x80) == 0x80) { throw new DexException("invalid LEB128 sequence"); } // Sign extend if appropriate if (((signBits >> 1) & result) != 0 ) { result |= signBits; } return result; }
Example #6
Source File: Leb128.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** * Reads an unsigned integer from {@code in}. */ public static int readUnsignedLeb128(ByteInput in) { int result = 0; int cur; int count = 0; do { cur = in.readByte() & 0xff; result |= (cur & 0x7f) << (count * 7); count++; } while (((cur & 0x80) == 0x80) && count < 5); if ((cur & 0x80) == 0x80) { throw new DexException("invalid LEB128 sequence"); } return result; }
Example #7
Source File: Leb128.java From aapt with Apache License 2.0 | 6 votes |
/** * Reads an unsigned integer from {@code in}. */ public static int readUnsignedLeb128(ByteInput in) { int result = 0; int cur; int count = 0; do { cur = in.readByte() & 0xff; result |= (cur & 0x7f) << (count * 7); count++; } while (((cur & 0x80) == 0x80) && count < 5); if ((cur & 0x80) == 0x80) { throw new DexException("invalid LEB128 sequence"); } return result; }
Example #8
Source File: Leb128.java From aapt with Apache License 2.0 | 6 votes |
/** * Reads an signed integer from {@code in}. */ public static int readSignedLeb128(ByteInput in) { int result = 0; int cur; int count = 0; int signBits = -1; do { cur = in.readByte() & 0xff; result |= (cur & 0x7f) << (count * 7); signBits <<= 7; count++; } while (((cur & 0x80) == 0x80) && count < 5); if ((cur & 0x80) == 0x80) { throw new DexException("invalid LEB128 sequence"); } // Sign extend if appropriate if (((signBits >> 1) & result) != 0 ) { result |= signBits; } return result; }
Example #9
Source File: Leb128.java From Box with Apache License 2.0 | 6 votes |
/** * Reads an unsigned integer from {@code in}. */ public static int readUnsignedLeb128(ByteInput in) { int result = 0; int cur; int count = 0; do { cur = in.readByte() & 0xff; result |= (cur & 0x7f) << (count * 7); count++; } while (((cur & 0x80) == 0x80) && count < 5); if ((cur & 0x80) == 0x80) { throw new DexException("invalid LEB128 sequence"); } return result; }
Example #10
Source File: Leb128.java From Box with Apache License 2.0 | 6 votes |
/** * Reads an signed integer from {@code in}. */ public static int readSignedLeb128(ByteInput in) { int result = 0; int cur; int count = 0; int signBits = -1; do { cur = in.readByte() & 0xff; result |= (cur & 0x7f) << (count * 7); signBits <<= 7; count++; } while (((cur & 0x80) == 0x80) && count < 5); if ((cur & 0x80) == 0x80) { throw new DexException("invalid LEB128 sequence"); } // Sign extend if appropriate if (((signBits >> 1) & result) != 0 ) { result |= signBits; } return result; }
Example #11
Source File: EncodedValueCodec.java From J2ME-Loader with Apache License 2.0 | 5 votes |
/** * Read a signed long. * * @param zwidth byte count minus one */ public static long readSignedLong(ByteInput in, int zwidth) { long result = 0; for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xffL) << 56); } result >>= (7 - zwidth) * 8; return result; }
Example #12
Source File: Mutf8Test.java From buck with Apache License 2.0 | 5 votes |
public void testDecode() throws IOException { ByteInput in = new ByteArrayByteInput( new byte[] { 'A', 'B', 'C', (byte) 0xc0, (byte) 0x80, 0, 'E' }); assertEquals('A', in.readByte()); assertEquals("BC\u0000", Mutf8.decode(in, new char[3])); assertEquals('E', in.readByte()); }
Example #13
Source File: EncodedValueCodec.java From J2ME-Loader with Apache License 2.0 | 5 votes |
/** * Read an unsigned long. * * @param zwidth byte count minus one * @param fillOnRight true to zero fill on the right; false on the left */ public static long readUnsignedLong(ByteInput in, int zwidth, boolean fillOnRight) { long result = 0; if (!fillOnRight) { for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xffL) << 56); } result >>>= (7 - zwidth) * 8; } else { for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xffL) << 56); } } return result; }
Example #14
Source File: EncodedValueCodec.java From aapt with Apache License 2.0 | 5 votes |
/** * Read a signed integer. * * @param zwidth byte count minus one */ public static int readSignedInt(ByteInput in, int zwidth) { int result = 0; for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xff) << 24); } result >>= (3 - zwidth) * 8; return result; }
Example #15
Source File: EncodedValueCodec.java From aapt with Apache License 2.0 | 5 votes |
/** * Read an unsigned integer. * * @param zwidth byte count minus one * @param fillOnRight true to zero fill on the right; false on the left */ public static int readUnsignedInt(ByteInput in, int zwidth, boolean fillOnRight) { int result = 0; if (!fillOnRight) { for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xff) << 24); } result >>>= (3 - zwidth) * 8; } else { for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xff) << 24); } } return result; }
Example #16
Source File: EncodedValueCodec.java From aapt with Apache License 2.0 | 5 votes |
/** * Read a signed long. * * @param zwidth byte count minus one */ public static long readSignedLong(ByteInput in, int zwidth) { long result = 0; for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xffL) << 56); } result >>= (7 - zwidth) * 8; return result; }
Example #17
Source File: EncodedValueCodec.java From aapt with Apache License 2.0 | 5 votes |
/** * Read an unsigned long. * * @param zwidth byte count minus one * @param fillOnRight true to zero fill on the right; false on the left */ public static long readUnsignedLong(ByteInput in, int zwidth, boolean fillOnRight) { long result = 0; if (!fillOnRight) { for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xffL) << 56); } result >>>= (7 - zwidth) * 8; } else { for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xffL) << 56); } } return result; }
Example #18
Source File: EncodedValueCodec.java From buck with Apache License 2.0 | 5 votes |
/** * Read a signed integer. * * @param zwidth byte count minus one */ public static int readSignedInt(ByteInput in, int zwidth) { int result = 0; for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xff) << 24); } result >>= (3 - zwidth) * 8; return result; }
Example #19
Source File: EncodedValueCodec.java From buck with Apache License 2.0 | 5 votes |
/** * Read an unsigned integer. * * @param zwidth byte count minus one * @param fillOnRight true to zero fill on the right; false on the left */ public static int readUnsignedInt(ByteInput in, int zwidth, boolean fillOnRight) { int result = 0; if (!fillOnRight) { for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xff) << 24); } result >>>= (3 - zwidth) * 8; } else { for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xff) << 24); } } return result; }
Example #20
Source File: EncodedValueCodec.java From buck with Apache License 2.0 | 5 votes |
/** * Read a signed long. * * @param zwidth byte count minus one */ public static long readSignedLong(ByteInput in, int zwidth) { long result = 0; for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xffL) << 56); } result >>= (7 - zwidth) * 8; return result; }
Example #21
Source File: EncodedValueCodec.java From buck with Apache License 2.0 | 5 votes |
/** * Read an unsigned long. * * @param zwidth byte count minus one * @param fillOnRight true to zero fill on the right; false on the left */ public static long readUnsignedLong(ByteInput in, int zwidth, boolean fillOnRight) { long result = 0; if (!fillOnRight) { for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xffL) << 56); } result >>>= (7 - zwidth) * 8; } else { for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xffL) << 56); } } return result; }
Example #22
Source File: EncodedValueCodec.java From Box with Apache License 2.0 | 5 votes |
/** * Read a signed integer. * * @param zwidth byte count minus one */ public static int readSignedInt(ByteInput in, int zwidth) { int result = 0; for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xff) << 24); } result >>= (3 - zwidth) * 8; return result; }
Example #23
Source File: EncodedValueCodec.java From J2ME-Loader with Apache License 2.0 | 5 votes |
/** * Read a signed integer. * * @param zwidth byte count minus one */ public static int readSignedInt(ByteInput in, int zwidth) { int result = 0; for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xff) << 24); } result >>= (3 - zwidth) * 8; return result; }
Example #24
Source File: EncodedValueCodec.java From Box with Apache License 2.0 | 5 votes |
/** * Read an unsigned integer. * * @param zwidth byte count minus one * @param fillOnRight true to zero fill on the right; false on the left */ public static int readUnsignedInt(ByteInput in, int zwidth, boolean fillOnRight) { int result = 0; if (!fillOnRight) { for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xff) << 24); } result >>>= (3 - zwidth) * 8; } else { for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xff) << 24); } } return result; }
Example #25
Source File: EncodedValueCodec.java From Box with Apache License 2.0 | 5 votes |
/** * Read a signed long. * * @param zwidth byte count minus one */ public static long readSignedLong(ByteInput in, int zwidth) { long result = 0; for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xffL) << 56); } result >>= (7 - zwidth) * 8; return result; }
Example #26
Source File: EncodedValueCodec.java From Box with Apache License 2.0 | 5 votes |
/** * Read an unsigned long. * * @param zwidth byte count minus one * @param fillOnRight true to zero fill on the right; false on the left */ public static long readUnsignedLong(ByteInput in, int zwidth, boolean fillOnRight) { long result = 0; if (!fillOnRight) { for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xffL) << 56); } result >>>= (7 - zwidth) * 8; } else { for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xffL) << 56); } } return result; }
Example #27
Source File: EncodedValueCodec.java From Box with Apache License 2.0 | 5 votes |
/** * Read a signed integer. * * @param zwidth byte count minus one */ public static int readSignedInt(ByteInput in, int zwidth) { int result = 0; for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xff) << 24); } result >>= (3 - zwidth) * 8; return result; }
Example #28
Source File: EncodedValueCodec.java From Box with Apache License 2.0 | 5 votes |
/** * Read an unsigned integer. * * @param zwidth byte count minus one * @param fillOnRight true to zero fill on the right; false on the left */ public static int readUnsignedInt(ByteInput in, int zwidth, boolean fillOnRight) { int result = 0; if (!fillOnRight) { for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xff) << 24); } result >>>= (3 - zwidth) * 8; } else { for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xff) << 24); } } return result; }
Example #29
Source File: EncodedValueCodec.java From Box with Apache License 2.0 | 5 votes |
/** * Read a signed long. * * @param zwidth byte count minus one */ public static long readSignedLong(ByteInput in, int zwidth) { long result = 0; for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xffL) << 56); } result >>= (7 - zwidth) * 8; return result; }
Example #30
Source File: EncodedValueCodec.java From Box with Apache License 2.0 | 5 votes |
/** * Read an unsigned long. * * @param zwidth byte count minus one * @param fillOnRight true to zero fill on the right; false on the left */ public static long readUnsignedLong(ByteInput in, int zwidth, boolean fillOnRight) { long result = 0; if (!fillOnRight) { for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xffL) << 56); } result >>>= (7 - zwidth) * 8; } else { for (int i = zwidth; i >= 0; i--) { result = (result >>> 8) | ((in.readByte() & 0xffL) << 56); } } return result; }