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


Java ReadBuffer类代码示例

本文整理汇总了Java中com.sun.tools.hat.internal.parser.ReadBuffer的典型用法代码示例。如果您正苦于以下问题:Java ReadBuffer类的具体用法?Java ReadBuffer怎么用?Java ReadBuffer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ReadBuffer类属于com.sun.tools.hat.internal.parser包,在下文中一共展示了ReadBuffer类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readValue

import com.sun.tools.hat.internal.parser.ReadBuffer; //导入依赖的package包/类
protected final byte[] readValue() throws IOException {
    JavaClass cl = getClazz();
    ReadBuffer buf = cl.getReadBuffer();
    int idSize = cl.getIdentifierSize();
    long offset = getOffset() + idSize + 4;
    // length of the array
    int length = buf.getInt(offset);
    // typecode of array element type
    byte type = buf.getByte(offset + 4);
    if (length == 0) {
        return Snapshot.EMPTY_BYTE_ARRAY;
    } else {
        length *= elementSize(type);
        byte[] res = new byte[length];
        buf.get(offset + 5, res);
        return res;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:JavaValueArray.java

示例2: create

import com.sun.tools.hat.internal.parser.ReadBuffer; //导入依赖的package包/类
static ReadBuffer create(RandomAccessFile file) throws IOException {
  FileChannel ch = file.getChannel();
  long size = ch.size();
  // if file size is more than 2 GB and when file mapping is
  // configured (default), use mapped file reader
  if (canUseFileMap() && (size <= Integer.MAX_VALUE)) {
    System.out.println("Using mapped file");
    MappedByteBuffer buf;
    try {
      buf = ch.map(FileChannel.MapMode.READ_ONLY, 0, size);
      ch.close();
      return new OriginalMappedReadBuffer(buf);
    } catch (IOException exp) {
      exp.printStackTrace();
      System.err.println("File mapping failed, will use direct read");
      // fall through
    }
  } // else fall through
  return new OriginalFileReadBuffer(file);
}
 
开发者ID:asengupta,项目名称:MuchHeap,代码行数:21,代码来源:OriginalMappedReadBuffer.java

示例3: readValueLength

import com.sun.tools.hat.internal.parser.ReadBuffer; //导入依赖的package包/类
protected final int readValueLength() throws IOException {
    JavaClass cl = getClazz();
    ReadBuffer buf = cl.getReadBuffer();
    int idSize = cl.getIdentifierSize();
    long offset = getOffset() + idSize + 4;
    // length of the array
    int len = buf.getInt(offset);
    // typecode of array element type
    byte type = buf.getByte(offset + 4);
    return len * elementSize(type);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:JavaValueArray.java

示例4: readValueLength

import com.sun.tools.hat.internal.parser.ReadBuffer; //导入依赖的package包/类
protected final int readValueLength() throws IOException {
    JavaClass cl = getClazz();
    ReadBuffer buf = cl.getReadBuffer();
    int idSize = cl.getIdentifierSize();
    long offset = getOffset() + idSize + 4;
    int len = buf.getInt(offset);
    return len * cl.getIdentifierSize();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:JavaObjectArray.java

示例5: readValue

import com.sun.tools.hat.internal.parser.ReadBuffer; //导入依赖的package包/类
protected final byte[] readValue() throws IOException {
    JavaClass cl = getClazz();
    ReadBuffer buf = cl.getReadBuffer();
    int idSize = cl.getIdentifierSize();
    long offset = getOffset() + idSize + 4;
    int len = buf.getInt(offset);
    if (len == 0) {
        return Snapshot.EMPTY_BYTE_ARRAY;
    } else {
        byte[] res = new byte[len * idSize];
        buf.get(offset + 4 + idSize, res);
        return res;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:JavaObjectArray.java

示例6: resolve

import com.sun.tools.hat.internal.parser.ReadBuffer; //导入依赖的package包/类
public void resolve(Snapshot snapshot) {
    if (clazz instanceof JavaClass) {
        return;
    }
    if (clazz instanceof Number) {
        long classID = getIdValue((Number)clazz);
        clazz = snapshot.findThing(classID);
        if (! (clazz instanceof JavaClass)) {
            warn("Class " + Long.toHexString(classID) + " not found, " +
                 "adding fake class!");
            int length;
            ReadBuffer buf = snapshot.getReadBuffer();
            int idSize = snapshot.getIdentifierSize();
            long lenOffset = getOffset() + 2*idSize + 4;
            try {
                length = buf.getInt(lenOffset);
            } catch (IOException exp) {
                throw new RuntimeException(exp);
            }
            clazz = snapshot.addFakeInstanceClass(classID, length);
        }
    } else {
        throw new InternalError("should not reach here");
    }

    JavaClass cl = (JavaClass) clazz;
    cl.resolve(snapshot);

    // while resolving, parse fields in verbose mode.
    // but, getFields calls parseFields in non-verbose mode
    // to avoid printing warnings repeatedly.
    parseFields(getValue(), true);

    cl.addInstance(this);
    super.resolve(snapshot);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:37,代码来源:JavaObject.java

示例7: readValue

import com.sun.tools.hat.internal.parser.ReadBuffer; //导入依赖的package包/类
protected final byte[] readValue() throws IOException {
    JavaClass cl = getClazz();
    int idSize = cl.getIdentifierSize();
    ReadBuffer buf = cl.getReadBuffer();
    long offset = getOffset() + 2*idSize + 4;
    int length = buf.getInt(offset);
    if (length == 0) {
        return Snapshot.EMPTY_BYTE_ARRAY;
    } else {
        byte[] res = new byte[length];
        buf.get(offset + 4, res);
        return res;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:JavaObject.java

示例8: getId

import com.sun.tools.hat.internal.parser.ReadBuffer; //导入依赖的package包/类
public final long getId() {
    try {
        ReadBuffer buf = getClazz().getReadBuffer();
        int idSize = getClazz().getIdentifierSize();
        if (idSize == 4) {
            return ((long)buf.getInt(offset)) & Snapshot.SMALL_ID_MASK;
        } else {
            return buf.getLong(offset);
        }
    } catch (IOException exp) {
        System.err.println("lazy read failed at offset " + offset);
        exp.printStackTrace();
        return -1;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:JavaLazyReadObject.java


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