本文整理匯總了Java中com.google.common.io.ByteArrayDataInput.readInt方法的典型用法代碼示例。如果您正苦於以下問題:Java ByteArrayDataInput.readInt方法的具體用法?Java ByteArrayDataInput.readInt怎麽用?Java ByteArrayDataInput.readInt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.io.ByteArrayDataInput
的用法示例。
在下文中一共展示了ByteArrayDataInput.readInt方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: readPermissionRequest
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
/**
* Reads a permission request.
*/
public static PermissionRequest readPermissionRequest(
Player player, byte[] data) {
ByteArrayDataInput input = ByteStreams.newDataInput(data);
String requestReason = input.readUTF();
Map<String, String> requestedPerms = new HashMap<>();
int numRequests = input.readInt();
for (int i = 0; i < numRequests; i++) {
String key = input.readUTF();
String value = input.readUTF();
requestedPerms.put(key, value);
}
List<ProtectionRange> rangeRequests = new ArrayList<>();
int numRangeRequests = input.readInt();
for (int i = 0; i < numRangeRequests; i++) {
rangeRequests.add(readProtectionRange(input));
}
return new PermissionRequest(player, requestReason, requestedPerms,
rangeRequests);
}
示例3: 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;
}
示例4: consumePacket
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
@Override
public FMLPacket consumePacket(byte[] data)
{
ByteArrayDataInput dat = ByteStreams.newDataInput(data);
int versionListSize = dat.readInt();
modVersions = Maps.newHashMapWithExpectedSize(versionListSize);
for (int i = 0; i < versionListSize; i++)
{
String modName = dat.readUTF();
String modVersion = dat.readUTF();
modVersions.put(modName, modVersion);
}
int missingModSize = dat.readInt();
missingMods = Lists.newArrayListWithExpectedSize(missingModSize);
for (int i = 0; i < missingModSize; i++)
{
missingMods.add(dat.readUTF());
}
return this;
}
示例5: accept
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
@Override
public boolean accept(Player receiver, ByteArrayDataInput in) {
String ip = in.readUTF();
int port = in.readInt();
callback.accept(Maps.immutableEntry(ip, port));
return true;
}
示例6: readPatch
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
private ClassPatch readPatch(JarEntry patchEntry, JarInputStream jis)
{
if (DEBUG)
FMLRelaunchLog.finer("Reading patch data from %s", patchEntry.getName());
ByteArrayDataInput input;
try
{
input = ByteStreams.newDataInput(ByteStreams.toByteArray(jis));
}
catch (IOException e)
{
FMLRelaunchLog.log(Level.WARN, e, "Unable to read binpatch file %s - ignoring", patchEntry.getName());
return null;
}
String name = input.readUTF();
String sourceClassName = input.readUTF();
String targetClassName = input.readUTF();
boolean exists = input.readBoolean();
int inputChecksum = 0;
if (exists)
{
inputChecksum = input.readInt();
}
int patchLength = input.readInt();
byte[] patchBytes = new byte[patchLength];
input.readFully(patchBytes);
return new ClassPatch(name, sourceClassName, targetClassName, exists, inputChecksum, patchBytes);
}
示例7: getClusterIds
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
/**
* @return the set of clusterIds that have consumed the mutation
*/
public List<UUID> getClusterIds() {
List<UUID> clusterIds = new ArrayList<UUID>();
byte[] bytes = getAttribute(CONSUMED_CLUSTER_IDS);
if(bytes != null) {
ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
int numClusters = in.readInt();
for(int i=0; i<numClusters; i++){
clusterIds.add(new UUID(in.readLong(), in.readLong()));
}
}
return clusterIds;
}
示例8: read
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
@Override
public void read(ByteArrayDataInput stream) {
this.friends.clear();
int size = stream.readInt();
for (int i = 0; i < size; i++) {
this.friends.add(stream.readUTF());
}
}
示例9: getClusterIds
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
/**
* @return the set of cluster Ids that have consumed the mutation
*/
public List<UUID> getClusterIds() {
List<UUID> clusterIds = new ArrayList<UUID>();
byte[] bytes = getAttribute(CONSUMED_CLUSTER_IDS);
if(bytes != null) {
ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
int numClusters = in.readInt();
for(int i=0; i<numClusters; i++){
clusterIds.add(new UUID(in.readLong(), in.readLong()));
}
}
return clusterIds;
}
示例10: readPatch
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
private ClassPatch readPatch(JarEntry patchEntry, JarInputStream jis)
{
FMLRelaunchLog.finer("Reading patch data from %s", patchEntry.getName());
ByteArrayDataInput input;
try
{
input = ByteStreams.newDataInput(ByteStreams.toByteArray(jis));
}
catch (IOException e)
{
FMLRelaunchLog.log(Level.WARN, e, "Unable to read binpatch file %s - ignoring", patchEntry.getName());
return null;
}
String name = input.readUTF();
String sourceClassName = input.readUTF();
String targetClassName = input.readUTF();
boolean exists = input.readBoolean();
int inputChecksum = 0;
if (exists)
{
inputChecksum = input.readInt();
}
int patchLength = input.readInt();
byte[] patchBytes = new byte[patchLength];
input.readFully(patchBytes);
return new ClassPatch(name, sourceClassName, targetClassName, exists, inputChecksum, patchBytes);
}
示例11: getClusterIds
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
/**
* @return the set of clusterIds that have consumed the mutation
*/
public List<UUID> getClusterIds() {
List<UUID> clusterIds = new ArrayList<UUID>();
byte[] bytes = getAttribute(CONSUMED_CLUSTER_IDS);
if (bytes != null) {
ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
int numClusters = in.readInt();
for (int i = 0; i < numClusters; i++) {
clusterIds.add(new UUID(in.readLong(), in.readLong()));
}
}
return clusterIds;
}
示例12: readFields
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
/**
* @param bytes
* @throws IOException
*/
public void readFields(byte[] bytes) throws IOException {
ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
int indicesSize = in.readInt();
indices.clear();
for (int i = 0; i < indicesSize; i++) {
IndexSpecification is = new IndexSpecification();
is.readFields(in);
this.indices.add(is);
}
}
示例13: consumePacket
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
@Override
public ForgePacket consumePacket(byte[] data)
{
ByteArrayDataInput dat = ByteStreams.newDataInput(data);
dimensionId = dat.readInt();
providerId = dat.readInt();
return this;
}
示例14: recievePacket
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
@Override
public void recievePacket(ByteArrayDataInput data) {
fuel = data.readInt();
maxFuel = data.readInt();
cookTime = data.readInt();
direction = (byte)data.readInt();
heat = data.readInt();
}
示例15: read
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
@Override
public void read(ByteArrayDataInput in) {
windowId = in.readInt();
marketId = in.readInt();
cartIndex = in.readInt();
int itemId = in.readInt();
int stackSize = in.readInt();
int damage = in.readInt();
Item item = (Item)Item.itemRegistry.getObjectById(itemId);
itemToAddOrUpdate = new ItemStack(item, stackSize, damage);
addIfUnlocated = in.readBoolean();
}