Java Code Examples for com.google.common.primitives.Chars#fromByteArray()

The following examples show how to use com.google.common.primitives.Chars#fromByteArray() . 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: BmdReader.java    From hprof-tools with MIT License 6 votes vote down vote up
private BmdConstantField readConstantField() throws IOException {
    int index = readInt32();
    BmdBasicType type = BmdBasicType.fromInt(readInt32());
    log("Field: " + type);
    switch (type) {
        case OBJECT:
        case INT:
            return new BmdConstantField(index, type, readInt32());
        case BOOLEAN:
            return new BmdConstantField(index, type, readBool());
        case BYTE:
            return new BmdConstantField(index, type, readRawByte());
        case CHAR:
            return new BmdConstantField(index, type, Chars.fromByteArray(readRawBytes(2)));
        case FLOAT:
            return new BmdConstantField(index, type, readFloat());
        case DOUBLE:
            return new BmdConstantField(index, type, readDouble());
        case LONG:
            return new BmdConstantField(index, type, readInt64());
        case SHORT:
            return new BmdConstantField(index, type, (short) readInt32());
        default:
            throw new IllegalArgumentException("Invalid field type: " + type);
    }
}
 
Example 2
Source File: MultiQpidByteBuffer.java    From qpid-broker-j with Apache License 2.0 5 votes vote down vote up
@Override
public final char getChar()
{
    byte[] value = new byte[2];
    get(value, 0, value.length);
    return Chars.fromByteArray(value);
}
 
Example 3
Source File: BmdReader.java    From hprof-tools with MIT License 5 votes vote down vote up
private BmdStaticField readStaticField() throws IOException {
    int nameId = readInt32();
    BmdBasicType type = BmdBasicType.fromInt(readInt32());
    log("Field: " + type);
    Object value;
    switch (type) {
        case OBJECT:
        case INT:
            value = readInt32();
            break;
        case BOOLEAN:
            value = readBool();
            break;
        case BYTE:
            value = readRawByte();
            break;
        case CHAR:
            value = Chars.fromByteArray(readRawBytes(2));
            break;
        case FLOAT:
            value = readFloat();
            break;
        case DOUBLE:
            value = readDouble();
            break;
        case LONG:
            value = readInt64();
            break;
        case SHORT:
            value = (short) readInt32();
            break;
        default:
            throw new IllegalArgumentException("Invalid field type: " + type);
    }
    return new BmdStaticField(nameId, type, value);
}
 
Example 4
Source File: MultiQpidByteBuffer.java    From qpid-broker-j with Apache License 2.0 4 votes vote down vote up
@Override
public char getChar(final int index)
{
    final byte[] byteArray = getByteArray(index, 2);
    return Chars.fromByteArray(byteArray);
}