Java Code Examples for com.google.common.io.ByteArrayDataInput#readByte()
The following examples show how to use
com.google.common.io.ByteArrayDataInput#readByte() .
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: SettingMapFactory.java From helper with MIT License | 6 votes |
/** * Decodes the given byte array to a {@link SettingMap}. * * <p>Operates on the reverse of {@link SettingMap#encode()}.</p> * * @param buf the byte array * @return the decoded map */ public SettingMap<S, V> decode(byte[] buf) { if (buf.length == 0) { return newMap(); } ByteArrayDataInput in = ByteStreams.newDataInput(buf); int n = Byte.toUnsignedInt(in.readByte()); byte[] states = Arrays.copyOf(this.defaultStates, this.defaultStates.length); for (int i = 0; i < n; i++) { int settingOrdinal = Byte.toUnsignedInt(in.readByte()); byte stateByte = in.readByte(); states[settingOrdinal] = stateByte; } return new SettingMap<>(this, states); }
Example 2
Source File: ConstantPoolReader.java From turbine with Apache License 2.0 | 6 votes |
/** * Reads a constant value at the given index, which must be one of CONSTANT_String_info, * CONSTANT_Integer_info, CONSTANT_Float_info, CONSTANT_Long_info, or CONSTANT_Double_info. */ Const.Value constant(int index) { ByteArrayDataInput reader = byteReader.seek(constantPool[index - 1]); byte tag = reader.readByte(); switch (tag) { case CONSTANT_LONG: return new Const.LongValue(reader.readLong()); case CONSTANT_FLOAT: return new Const.FloatValue(reader.readFloat()); case CONSTANT_DOUBLE: return new Const.DoubleValue(reader.readDouble()); case CONSTANT_INTEGER: return new Const.IntValue(reader.readInt()); case CONSTANT_STRING: return new Const.StringValue(utf8(reader.readUnsignedShort())); case CONSTANT_UTF8: return new Const.StringValue(reader.readUTF()); default: throw new AssertionError(String.format("bad tag: %x", tag)); } }
Example 3
Source File: ConstantPoolReader.java From turbine with Apache License 2.0 | 5 votes |
/** Reads the CONSTANT_Class_info at the given index. */ public String classInfo(int index) { ByteArrayDataInput reader = byteReader.seek(constantPool[index - 1]); byte tag = reader.readByte(); if (tag != CONSTANT_CLASS) { throw new AssertionError(String.format("bad tag: %x", tag)); } int nameIndex = reader.readUnsignedShort(); return utf8(nameIndex); }
Example 4
Source File: ConstantPoolReader.java From turbine with Apache License 2.0 | 5 votes |
/** Reads the CONSTANT_Utf8_info at the given index. */ public String utf8(int index) { ByteArrayDataInput reader = byteReader.seek(constantPool[index - 1]); byte tag = reader.readByte(); if (tag != CONSTANT_UTF8) { throw new AssertionError(String.format("bad tag: %x", tag)); } return reader.readUTF(); }
Example 5
Source File: ConstantPoolReader.java From turbine with Apache License 2.0 | 5 votes |
/** Reads the CONSTANT_Module_info at the given index. */ public String moduleInfo(int index) { ByteArrayDataInput reader = byteReader.seek(constantPool[index - 1]); byte tag = reader.readByte(); if (tag != CONSTANT_MODULE) { throw new AssertionError(String.format("bad tag: %x", tag)); } int nameIndex = reader.readUnsignedShort(); return utf8(nameIndex); }
Example 6
Source File: ConstantPoolReader.java From turbine with Apache License 2.0 | 5 votes |
/** Reads the CONSTANT_Package_info at the given index. */ public String packageInfo(int index) { ByteArrayDataInput reader = byteReader.seek(constantPool[index - 1]); byte tag = reader.readByte(); if (tag != CONSTANT_PACKAGE) { throw new AssertionError(String.format("bad tag: %x", tag)); } int nameIndex = reader.readUnsignedShort(); return utf8(nameIndex); }
Example 7
Source File: MoCEntityGolem.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
@Override public void readSpawnData(ByteArrayDataInput data) { for (int i = 0; i < 23; i++) { golemCubes[i] = data.readByte(); } }
Example 8
Source File: PacketTerminalFluid.java From ExtraCells1 with MIT License | 5 votes |
@Override public void read(ByteArrayDataInput in) throws ProtocolException { type = in.readByte(); world = DimensionManager.getWorld(in.readInt()); x = in.readInt(); y = in.readInt(); z = in.readInt(); fluidID = in.readInt(); amount = in.readInt(); }
Example 9
Source File: ServerJoinedPackage.java From bartworks with MIT License | 4 votes |
@Override public GT_Packet decode(ByteArrayDataInput byteArrayDataInput) { this.config = byteArrayDataInput.readByte(); return this; }
Example 10
Source File: PlayerSqlProtocol.java From PlayerSQL with GNU General Public License v2.0 | 4 votes |
public static PlayerSqlProtocol decode(byte[] input) { ByteArrayDataInput buf = ByteStreams.newDataInput(input); Protocol protocol = Protocol.values()[buf.readByte()]; return protocol.decode(buf); }