com.android.dex.EncodedValueCodec Java Examples

The following examples show how to use com.android.dex.EncodedValueCodec. 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: IndexMap.java    From Box with Apache License 2.0 4 votes vote down vote up
public void transform(EncodedValueReader reader) {
    // TODO: extract this into a helper class, EncodedValueWriter
    switch (reader.peek()) {
    case ENCODED_BYTE:
        EncodedValueCodec.writeSignedIntegralValue(out, ENCODED_BYTE, reader.readByte());
        break;
    case ENCODED_SHORT:
        EncodedValueCodec.writeSignedIntegralValue(out, ENCODED_SHORT, reader.readShort());
        break;
    case ENCODED_INT:
        EncodedValueCodec.writeSignedIntegralValue(out, ENCODED_INT, reader.readInt());
        break;
    case ENCODED_LONG:
        EncodedValueCodec.writeSignedIntegralValue(out, ENCODED_LONG, reader.readLong());
        break;
    case ENCODED_CHAR:
        EncodedValueCodec.writeUnsignedIntegralValue(out, ENCODED_CHAR, reader.readChar());
        break;
    case ENCODED_FLOAT:
        // Shift value left 32 so that right-zero-extension works.
        long longBits = ((long) Float.floatToIntBits(reader.readFloat())) << 32;
        EncodedValueCodec.writeRightZeroExtendedValue(out, ENCODED_FLOAT, longBits);
        break;
    case ENCODED_DOUBLE:
        EncodedValueCodec.writeRightZeroExtendedValue(
                out, ENCODED_DOUBLE, Double.doubleToLongBits(reader.readDouble()));
        break;
    case ENCODED_METHOD_TYPE:
        EncodedValueCodec.writeUnsignedIntegralValue(
                out, ENCODED_METHOD_TYPE, adjustProto(reader.readMethodType()));
        break;
    case ENCODED_METHOD_HANDLE:
        EncodedValueCodec.writeUnsignedIntegralValue(
                out,
                ENCODED_METHOD_HANDLE,
                adjustMethodHandle(reader.readMethodHandle()));
        break;
    case ENCODED_STRING:
        EncodedValueCodec.writeUnsignedIntegralValue(
                out, ENCODED_STRING, adjustString(reader.readString()));
        break;
    case ENCODED_TYPE:
        EncodedValueCodec.writeUnsignedIntegralValue(
                out, ENCODED_TYPE, adjustType(reader.readType()));
        break;
    case ENCODED_FIELD:
        EncodedValueCodec.writeUnsignedIntegralValue(
                out, ENCODED_FIELD, adjustField(reader.readField()));
        break;
    case ENCODED_ENUM:
        EncodedValueCodec.writeUnsignedIntegralValue(
                out, ENCODED_ENUM, adjustField(reader.readEnum()));
        break;
    case ENCODED_METHOD:
        EncodedValueCodec.writeUnsignedIntegralValue(
                out, ENCODED_METHOD, adjustMethod(reader.readMethod()));
        break;
    case ENCODED_ARRAY:
        writeTypeAndArg(ENCODED_ARRAY, 0);
        transformArray(reader);
        break;
    case ENCODED_ANNOTATION:
        writeTypeAndArg(ENCODED_ANNOTATION, 0);
        transformAnnotation(reader);
        break;
    case ENCODED_NULL:
        reader.readNull();
        writeTypeAndArg(ENCODED_NULL, 0);
        break;
    case ENCODED_BOOLEAN:
        boolean value = reader.readBoolean();
        writeTypeAndArg(ENCODED_BOOLEAN, value ? 1 : 0);
        break;
    default:
        throw new DexException("Unexpected type: " + Integer.toHexString(reader.peek()));
    }
}
 
