private void initializeAddStage() { // We can't add if we've passed the add stage. if (stage.compareTo(StorageStage.Add) > 0) { throw new OsmosisRuntimeException("Cannot add to storage in stage " + stage + "."); } // If we're not up to the add stage, initialise for adding. if (stage.compareTo(StorageStage.Add) < 0) { try { nodeStorageFile = File.createTempFile("nodelatlon", null); fileOutStream = new FileOutputStream(nodeStorageFile); dataOutStream = new DataOutputStream(new BufferedOutputStream(fileOutStream, 65536)); currentFileOffset = 0; stage = StorageStage.Add; } catch (IOException e) { throw new OsmosisRuntimeException( "Unable to create object stream writing to temporary file " + nodeStorageFile + ".", e); } } }
/** * Configures the state of this object instance for reading mode. If the * current state doesn't allow reading, an exception will be thrown. */ private void initializeReadingStage() { // If we're already in the reading stage there's nothing to do. if (stage.equals(StorageStage.Reading)) { return; } if (stage.equals(StorageStage.Add)) { throw new OsmosisRuntimeException( "Cannot begin reading in " + StorageStage.Add + " stage, must call complete first."); } // If we haven't reached the reading stage yet, configure for output // first to ensure a file is available for reading. if (stage.compareTo(StorageStage.Reading) < 0) { stage = StorageStage.Reading; } // If we've passed the reading stage, we can't continue. if (stage.compareTo(StorageStage.Reading) > 0) { throw new OsmosisRuntimeException("Cannot read from storage once we've reached stage " + stage + "."); } }
/** * Configures the state of this object instance for reading mode. If the * current state doesn't allow reading, an exception will be thrown. */ private void initializeReadingStage() { // If we're already in the reading stage there's nothing to do. if (stage.equals(StorageStage.Reading)) { return; } if (stage.equals(StorageStage.Add)) { throw new OsmosisRuntimeException( "Cannot begin reading in " + StorageStage.Add + " stage, must call complete first."); } // If we haven't reached the reading stage yet, configure for output // first to ensure a file is available for reading. if (stage.compareTo(StorageStage.Reading) < 0) { stage = StorageStage.Reading; } // If we've passed the reading stage, we can't continue. if (stage.compareTo(StorageStage.Reading) > 0) { throw new OsmosisRuntimeException("Cannot read from storage once we've reached stage " + stage + "."); } }
private void initializeAddStage() { // We can't add if we've passed the add stage. if (stage.compareTo(StorageStage.Add) > 0) { throw new OsmosisRuntimeException("Cannot add to storage in stage " + stage + "."); } // If we're not up to the add stage, initialise for adding. if (stage.compareTo(StorageStage.Add) < 0) { try { nodeStorageFile = File.createTempFile("nodelatlon", null); fileOutStream = new FileOutputStream(nodeStorageFile); dataOutStream = new DataOutputStream(new BufferedOutputStream(fileOutStream, 65536)); currentFileOffset = 0; stage = StorageStage.Add; } catch (IOException e) { throw new OsmosisRuntimeException( "Unable to create object stream writing to temporary file " + nodeStorageFile + ".", e); } } }
private void initializeReadingStage() { if (stage.compareTo(StorageStage.Reading) == 0) { return; if (stage.compareTo(StorageStage.Released) >= 0) { throw new OsmosisRuntimeException("Cannot read from node storage in stage " + stage + "."); if (stage.compareTo(StorageStage.NotStarted) <= 0) { initializeAddStage(); if (stage.compareTo(StorageStage.Add) == 0) { try { dataOutStream.close();
private void initializeReadingStage() { if (stage.compareTo(StorageStage.Reading) == 0) { return; if (stage.compareTo(StorageStage.Released) >= 0) { throw new OsmosisRuntimeException("Cannot read from node storage in stage " + stage + "."); if (stage.compareTo(StorageStage.NotStarted) <= 0) { initializeAddStage(); if (stage.compareTo(StorageStage.Add) == 0) { try { dataOutStream.close();
if (stage.compareTo(StorageStage.Add) != 0) { throw new OsmosisRuntimeException("Cannot create interval in stage " + stage + ".");
if (stage.compareTo(StorageStage.Add) != 0) { throw new OsmosisRuntimeException("Cannot create interval in stage " + stage + ".");
/** * {@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; } }