public void openAppend() { if (!datafile.hasLock()) { throw new RuntimeException( PrintTools.sprintf("Should lock file before append %s", datafile.getName())); } datafile.openAppend(); }
protected static void out(String s, Object... args) throws IOException { if (out == null) { systemout.println(sprintf(s, args)); } else { out.printf(s + "\n", args); out.flush(); } }
public static void print(String s) throws IOException { if (out == null) { systemout.println(s); } else { out.printf(s + "\n"); out.flush(); } }
public boolean findFirstRecord() { if (getOffset() == 0 && getOffset() < getCeiling()) { return true; } ByteSearchPosition matchPos = datafile.matchPos(root.section); if (matchPos.found()) { datafile.movePast(matchPos); return getOffset() < getCeiling(); } return false; }
public void openWrite() { checkFirstUse(); if (root.writeenabled() && datafile != null) { datafile.openWrite(); if (hasHeader) { root.writeHeader(); } } }
public void openRead() { checkFirstUse(); if (datafile != null) { if (reader == null) { reader = datafile.rwbuffer; } datafile.openRead(); if (hasHeader) { ByteSearchSection section = reader.readSectionStart(root.section); if (section.notEmpty()) { root.readHeader(section); reader.movePast(section); } } } }
public boolean hasMore() { return datafile.hasMore(); }
public void setBufferSize(int buffersize) { datafile.setBufferSize(buffersize); }
public void setOffset(long offset) { datafile.setOffset(offset); }
public void setCeiling(long ceiling) { datafile.setCeiling(ceiling); }
public long getCeiling() { return datafile.getCeiling(); }
public void closeWrite() { if (datafile != null) { datafile.closeWrite(); } }
public void unlock() { datafile.unlock(); }
public boolean lock() { return datafile.lock(); }
public boolean exists() { return datafile.existsDir(); }
public void delete() { datafile.delete(); }
public long getLength() { return datafile.getLength(); }
public void resetStart() { if (datafile != null) { datafile.resetStart(); } }
public long getOffset() { return datafile.getOffset(); }
public void closeRead() { if (datafile != null) { datafile.closeRead(); } }