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


Java DataInput.readUnsignedByte方法代码示例

本文整理汇总了Java中java.io.DataInput.readUnsignedByte方法的典型用法代码示例。如果您正苦于以下问题:Java DataInput.readUnsignedByte方法的具体用法?Java DataInput.readUnsignedByte怎么用?Java DataInput.readUnsignedByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.DataInput的用法示例。


在下文中一共展示了DataInput.readUnsignedByte方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readPixel

import java.io.DataInput; //导入方法依赖的package包/类
/**
 * Tries to recycle a pooled bitmap and reads raw pixels into the bitmap. Internally always reuses
 * a (potentially) big buffer to update the texture. The buffer grows to the largest size when needed and
 * is never shrunk, so be careful what you read, e.g. a fullhd frame will take more than 8 MiB. However to
 * lower the pressure to the stupid Android GC we sacrifice throughput by synchronizing globally, so NEVER
 * call this method from the UI thread.
 * <p>
 * The format is:
 * <pre>
 *     bool available   1 byte
 *     int width        4 byte
 *     int height       4 byte
 *     int type         1 byte, [2 = ARGB_8888]
 * </pre>
 *
 * @param in the source
 * @return the instance or null if not available
 * @throws IOException
 */
@Nullable
public static Bitmap readPixel(DataInput in) throws IOException {
    boolean available = in.readBoolean();
    if (!available) {
        return null;
    }
    int width = in.readInt();
    int height = in.readInt();
    int type = in.readUnsignedByte();
    if (type != Config.ARGB_8888.ordinal()) {
        throw new Panic("format not implemented " + type);
    }
    int bytes = width * height * 4;
    Bitmap bmp = getDefaultPool().borrowBitmap(width, height, Config.ARGB_8888);
    synchronized (BitmapPoolFactory.class) {
        if (sTmp.capacity() < bytes) {
            sTmp = ByteBuffer.allocate(bytes);
        }
        sTmp.clear();
        in.readFully(sTmp.array(), 0, bytes);
        sTmp.limit(bytes);
        bmp.copyPixelsFromBuffer(sTmp);
    }
    return bmp;
}
 
开发者ID:worldiety,项目名称:homunculus,代码行数:45,代码来源:BitmapPoolFactory.java

示例2: readDiskRegionID

