@Override public void finish() { if (localIterator != null) localIterator.close(); }
@Override public void close() { origIter.close(); finishCalcBounds(); }
@Override public void close() { if (finished) return; if (pfiter != null) pfiter.close(); // collectionIter.close(); finishCalcBounds(); finished = true; }
@Override public void close() { if (finished) { return; } // If hasNext() was repeatedly called until it returned "false", all PointFeatureIterators should've // already been closed. However, this may be useful in exceptional circumstances. if (pfIter != null) { pfIter.close(); } finishCalcBounds(); finished = true; } }
@Override public void close() { if (finished) return; if (pfIter != null) pfIter.close(); finishCalcBounds(); if (currentDataset != null) try { currentDataset.close(); } catch (IOException e) { throw new RuntimeException(e); } finished = true; } }
public static int write(PointFeatureCollection pointFeatCol, File outFile) throws IOException { String name = outFile.getCanonicalPath(); String timeUnitString = pointFeatCol.getTimeUnit().getUdUnit(); String altUnits = pointFeatCol.getAltUnits(); PointFeatureIterator pointFeatIter = pointFeatCol.getPointFeatureIterator(); try (BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(outFile))) { return write(out, pointFeatIter, name, timeUnitString, altUnits); } finally { pointFeatIter.close(); } }
@Override public void close() { if (finished) return; if (pfIter != null) pfIter.close(); finishCalcBounds(); if (currentDataset != null) try { currentDataset.close(); if (CompositeDatasetFactory.debug) System.out.printf("CompositeStationCollectionFlattened close dataset: %s%n", currentDataset.getLocation()); } catch (IOException e) { throw new RuntimeException(e); } finished = true; } }
@Override public void close() { if (finished) return; if (pfIter != null) pfIter.close(); if (currentDataset != null) try { currentDataset.close(); if (CompositeDatasetFactory.debug) System.out.printf("CompositeStationFeatureIterator close dataset: %s%n", currentDataset.getLocation()); } catch (IOException e) { throw new RuntimeException(e); } finishCalcBounds(); finished = true; } }
@Override public boolean hasNext() { try { if (pfIter == null) { pfIter = getNextIterator(); if (pfIter == null) { close(); return false; } } if (!pfIter.hasNext()) { pfIter.close(); if (CompositeDatasetFactory.debug) System.out.printf("CompositePointFeatureIterator open dataset %s%n", currentDataset.getLocation()); currentDataset.close(); pfIter = getNextIterator(); return hasNext(); } return true; } catch (IOException ioe) { throw new RuntimeException(ioe); } }
@Override public boolean hasNext() { try { if (pfIter == null) { pfIter = getNextIterator(); if (pfIter == null) { close(); return false; } } if (!pfIter.hasNext()) { pfIter.close(); currentDataset.close(); if (CompositeDatasetFactory.debug) System.out.printf("CompositeStationCollectionFlattened.Iterator close dataset: %s%n", currentDataset.getLocation()); pfIter = getNextIterator(); return hasNext(); } return true; } catch (IOException ioe) { throw new RuntimeException(ioe); } }
@Override public boolean hasNext() { try { if (pfIter == null) { pfIter = getNextIterator(); if (pfIter == null) { close(); return false; } } if (!pfIter.hasNext()) { pfIter.close(); currentDataset.close(); if (CompositeDatasetFactory.debug) System.out.printf("CompositeStationFeatureIterator close dataset: %s%n", currentDataset.getLocation()); pfIter = getNextIterator(); return hasNext(); } return true; } catch (IOException ioe) { throw new RuntimeException(ioe); } }
/** * Attempts to find a PointFeatureIterator in the currently-loaded DsgFeatureCollection that has another * available element (i.e. {@code hasNext() == true}). Such an iterator may already be loaded into * {@code pfIter}. If not, we'll have to look through {@code pfcIter} and/or {@code pfccIter} to find one. * <p> * That iterator, if it's found, will be assigned to {@code pfIter} and this method will return {@code true}. * Otherwise, it'll return {@code false}, meaning that there are no more unread PointFeatures available in the * currently-loaded DsgFeatureCollection. * * @return {@code true} if {@code pfIter.hasNext()} will now return {@code true}. * @throws IOException if an I/O error occurs. */ private boolean pfIterHasNext() throws IOException { if (pfIter != null) { if (pfIter.hasNext()) { return true; } else { // We'll need to load a new PointFeatureIterator below. But first, close the old one. pfIter.close(); } } while (pfcIterHasNext()) { this.pfIter = pfcIter.next().getPointFeatureIterator(); if (pfIter.hasNext()) { return true; } // else: Iterator could be empty, in which case we proceed to the next loop iteration. } return false; }
public static boolean equals(PointFeatureIterator iter1, PointFeatureIterator iter2) throws IOException { if (iter1 == iter2) { return true; } else if (iter1 == null || iter2 == null) { return false; } try { while (iter1.hasNext() && iter2.hasNext()) { if (!equals(iter1.next(), iter2.next())) { return false; } } return !(iter1.hasNext() || iter2.hasNext()); } finally { iter1.close(); iter2.close(); } }