/** * Adds the specified object to the store. * * @param data * The object to be added. * @return The offset within the output file of the object written. */ public long add(T data) { long objectFileOffset; initializeAddStage(); objectFileOffset = offsetTrackingStream.getByteCount(); // Write the object to the store. objectWriter.writeObject(data); return objectFileOffset; }
/** * Adds the specified object to the store. * * @param data * The object to be added. * @return The offset within the output file of the object written. */ public long add(T data) { long objectFileOffset; initializeAddStage(); objectFileOffset = offsetTrackingStream.getByteCount(); // Write the object to the store. objectWriter.writeObject(data); return objectFileOffset; }
/** * {@inheritDoc} */ @Override public void complete() { // If we're already in the reading stage, we don't need to perform a // complete. if (stage.compareTo(StorageStage.Reading) != 0) { // We need to make sure we pass through the add stage to ensure an // output file is created. initializeAddStage(); try { offsetTrackingStream.close(); offsetTrackingStream = null; } catch (IOException e) { throw new OsmosisRuntimeException("Unable to close the file " + storageFile + "."); } stage = StorageStage.Reading; } }
/** * {@inheritDoc} */ @Override public void complete() { // If we're already in the reading stage, we don't need to perform a // complete. if (stage.compareTo(StorageStage.Reading) != 0) { // We need to make sure we pass through the add stage to ensure an // output file is created. initializeAddStage(); try { offsetTrackingStream.close(); offsetTrackingStream = null; } catch (IOException e) { throw new OsmosisRuntimeException("Unable to close the file " + storageFile + "."); } stage = StorageStage.Reading; } }