public FNode(RandomAccessFile f) throws Throwable { offset = f.getFilePointer(); hash = f.readLong(); childOffset = f.readUnsignedShort(); numChildren = f.readUnsignedShort(); tagOffset = f.readUnsignedShort(); }
public FNode() throws IOException { offset = f.getFilePointer(); try { hash = f.readLong(); childOffset = f.readUnsignedShort(); numChildren = f.readUnsignedShort(); tagOffset = f.readUnsignedShort(); } catch (EOFException e) { numChildren = 0; tagOffset = 0; } }
private FNode binarySearch(long start, int len, long hash) throws IOException { int b = 0; int e = len; while (b <= e) { int m = (b + e) / 2; f.seek(start + m * EftarFile.RECORD_LENGTH); long mhash = f.readLong(); if (hash > mhash) { b = m + 1; } else if (hash < mhash) { e = m - 1; } else { return new FNode(mhash, f.getFilePointer() - 8l, f.readUnsignedShort(), f.readUnsignedShort(), f.readUnsignedShort()); } } return null; }
private FNode sbinSearch(long start, int len, long hash, RandomAccessFile f) throws Throwable { int b = 0; int e = len; while (b <= e) { int m = (b + e) / 2; f.seek(start + m * RECORD_LENGTH); long mhash = f.readLong(); if (hash > mhash) { b = m + 1; } else if (hash < mhash) { e = m - 1; } else { return new FNode(mhash, f.getFilePointer() - 8l, f.readUnsignedShort(), f.readUnsignedShort(), f.readUnsignedShort()); } } return null; } }
/** * Reads a string that is encoded in {@link DataInput modified UTF-8} from * this file. The number of bytes that must be read for the complete string * is determined by the first two bytes read from the file. Blocks until all * required bytes have been read, the end of the file is reached or an * exception is thrown. * * @return the next string encoded in {@link DataInput modified UTF-8} from * this file. * @throws EOFException * if the end of this file is detected. * @throws IOException * if this file is closed or another I/O error occurs. * @throws UTFDataFormatException * if the bytes read cannot be decoded into a character string. * @see #writeUTF(String) */ public final String readUTF() throws IOException { int utfSize = readUnsignedShort(); if (utfSize == 0) { return ""; } byte[] buf = new byte[utfSize]; if (read(buf, 0, buf.length) != buf.length) { throw new EOFException(); } return ModifiedUtf8.decode(buf, new char[utfSize], 0, utfSize); }
@Override public int readUnsignedShort() throws IOException { try { return getRaf().readUnsignedShort(); } catch (IOException ioe) { handleException(); throw ioe; } }
/** * Read an unsigned short. * * @return An unsigned short. * @throws IOException If there is an error reading the data. * @see RandomAccessFile#readUnsignedShort() */ @Override public int readUnsignedShort() throws IOException { return raf.readUnsignedShort(); }
public int readUnsignedShort() throws IOException { return delegate.readUnsignedShort(); }
/** Creates new CoverageFormat1 */ protected CoverageFormat1(RandomAccessFile raf) throws IOException { glyphCount = raf.readUnsignedShort(); glyphIds = new int[glyphCount]; for (int i = 0; i < glyphCount; i++) { glyphIds[i] = raf.readUnsignedShort(); } }
protected final int readLittleUShort() throws IOException { final int i = raf.readUnsignedShort(); return( (i >> 8) | ((i & 0xFF) << 8) ); }
/** Creates new LangSys */ protected LangSys(RandomAccessFile raf) throws IOException { lookupOrder = raf.readUnsignedShort(); reqFeatureIndex = raf.readUnsignedShort(); featureCount = raf.readUnsignedShort(); featureIndex = new int[featureCount]; for (int i = 0; i < featureCount; i++) { featureIndex[i] = raf.readUnsignedShort(); } }
/** Creates new Feature */ protected Feature(RandomAccessFile raf, int offset) throws IOException { raf.seek(offset); featureParams = raf.readUnsignedShort(); lookupCount = raf.readUnsignedShort(); lookupListIndex = new int[lookupCount]; for (int i = 0; i < lookupCount; i++) { lookupListIndex[i] = raf.readUnsignedShort(); } }
protected CmapIndexEntry(RandomAccessFile raf) throws IOException { platformId = raf.readUnsignedShort(); encodingId = raf.readUnsignedShort(); offset = raf.readInt(); }
/** Creates new KernSubtableFormat0 */ protected KernSubtableFormat0(RandomAccessFile raf) throws IOException { nPairs = raf.readUnsignedShort(); searchRange = raf.readUnsignedShort(); entrySelector = raf.readUnsignedShort(); rangeShift = raf.readUnsignedShort(); kerningPairs = new KerningPair[nPairs]; for (int i = 0; i < nPairs; i++) { kerningPairs[i] = new KerningPair(raf); } }
/** Creates new SingleSubstFormat2 */ protected SingleSubstFormat2(RandomAccessFile raf, int offset) throws IOException { coverageOffset = raf.readUnsignedShort(); glyphCount = raf.readUnsignedShort(); substitutes = new int[glyphCount]; for (int i = 0; i < glyphCount; i++) { substitutes[i] = raf.readUnsignedShort(); } raf.seek(offset + coverageOffset); coverage = Coverage.read(raf); }
/** Creates new CoverageFormat2 */ protected CoverageFormat2(RandomAccessFile raf) throws IOException { rangeCount = raf.readUnsignedShort(); rangeRecords = new RangeRecord[rangeCount]; for (int i = 0; i < rangeCount; i++) { rangeRecords[i] = new RangeRecord(raf); } }
@Override public int readUnsignedShort(long offset) { checkRead(offset, SHORT); try { seekToOffset(offset); return randomAccessFile.readUnsignedShort(); } catch (IOException e) { throw new RuntimeException(e); } }
protected static ClassDef read(final RandomAccessFile raf) throws IOException { ClassDef c = null; final int format = raf.readUnsignedShort(); if (format == 1) { c = new ClassDefFormat1(raf); } else if (format == 2) { c = new ClassDefFormat2(raf); } return c; } }
protected static Coverage read(RandomAccessFile raf) throws IOException { Coverage c = null; int format = raf.readUnsignedShort(); if (format == 1) { c = new CoverageFormat1(raf); } else if (format == 2) { c = new CoverageFormat2(raf); } return c; }
protected static ClassDef read(RandomAccessFile raf) throws IOException { ClassDef c = null; int format = raf.readUnsignedShort(); if (format == 1) { c = new ClassDefFormat1(raf); } else if (format == 2) { c = new ClassDefFormat2(raf); } return c; } }