import java.io.DataInput; //导入方法依赖的package包/类
static long readDiskRegionID(DataInput dis) throws IOException {
  int bytesToRead = dis.readUnsignedByte();
  if (bytesToRead <= DiskStoreImpl.MAX_RESERVED_DRID
      && bytesToRead >= DiskStoreImpl.MIN_RESERVED_DRID) {
    long result = dis.readByte(); // we want to sign extend this first byte
    bytesToRead--;
    while (bytesToRead > 0) {
      result <<= 8;
      result |= dis.readUnsignedByte(); // no sign extension
      bytesToRead--;
    }
    return result;
  } else {
    return bytesToRead;
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:17,代码来源:DiskInitFile.java

示例3: read

import java.io.DataInput; //导入方法依赖的package包/类
@Override
@SuppressWarnings("all")
public void read(DataInput input) throws IOException {
    int typeId = input.readUnsignedByte();
    super.value = new ArrayList<>();
    this.elementTypeId = typeId;
    int length = input.readInt();
    for(int i = 0; i < length; i++) {
        NBTBase nbt = NBTType.createNBTTag(typeId);
        nbt.read(input);
        add((E) nbt);
    }
}
 
开发者ID:McMoonLakeDev,项目名称:MoonLakeNBT,代码行数:14,代码来源:NBTTagList.java

示例4: testReadUnsignedByte_eof

import java.io.DataInput; //导入方法依赖的package包/类
public void testReadUnsignedByte_eof() throws IOException {
  DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(new byte[0]));
  try {
    in.readUnsignedByte();
    fail();
  } catch (EOFException expected) {
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:9,代码来源:LittleEndianDataInputStreamTest.java

示例5: parseConstantPool_CONSTANT_MethodHandle

import java.io.DataInput; //导入方法依赖的package包/类
private void parseConstantPool_CONSTANT_MethodHandle(DataInput aDis, BytecodeConstantPool aConstantPool) throws IOException {
    int theReferenceKind = aDis.readUnsignedByte();
    int theReferenceIndex = aDis.readUnsignedShort();
    switch (theReferenceKind) {
        case 1:
            aConstantPool.registerConstant(new BytecodeMethodHandleConstant(BytecodeReferenceKind.REF_getField, new BytecodeReferenceIndex(theReferenceIndex, aConstantPool)));
            break;
        case 2:
            aConstantPool.registerConstant(new BytecodeMethodHandleConstant(BytecodeReferenceKind.REF_getStatic, new BytecodeReferenceIndex(theReferenceIndex, aConstantPool)));
            break;
        case 3:
            aConstantPool.registerConstant(new BytecodeMethodHandleConstant(BytecodeReferenceKind.REF_putField, new BytecodeReferenceIndex(theReferenceIndex, aConstantPool)));
            break;
        case 4:
            aConstantPool.registerConstant(new BytecodeMethodHandleConstant(BytecodeReferenceKind.REF_putStatic, new BytecodeReferenceIndex(theReferenceIndex, aConstantPool)));
            break;
        case 5:
            aConstantPool.registerConstant(new BytecodeMethodHandleConstant(BytecodeReferenceKind.REF_invokeVirtual, new BytecodeReferenceIndex(theReferenceIndex, aConstantPool)));
            break;
        case 6:
            aConstantPool.registerConstant(new BytecodeMethodHandleConstant(BytecodeReferenceKind.REF_invokeStatic, new BytecodeReferenceIndex(theReferenceIndex, aConstantPool)));
            break;
        case 7:
            aConstantPool.registerConstant(new BytecodeMethodHandleConstant(BytecodeReferenceKind.REF_invokeSpecial, new BytecodeReferenceIndex(theReferenceIndex, aConstantPool)));
            break;
        case 8:
            aConstantPool.registerConstant(new BytecodeMethodHandleConstant(BytecodeReferenceKind.REF_newInvokeSpecial, new BytecodeReferenceIndex(theReferenceIndex, aConstantPool)));
            break;
        case 9:
            aConstantPool.registerConstant(new BytecodeMethodHandleConstant(BytecodeReferenceKind.REF_invokeInterface, new BytecodeReferenceIndex(theReferenceIndex, aConstantPool)));
            break;
        default:
            throw new IllegalStateException("Unknown reference kind : " + theReferenceKind);
    }
}
 
开发者ID:mirkosertic,项目名称:Bytecoder,代码行数:36,代码来源:Bytecode5xClassParser.java

示例6: parseAnnotationAttribute

import java.io.DataInput; //导入方法依赖的package包/类
private BytecodeAnnotationAttributeInfo parseAnnotationAttribute(DataInput aDis, BytecodeConstantPool aConstantPool) throws IOException {
    int theAnnotationCount = aDis.readUnsignedShort();
    List<BytecodeAnnotation> theAnnotations = new ArrayList<>();
    for (int i=0;i<theAnnotationCount;i++) {
        int theTypeIndex = aDis.readUnsignedShort();
        int theNumElementValuePairs = aDis.readUnsignedShort();

        List<BytecodeAnnotation.ElementValuePair> theElementValuePairs = new ArrayList<>();
        for (int j=0;j<theNumElementValuePairs;j++) {
            int theElementNameIndex = aDis.readUnsignedShort();
            char theTag = (char) aDis.readUnsignedByte();
            switch (theTag) {
                case 's':
                    int theConstValueIndex = aDis.readUnsignedShort();
                    theElementValuePairs.add(new BytecodeAnnotation.ElementValuePair(theElementNameIndex,
                            new BytecodeAnnotation.StringElementValue(theConstValueIndex, aConstantPool),
                            aConstantPool));
                    break;
                case 'c':
                    int theClassInfoIndex = aDis.readUnsignedShort();
                    theElementValuePairs.add(new BytecodeAnnotation.ElementValuePair(theElementNameIndex,
                            new BytecodeAnnotation.ClassElementValue(theClassInfoIndex, aConstantPool, signatureParser),
                            aConstantPool));
                    break;
                default:
                    throw new IllegalArgumentException("Not supported annotation value type : " + theTag);
            }
        }

        theAnnotations.add(new BytecodeAnnotation(theTypeIndex, theElementValuePairs.toArray(new BytecodeAnnotation.ElementValuePair[theElementValuePairs.size()]), aConstantPool, signatureParser));
    }

    return new BytecodeAnnotationAttributeInfo(theAnnotations.toArray(new BytecodeAnnotation[theAnnotations.size()]));
}
 
开发者ID:mirkosertic,项目名称:Bytecoder,代码行数:35,代码来源:Bytecode5xClassParser.java

示例7: fromData

import java.io.DataInput; //导入方法依赖的package包/类
@Override
public final void fromData(DataInput in) throws IOException, ClassNotFoundException {
  super.fromData(in);
  setKey(DataSerializer.readObject(in));

  final int extraFlags = in.readUnsignedByte();
  this.deserializationPolicy =
      (byte) (extraFlags & DistributedCacheOperation.DESERIALIZATION_POLICY_MASK);
  this.cbArg = DataSerializer.readObject(in);
  this.lastModified = in.readLong();
  this.op = Operation.fromOrdinal(in.readByte());
  if ((extraFlags & HAS_BRIDGE_CONTEXT) != 0) {
    this.bridgeContext = DataSerializer.readObject(in);
  }
  if ((extraFlags & HAS_ORIGINAL_SENDER) != 0) {
    this.originalSender = DataSerializer.readObject(in);
  }
  this.eventId = new EventID();
  InternalDataSerializer.invokeFromData(this.eventId, in);

  if ((flags & HAS_EXPECTED_OLD_VAL) != 0) {
    this.expectedOldValue = DataSerializer.readObject(in);
  }

  if (this.hasOldValue) {
    this.oldValueIsSerialized = (in.readByte() == 1);
    setOldValBytes(DataSerializer.readByteArray(in));
  }
  setValBytes(DataSerializer.readByteArray(in));
  if ((flags & HAS_DELTA_BYTES) != 0) {
    this.applyDeltaBytes = true;
    this.deltaBytes = DataSerializer.readByteArray(in);
  }
  if ((extraFlags & HAS_VERSION_TAG) != 0) {
    this.versionTag = DataSerializer.readObject(in);
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:38,代码来源:RemotePutMessage.java

示例8: readCompactValue

import java.io.DataInput; //导入方法依赖的package包/类
public static long readCompactValue(DataInput dataIn) throws IOException {
  long v = dataIn.readByte();
  boolean dump = false;
  if (dump) {
    System.out.print("compactValue(byte1)=" + v);
  }
  if (v < MIN_1BYTE_COMPACT_VALUE) {
    if (v == COMPACT_VALUE_2_TOKEN) {
      v = dataIn.readShort();
      if (dump) {
        System.out.print("compactValue(short)=" + v);
      }
    } else {
      int bytesToRead = ((byte) v - COMPACT_VALUE_2_TOKEN) + 2;
      v = dataIn.readByte(); // note the first byte will be a signed byte.
      if (dump) {
        System.out.print("compactValue(" + bytesToRead + ")=" + v);
      }
      bytesToRead--;
      while (bytesToRead > 0) {
        v <<= 8;
        v |= dataIn.readUnsignedByte();
        bytesToRead--;
      }
    }
  }
  return v;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:29,代码来源:StatArchiveWriter.java

示例9: readUnsignedByte

import java.io.DataInput; //导入方法依赖的package包/类
/**
 * Reads a primitive <code>int</code> as an unsigned byte from a <code>DataInput</code> using
 * {@link DataInput#readUnsignedByte}.
 *
 * @throws IOException A problem occurs while reading from <code>in</code>
 * @since GemFire 5.1
 */
public static int readUnsignedByte(DataInput in) throws IOException {
  InternalDataSerializer.checkIn(in);

  int value = in.readUnsignedByte();
  if (logger.isTraceEnabled(LogMarker.SERIALIZER)) {
    logger.trace(LogMarker.SERIALIZER, "Read Unsigned Byte {}", value);
  }
  return value;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:17,代码来源:DataSerializer.java

示例10: ParameterAnnotations

import java.io.DataInput; //导入方法依赖的package包/类
/**
 * @param parameter_annotation_type the subclass type of the parameter annotation
 * @param name_index Index pointing to the name <em>Code</em>
 * @param length Content length in bytes
 * @param input Input stream
 * @param constant_pool Array of constants
 */
ParameterAnnotations(final byte parameter_annotation_type, final int name_index, final int length,
        final DataInput input, final ConstantPool constant_pool) throws IOException {
    this(parameter_annotation_type, name_index, length, (ParameterAnnotationEntry[]) null,
            constant_pool);
    final int num_parameters = input.readUnsignedByte();
    parameter_annotation_table = new ParameterAnnotationEntry[num_parameters];
    for (int i = 0; i < num_parameters; i++) {
        parameter_annotation_table[i] = new ParameterAnnotationEntry(input, constant_pool);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:ParameterAnnotations.java

示例11: MethodParameters

import java.io.DataInput; //导入方法依赖的package包/类
MethodParameters(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool) throws IOException {
    super(Const.ATTR_METHOD_PARAMETERS, name_index, length, constant_pool);

    final int parameters_count = input.readUnsignedByte();
    parameters = new MethodParameter[parameters_count];
    for (int i = 0; i < parameters_count; i++) {
        parameters[i] = new MethodParameter(input);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:MethodParameters.java

示例12: readLegacyCell

import java.io.DataInput; //导入方法依赖的package包/类
public static LegacyCell readLegacyCell(CFMetaData metadata, DataInput in, SerializationHelper.Flag flag) throws IOException, UnknownColumnException
{
    ByteBuffer cellname = ByteBufferUtil.readWithShortLength(in);
    int b = in.readUnsignedByte();
    return readLegacyCellBody(metadata, in, cellname, b, flag, false);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:7,代码来源:LegacyLayout.java

示例13: readVLong

import java.io.DataInput; //导入方法依赖的package包/类
/**
 * Decoding the variable-length integer. Suppose the value of the first byte
 * is FB, and the following bytes are NB[*].
 * <ul>
 * <li>if (FB >= -32), return (long)FB;
 * <li>if (FB in [-72, -33]), return (FB+52)<<8 + NB[0]&0xff;
 * <li>if (FB in [-104, -73]), return (FB+88)<<16 + (NB[0]&0xff)<<8 +
 * NB[1]&0xff;
 * <li>if (FB in [-120, -105]), return (FB+112)<<24 + (NB[0]&0xff)<<16 +
 * (NB[1]&0xff)<<8 + NB[2]&0xff;
 * <li>if (FB in [-128, -121]), return interpret NB[FB+129] as a signed
 * big-endian integer.
 * 
 * @param in
 *          input stream
 * @return the decoded long integer.
 * @throws IOException
 */

public static long readVLong(DataInput in) throws IOException {
  int firstByte = in.readByte();
  if (firstByte >= -32) {
    return firstByte;
  }

  switch ((firstByte + 128) / 8) {
    case 11:
    case 10:
    case 9:
    case 8:
    case 7:
      return ((firstByte + 52) << 8) | in.readUnsignedByte();
    case 6:
    case 5:
    case 4:
    case 3:
      return ((firstByte + 88) << 16) | in.readUnsignedShort();
    case 2:
    case 1:
      return ((firstByte + 112) << 24) | (in.readUnsignedShort() << 8)
          | in.readUnsignedByte();
    case 0:
      int len = firstByte + 129;
      switch (len) {
        case 4:
          return in.readInt();
        case 5:
          return ((long) in.readInt()) << 8 | in.readUnsignedByte();
        case 6:
          return ((long) in.readInt()) << 16 | in.readUnsignedShort();
        case 7:
          return ((long) in.readInt()) << 24 | (in.readUnsignedShort() << 8)
              | in.readUnsignedByte();
        case 8:
          return in.readLong();
        default:
          throw new IOException("Corrupted VLong encoding");
      }
    default:
      throw new RuntimeException("Internal error");
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:63,代码来源:Utils.java

示例14: parseConstantPool

import java.io.DataInput; //导入方法依赖的package包/类
private BytecodeConstantPool parseConstantPool(DataInput aDis) throws IOException {
    BytecodeConstantPool theResult = new BytecodeConstantPool();
    int theConstantPoolCount = aDis.readUnsignedShort();
    for (int i=1;i<theConstantPoolCount;i++) {
        int theTag = aDis.readUnsignedByte();
        switch (theTag) {
            case CONSTANT_Class:
                parseConstantPool_CONSTANT_Class(aDis, theResult);
                break;
            case CONSTANT_Fieldref:
                parseConstantPool_CONSTANT_Fieldref(aDis, theResult);
                break;
            case CONSTANT_Methodref:
                parseConstantPool_CONSTANT_Methodref(aDis, theResult);
                break;
            case CONSTANT_InterfaceMethodref:
                parseConstantPool_CONSTANT_InterfaceMethodref(aDis, theResult);
                break;
            case CONSTANT_String:
                parseConstantPool_CONSTANT_String(aDis, theResult);
                break;
            case CONSTANT_Integer:
                parseConstantPool_CONSTANT_Integer(aDis, theResult);
                break;
            case CONSTANT_Float:
                parseConstantPool_CONSTANT_Float(aDis, theResult);
                break;
            case CONSTANT_Long:
                parseConstantPool_CONSTANT_Long(aDis, theResult);
                theResult.registerConstant(new BytecodeUnusedConstant());
                i++;
                break;
            case CONSTANT_Double:
                parseConstantPool_CONSTANT_Double(aDis, theResult);
                theResult.registerConstant(new BytecodeUnusedConstant());
                i++;
                break;
            case CONSTANT_NameAndType:
                parseConstantPool_CONSTANT_NameAndType(aDis, theResult);
                break;
            case CONSTANT_Utf8:
                parseConstantPool_CONSTANT_Utf8(aDis, theResult);
                break;
            case CONSTANT_MethodHandle:
                parseConstantPool_CONSTANT_MethodHandle(aDis, theResult);
                break;
            case CONSTANT_MethodType:
                parseConstantPool_CONSTANT_MethodType(aDis, theResult);
                break;
            case CONSTANT_InvokeDynamic:
                parseConstantPool_CONSTANT_InvokeDynamic(aDis, theResult);
                break;
            default:
                throw new IllegalStateException("Unknown constant pool tag : " + theTag + " for index " + i + " of " + theConstantPoolCount);
        }
    }

    return theResult;
}
 
开发者ID:mirkosertic,项目名称:Bytecoder,代码行数:60,代码来源:Bytecode5xClassParser.java

示例15: fromData

import java.io.DataInput; //导入方法依赖的package包/类
@Override
public final void fromData(DataInput in) throws IOException, ClassNotFoundException {
  super.fromData(in);

  final int extraFlags = in.readUnsignedByte();
  setKey(DataSerializer.readObject(in));
  this.cbArg = DataSerializer.readObject(in);
  this.lastModified = in.readLong();
  this.op = Operation.fromOrdinal(in.readByte());
  if ((extraFlags & HAS_BRIDGE_CONTEXT) != 0) {
    this.bridgeContext = ClientProxyMembershipID.readCanonicalized(in);
  }
  if ((extraFlags & HAS_ORIGINAL_SENDER) != 0) {
    this.originalSender = (InternalDistributedMember) DataSerializer.readObject(in);
  }
  this.eventId = new EventID();
  InternalDataSerializer.invokeFromData(this.eventId, in);

  if ((flags & HAS_EXPECTED_OLD_VAL) != 0) {
    this.expectedOldValue = DataSerializer.readObject(in);
  }
  /*
   * this.hasOldValue = in.readBoolean(); if (this.hasOldValue){
   * //out.writeBoolean(this.hasOldValue); this.oldValueIsSerialized = in.readBoolean();
   * setOldValBytes(DataSerializer.readByteArray(in)); }
   */
  if (this.hasFilterInfo) {
    this.filterInfo = new FilterRoutingInfo();
    InternalDataSerializer.invokeFromData(this.filterInfo, in);
  }
  this.deserializationPolicy =
      (byte) (extraFlags & DistributedCacheOperation.DESERIALIZATION_POLICY_MASK);

  if (this.hasDelta) {
    this.deltaBytes = DataSerializer.readByteArray(in);
  } else {
    setValBytes(DataSerializer.readByteArray(in));
    if ((extraFlags & HAS_DELTA_WITH_FULL_VALUE) != 0) {
      this.deltaBytes = DataSerializer.readByteArray(in);
    }
  }
  if ((flags & HAS_VERSION_TAG) != 0) {
    this.versionTag = DataSerializer.readObject(in);
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:46,代码来源:PutMessage.java


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