本文整理汇总了Java中com.google.common.io.ByteArrayDataInput.readByte方法的典型用法代码示例。如果您正苦于以下问题:Java ByteArrayDataInput.readByte方法的具体用法?Java ByteArrayDataInput.readByte怎么用?Java ByteArrayDataInput.readByte使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.io.ByteArrayDataInput
的用法示例。
在下文中一共展示了ByteArrayDataInput.readByte方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: constant
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
/**
* 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()));
default:
throw new AssertionError(String.format("bad tag: %x", tag));
}
}
示例2: consumePacket
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
@Override
public FMLPacket consumePacket(byte[] data)
{
sentModList = Lists.newArrayList();
ByteArrayDataInput in = ByteStreams.newDataInput(data);
int listSize = in.readInt();
for (int i = 0; i < listSize; i++)
{
sentModList.add(in.readUTF());
}
try
{
compatibilityLevel = in.readByte();
}
catch (IllegalStateException e)
{
FMLLog.fine("No compatibility byte found - the server is too old");
}
return this;
}
示例3: classInfo
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
/** 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);
}
示例4: utf8
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
/** 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();
}
示例5: moduleInfo
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
/** 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);
}
示例6: packageInfo
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
/** 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);
}
示例7: readItemStack
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
public static ItemStack readItemStack(ByteArrayDataInput par0DataInputStream) throws IOException {
ItemStack itemstack = null;
short short1 = par0DataInputStream.readShort();
if (short1 >= 0) {
byte b0 = par0DataInputStream.readByte();
short short2 = par0DataInputStream.readShort();
itemstack = new ItemStack(short1, b0, short2);
itemstack.stackTagCompound = readNBTTagCompound(par0DataInputStream);
}
return itemstack;
}
示例8: readSpawnData
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
@Override
public void readSpawnData(ByteArrayDataInput data) {
setFacing(data.readByte());
byte flags = data.readByte();
setActive((flags & (1 << 0)) != 0);
if ((flags & (1 << 1)) != 0) {
displayName = data.readUTF();
}
}
示例9: consumePacket
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
@Override
public FMLPacket consumePacket(byte[] data)
{
ByteArrayDataInput dat = ByteStreams.newDataInput(data);
networkId = dat.readInt();
modEntityId = dat.readInt();
entityId = dat.readInt();
rawX = dat.readInt();
rawY = dat.readInt();
rawZ = dat.readInt();
scaledX = rawX / 32D;
scaledY = rawY / 32D;
scaledZ = rawZ / 32D;
scaledYaw = dat.readByte() * 360F / 256F;
scaledPitch = dat.readByte() * 360F / 256F;
scaledHeadYaw = dat.readByte() * 360F / 256F;
ByteArrayInputStream bis = new ByteArrayInputStream(data, 27, data.length - 27);
DataInputStream dis = new DataInputStream(bis);
try
{
metadata = DataWatcher.func_75686_a(dis);
}
catch (IOException e)
{
// Nope
}
dat.skipBytes(data.length - bis.available() - 27);
throwerId = dat.readInt();
if (throwerId != 0)
{
speedScaledX = dat.readInt() / 8000D;
speedScaledY = dat.readInt() / 8000D;
speedScaledZ = dat.readInt() / 8000D;
}
this.dataStream = dat;
return this;
}
示例10: consumePacket
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
@Override
public FMLPacket consumePacket(byte[] data)
{
ByteArrayDataInput dat = ByteStreams.newDataInput(data);
networkId = dat.readInt();
modEntityId = dat.readInt();
entityId = dat.readInt();
rawX = dat.readInt();
rawY = dat.readInt();
rawZ = dat.readInt();
scaledX = rawX / 32D;
scaledY = rawY / 32D;
scaledZ = rawZ / 32D;
scaledYaw = dat.readByte() * 360F / 256F;
scaledPitch = dat.readByte() * 360F / 256F;
scaledHeadYaw = dat.readByte() * 360F / 256F;
ByteArrayInputStream bis = new ByteArrayInputStream(data, 27, data.length - 27);
DataInputStream dis = new DataInputStream(bis);
try
{
metadata = DataWatcher.readWatchableObjects(dis);
}
catch (IOException e)
{
// Nope
}
dat.skipBytes(data.length - bis.available() - 27);
throwerId = dat.readInt();
if (throwerId != 0)
{
speedScaledX = dat.readInt() / 8000D;
speedScaledY = dat.readInt() / 8000D;
speedScaledZ = dat.readInt() / 8000D;
}
this.dataStream = dat;
return this;
}
示例11: feed
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
public void feed(ByteArrayDataInput fifo) {
short damnt = fifo.readShort();
for (int i=0; i<damnt; i++)
{
data[dataidx++] = (short) (fifo.readByte() & 0xFF); //make it unsigned
}
finished = dataidx<data.length;
}
示例12: load
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
@Override
public void load(NBTTagCompound nbt) {
if (node != null)
node.load(nbt);
tier = nbt.getInteger("tier")+1;
monitorAddress = nbt.getString("monitor");
if (monitorAddress.length() == 0)
monitorAddress = null;
init();
if (romGX != null) {
romGX.load(nbt.getCompoundTag("oc:romnode"));
}
NBTTagList stateReloadPackets = nbt.getTagList("state", 10);
if (stateReloadPackets != null)
{
for (int i=0; i<stateReloadPackets.tagCount(); i++)
{
NBTTagCompound pkt = stateReloadPackets.getCompoundTagAt(i);
IGX.DataType type = IGX.DataType.values()[pkt.getInteger("type")];
byte[] data = nbt.getByteArray("data");
ByteArrayDataInput dat = ByteStreams.newDataInput(data);
switch (type)
{
case FIFO:
gx.uploadFIFO(dat,data);
break;
case TEXTURE:
int id = dat.readShort();
int fmt = dat.readByte();
int size = dat.readInt();
byte[] texdata = new byte[size];
dat.readFully(texdata);
gx.uploadTexture((short) id, new ByteArrayInputStream(texdata), (byte) fmt);
break;
}
}
}
}
示例13: readSpawnData
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
@Override
public void readSpawnData(ByteArrayDataInput data) {
type = data.readByte();
if (worldObj != null) worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
示例14: uploadFIFO
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
@Override
public void uploadFIFO(ByteArrayDataInput fifo, byte[] fifoData) {
requestRender = true;
byte lastCommand = -1;
while (true)
{
byte b;
try
{
b = fifo.readByte();
}
catch(Exception e)
{
break;
}
if (b == GX_INIT)
{
System.out.println("GX_INIT");
reset();
}
else if (b == GX_ADD_POLYGON)
{
addPolygon(fifo);
}
else if (b == GX_ADD_POLYGONS)
{
int np = fifo.readInt();
for (int i=0; i<np; i++)
addPolygon(fifo);
}
else if (b == GX_CLEAR_POLYGONS)
{
nrpolygons = 0;
}
else if (b == GX_DISABLE_CLEAR)
{
clear = false;
}
else if (b == GX_SET_CLEAR_COLOR)
{
clear = true;
cR = fifo.readFloat();
cG = fifo.readFloat();
cB = fifo.readFloat();
cA = fifo.readFloat();
}
else if (b == GX_LOAD_MATRIX)
{
matrix = new GXMatrix(fifo);
}
else if (b == GX_MULTIPLY_MATRIX)
{
GXMatrix.mul(matrix, new GXMatrix(fifo), matrix);
}
else if (b == GX_LOAD_IDENTITY_MATRIX)
{
matrix = new GXMatrix();
}
}
}