Example #2
Source File: IndexMap.java    From Box with Apache License 2.0 4 votes vote down vote up
public void transform(EncodedValueReader reader) {
    // TODO: extract this into a helper class, EncodedValueWriter
    switch (reader.peek()) {
    case ENCODED_BYTE:
        EncodedValueCodec.writeSignedIntegralValue(out, ENCODED_BYTE, reader.readByte());
        break;
    case ENCODED_SHORT:
        EncodedValueCodec.writeSignedIntegralValue(out, ENCODED_SHORT, reader.readShort());
        break;
    case ENCODED_INT:
        EncodedValueCodec.writeSignedIntegralValue(out, ENCODED_INT, reader.readInt());
        break;
    case ENCODED_LONG:
        EncodedValueCodec.writeSignedIntegralValue(out, ENCODED_LONG, reader.readLong());
        break;
    case ENCODED_CHAR:
        EncodedValueCodec.writeUnsignedIntegralValue(out, ENCODED_CHAR, reader.readChar());
        break;
    case ENCODED_FLOAT:
        // Shift value left 32 so that right-zero-extension works.
        long longBits = ((long) Float.floatToIntBits(reader.readFloat())) << 32;
        EncodedValueCodec.writeRightZeroExtendedValue(out, ENCODED_FLOAT, longBits);
        break;
    case ENCODED_DOUBLE:
        EncodedValueCodec.writeRightZeroExtendedValue(
                out, ENCODED_DOUBLE, Double.doubleToLongBits(reader.readDouble()));
        break;
    case ENCODED_METHOD_TYPE:
        EncodedValueCodec.writeUnsignedIntegralValue(
                out, ENCODED_METHOD_TYPE, adjustProto(reader.readMethodType()));
        break;
    case ENCODED_METHOD_HANDLE:
        EncodedValueCodec.writeUnsignedIntegralValue(
                out,
                ENCODED_METHOD_HANDLE,
                adjustMethodHandle(reader.readMethodHandle()));
        break;
    case ENCODED_STRING:
        EncodedValueCodec.writeUnsignedIntegralValue(
                out, ENCODED_STRING, adjustString(reader.readString()));
        break;
    case ENCODED_TYPE:
        EncodedValueCodec.writeUnsignedIntegralValue(
                out, ENCODED_TYPE, adjustType(reader.readType()));
        break;
    case ENCODED_FIELD:
        EncodedValueCodec.writeUnsignedIntegralValue(
                out, ENCODED_FIELD, adjustField(reader.readField()));
        break;
    case ENCODED_ENUM:
        EncodedValueCodec.writeUnsignedIntegralValue(
                out, ENCODED_ENUM, adjustField(reader.readEnum()));
        break;
    case ENCODED_METHOD:
        EncodedValueCodec.writeUnsignedIntegralValue(
                out, ENCODED_METHOD, adjustMethod(reader.readMethod()));
        break;
    case ENCODED_ARRAY:
        writeTypeAndArg(ENCODED_ARRAY, 0);
        transformArray(reader);
        break;
    case ENCODED_ANNOTATION:
        writeTypeAndArg(ENCODED_ANNOTATION, 0);
        transformAnnotation(reader);
        break;
    case ENCODED_NULL:
        reader.readNull();
        writeTypeAndArg(ENCODED_NULL, 0);
        break;
    case ENCODED_BOOLEAN:
        boolean value = reader.readBoolean();
        writeTypeAndArg(ENCODED_BOOLEAN, value ? 1 : 0);
        break;
    default:
        throw new DexException("Unexpected type: " + Integer.toHexString(reader.peek()));
    }
}
 
Example #3
Source File: IndexMap.java    From buck with Apache License 2.0 4 votes vote down vote up
public void transform(EncodedValueReader reader) {
    // TODO: extract this into a helper class, EncodedValueWriter
    switch (reader.peek()) {
    case ENCODED_BYTE:
        EncodedValueCodec.writeSignedIntegralValue(out, ENCODED_BYTE, reader.readByte());
        break;
    case ENCODED_SHORT:
        EncodedValueCodec.writeSignedIntegralValue(out, ENCODED_SHORT, reader.readShort());
        break;
    case ENCODED_INT:
        EncodedValueCodec.writeSignedIntegralValue(out, ENCODED_INT, reader.readInt());
        break;
    case ENCODED_LONG:
        EncodedValueCodec.writeSignedIntegralValue(out, ENCODED_LONG, reader.readLong());
        break;
    case ENCODED_CHAR:
        EncodedValueCodec.writeUnsignedIntegralValue(out, ENCODED_CHAR, reader.readChar());
        break;
    case ENCODED_FLOAT:
        // Shift value left 32 so that right-zero-extension works.
        long longBits = ((long) Float.floatToIntBits(reader.readFloat())) << 32;
        EncodedValueCodec.writeRightZeroExtendedValue(out, ENCODED_FLOAT, longBits);
        break;
    case ENCODED_DOUBLE:
        EncodedValueCodec.writeRightZeroExtendedValue(
                out, ENCODED_DOUBLE, Double.doubleToLongBits(reader.readDouble()));
        break;
    case ENCODED_STRING:
        EncodedValueCodec.writeUnsignedIntegralValue(
                out, ENCODED_STRING, adjustString(reader.readString()));
        break;
    case ENCODED_TYPE:
        EncodedValueCodec.writeUnsignedIntegralValue(
                out, ENCODED_TYPE, adjustType(reader.readType()));
        break;
    case ENCODED_FIELD:
        EncodedValueCodec.writeUnsignedIntegralValue(
                out, ENCODED_FIELD, adjustField(reader.readField()));
        break;
    case ENCODED_ENUM:
        EncodedValueCodec.writeUnsignedIntegralValue(
                out, ENCODED_ENUM, adjustField(reader.readEnum()));
        break;
    case ENCODED_METHOD:
        EncodedValueCodec.writeUnsignedIntegralValue(
                out, ENCODED_METHOD, adjustMethod(reader.readMethod()));
        break;
    case ENCODED_ARRAY:
        writeTypeAndArg(ENCODED_ARRAY, 0);
        transformArray(reader);
        break;
    case ENCODED_ANNOTATION:
        writeTypeAndArg(ENCODED_ANNOTATION, 0);
        transformAnnotation(reader);
        break;
    case ENCODED_NULL:
        reader.readNull();
        writeTypeAndArg(ENCODED_NULL, 0);
        break;
    case ENCODED_BOOLEAN:
        boolean value = reader.readBoolean();
        writeTypeAndArg(ENCODED_BOOLEAN, value ? 1 : 0);
        break;
    default:
        throw new DexException("Unexpected type: " + Integer.toHexString(reader.peek()));
    }
}