当前位置: 首页>>代码示例>>Java>>正文


Java ByteArrayDataInput.readByte方法代码示例

本文整理汇总了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));
  }
}
 
开发者ID:google,项目名称:turbine,代码行数:23,代码来源:ConstantPoolReader.java

示例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;
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:21,代码来源:ModListRequestPacket.java

示例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);
}
 
开发者ID:google,项目名称:turbine,代码行数:11,代码来源:ConstantPoolReader.java

示例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();
}
 
开发者ID:google,项目名称:turbine,代码行数:10,代码来源:ConstantPoolReader.java

示例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);
}
 
开发者ID:google,项目名称:turbine,代码行数:11,代码来源:ConstantPoolReader.java

示例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);
}
 
开发者ID:google,项目名称:turbine,代码行数:11,代码来源:ConstantPoolReader.java

示例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;
}
 
开发者ID:TheAwesomeGem,项目名称:MineFantasy,代码行数:14,代码来源:BattlegearUtils.java

示例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();
	}
}
 
开发者ID:austinv11,项目名称:PeripheralsPlusPlus,代码行数:12,代码来源:Tile.java

示例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;
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:39,代码来源:EntitySpawnPacket.java

示例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;
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:39,代码来源:EntitySpawnPacket.java

示例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;
}
 
开发者ID:ds84182,项目名称:OpenGX,代码行数:9,代码来源:GXMap.java

示例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;
       		}
       	}
       }
}
 
开发者ID:ds84182,项目名称:OpenGX,代码行数:40,代码来源:ComponentGX.java

示例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);
}
 
开发者ID:austinv11,项目名称:PeripheralsPlusPlus,代码行数:7,代码来源:TileLanCable.java

示例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();
		}
	}
}
 
开发者ID:ds84182,项目名称:OpenGX,代码行数:61,代码来源:Tier2GX.java


注:本文中的com.google.common.io.ByteArrayDataInput.readByte方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。