/** Read four input bytes and return an int value. */ @Override public int readInt() throws IOException { return raf.readInt(); }
/** Read four input bytes and return an int value. */ @Override public int readInt() throws IOException { return raf.readInt(); }
/** Read four input bytes and return an int value. */ @Override public int readInt() throws IOException { return raf.readInt(); }
/** Read four input bytes and return an int value. */ @Override public int readInt() throws IOException { return raf.readInt(); }
/** * Parse a string from the IM3 file at the current file pointer loc * * @param is stream to read from * @return parsed string or null for string of zero length * @throws IOException */ static protected String parseString(IRandomAccess is) throws IOException { final int nameLength = is.readInt(); if (nameLength == 0) return EMPTY_STRING; final byte [] buf = new byte [nameLength]; is.read(buf); return new String(buf, loci.common.Constants.ENCODING); }
/** * Parse a string from the IM3 file at the current file pointer loc * * @param is stream to read from * @return parsed string or null for string of zero length * @throws IOException */ static protected String parseString(IRandomAccess is) throws IOException { final int nameLength = is.readInt(); if (nameLength == 0) return EMPTY_STRING; final byte [] buf = new byte [nameLength]; is.read(buf); return new String(buf, loci.common.Constants.ENCODING); }
/** * Get the # of floating-point values in this record * * @return number of integer values contained in the record * @throws IOException */ public int getNumEntries(IRandomAccess is) throws IOException { long oldPos = is.getFilePointer(); try { is.seek(offset); if (is.readInt() == 0) return 1; return is.readInt(); } finally { is.seek(oldPos); } }
/** * Get the # of floating-point values in this record * * @return number of integer values contained in the record * @throws IOException */ public int getNumEntries(IRandomAccess is) throws IOException { long oldPos = is.getFilePointer(); try { is.seek(offset); if (is.readInt() == 0) return 1; return is.readInt(); } finally { is.seek(oldPos); } }
/** * Get the integer value at the given index * * @param is the stream for the IM3 file * @param index the zero-based index of the entry to retrieve * @return the value stored in the indexed slot of the record * @throws IOException */ public int getEntry(IRandomAccess is, int index) throws IOException { long oldPos = is.getFilePointer(); try { is.seek(offset); if (is.readInt() == 0) return is.readInt(); is.seek(offset+index*4+8); return is.readInt(); } finally { is.seek(oldPos); } } /* (non-Javadoc)
/** * Get the # of integer values in this record * @param is * * @return number of integer values contained in the record * @throws IOException */ public int getNumEntries(IRandomAccess is) throws IOException { long oldPos = is.getFilePointer(); try { is.seek(offset); final int code = is.readInt(); if (code == 0) return 1; return is.readInt(); } finally { is.seek(oldPos); } }
/** * Get the # of integer values in this record * @param is * * @return number of integer values contained in the record * @throws IOException */ public int getNumEntries(IRandomAccess is) throws IOException { long oldPos = is.getFilePointer(); try { is.seek(offset); final int code = is.readInt(); if (code == 0) return 1; return is.readInt(); } finally { is.seek(oldPos); } }
/** * Get the integer value at the given index * * @param is the stream for the IM3 file * @param index the zero-based index of the entry to retrieve * @return the value stored in the indexed slot of the record * @throws IOException */ public int getEntry(IRandomAccess is, int index) throws IOException { long oldPos = is.getFilePointer(); try { is.seek(offset); if (is.readInt() == 0) return is.readInt(); is.seek(offset+index*4+8); return is.readInt(); } finally { is.seek(oldPos); } } /* (non-Javadoc)
/** * Get the # of boolean values in this record * * @return number of boolean values contained in the record * @throws IOException */ public int getNumEntries(IRandomAccess is) throws IOException { long oldPos = is.getFilePointer(); try { is.seek(offset+4); return is.readInt(); } finally { is.seek(oldPos); } }
/** * Get the # of boolean values in this record * * @return number of boolean values contained in the record * @throws IOException */ public int getNumEntries(IRandomAccess is) throws IOException { long oldPos = is.getFilePointer(); try { is.seek(offset+4); return is.readInt(); } finally { is.seek(oldPos); } }
/** * Parse an IM3 record at the current file pointer location * * @param is random access stream, pointing at the record's start * (the length-quadword of the record's tag name) * @return an IM3Record or subclass depending on the record's type * @throws IOException on file misparsing leading to overrun and other */ private static IM3Record parseRecord(IRandomAccess is) throws IOException { final String name = parseString(is); if (name == null) return null; final int recLength = is.readInt()-8; final int recType = is.readInt(); final long offset = is.getFilePointer(); is.skipBytes(recLength); switch(recType) { case REC_CONTAINER: return new ContainerRecord(name, recType, offset, recLength); case REC_STRING: return new StringIM3Record(name, recType, offset, recLength); case REC_INT: return new IntIM3Record(name, recType, offset, recLength); case REC_FLOAT: return new FloatIM3Record(name, recType, offset, recLength); case REC_BOOLEAN: return new BooleanIM3Record(name, recType, offset, recLength); } return new IM3Record(name, recType, offset, recLength); } /* (non-Javadoc)
/** * Parse an IM3 record at the current file pointer location * * @param is random access stream, pointing at the record's start * (the length-quadword of the record's tag name) * @return an IM3Record or subclass depending on the record's type * @throws IOException on file misparsing leading to overrun and other */ private static IM3Record parseRecord(IRandomAccess is) throws IOException { final String name = parseString(is); if (name == null) return null; final int recLength = is.readInt()-8; final int recType = is.readInt(); final long offset = is.getFilePointer(); is.skipBytes(recLength); switch(recType) { case REC_CONTAINER: return new ContainerRecord(name, recType, offset, recLength); case REC_STRING: return new StringIM3Record(name, recType, offset, recLength); case REC_INT: return new IntIM3Record(name, recType, offset, recLength); case REC_FLOAT: return new FloatIM3Record(name, recType, offset, recLength); case REC_BOOLEAN: return new BooleanIM3Record(name, recType, offset, recLength); } return new IM3Record(name, recType, offset, recLength); } /* (non-Javadoc)
/** * Get the floating-point value at the given index * * @param is the stream for the IM3 file * @param index the zero-based index of the entry to retrieve * @return the value stored in the indexed slot of the record * @throws IOException */ public float getEntry(IRandomAccess is, int index) throws IOException { long oldPos = is.getFilePointer(); try { is.seek(offset); if (is.readInt() == 0) return is.readFloat(); is.seek(offset+8+index*4); return is.readFloat(); } finally { is.seek(oldPos); } } /**
/** * Get the floating-point value at the given index * * @param is the stream for the IM3 file * @param index the zero-based index of the entry to retrieve * @return the value stored in the indexed slot of the record * @throws IOException */ public float getEntry(IRandomAccess is, int index) throws IOException { long oldPos = is.getFilePointer(); try { is.seek(offset); if (is.readInt() == 0) return is.readFloat(); is.seek(offset+8+index*4); return is.readFloat(); } finally { is.seek(oldPos); } } /**