Codota Logo
FeatureWriter.hasNext
Code IndexAdd Codota to your IDE (free)

How to use
hasNext
method
in
org.geotools.data.FeatureWriter

Best Java code snippets using org.geotools.data.FeatureWriter.hasNext (Showing top 20 results out of 315)

  • Common ways to obtain FeatureWriter
private void myMethod () {
FeatureWriter f =
  • Codota IconDataStore dataStore;String typeName;Transaction transaction;dataStore.getFeatureWriterAppend(typeName, transaction)
  • Codota IconDataStore dataStore;String str;Transaction transaction;dataStore.getFeatureWriter(str, transaction)
  • Codota IconPropertyDataStore propertyDataStore;String typeName;new PropertyFeatureWriter(propertyDataStore, typeName)
  • Smart code suggestions by Codota
}
origin: geoserver/geoserver

public boolean hasNext() throws IOException {
  return delegate.hasNext();
}
origin: geotools/geotools

/**
 * Query for more content.
 *
 * @see org.geotools.data.FeatureWriter#hasNext()
 */
public boolean hasNext() throws IOException {
  if (writer == null) {
    return false;
  }
  return writer.hasNext();
}
origin: geotools/geotools

public boolean hasNext() throws IOException {
  live = null;
  return writer.hasNext();
}
origin: geotools/geotools

@Override
public boolean hasNext() throws IOException {
  return w.hasNext();
}
origin: geotools/geotools

public boolean hasNext() throws IOException {
  return writer.hasNext();
}
origin: geotools/geotools

  /** Counts the number of Features in the specified writer. This method will close the writer. */
  protected int count(FeatureWriter<SimpleFeatureType, SimpleFeature> writer)
      throws NoSuchElementException, IOException {
    int count = 0;

    try {
      while (writer.hasNext()) {
        writer.next();
        count++;
      }
    } finally {
      writer.close();
    }

    return count;
  }
}
origin: geotools/geotools

/**
 * Utility method that ensures we are going to write only in append mode
 *
 * @return
 * @throws IOException
 */
private FeatureWriter<SimpleFeatureType, SimpleFeature> getWriterAppend() throws IOException {
  FeatureWriter<SimpleFeatureType, SimpleFeature> writer =
      getWriter(Filter.INCLUDE, WRITER_ADD);
  while (writer.hasNext()) {
    writer.next();
  }
  return writer;
}
origin: geotools/geotools

/** Counts the number of Features in the specified writer. This method will close the writer. */
protected int count(FeatureWriter<SimpleFeatureType, SimpleFeature> writer)
    throws NoSuchElementException, IOException, IllegalAttributeException {
  int count = 0;
  try {
    while (writer.hasNext()) {
      writer.next();
      count++;
    }
  } finally {
    writer.close();
  }
  return count;
}
origin: geotools/geotools

public void testGetFeaturesWriterAdd() throws IOException {
  FeatureWriter<SimpleFeatureType, SimpleFeature> writer =
      data.getFeatureWriter("road", Transaction.AUTO_COMMIT);
  SimpleFeature feature;
  while (writer.hasNext()) {
    feature = (SimpleFeature) writer.next();
  }
  assertFalse(writer.hasNext());
  feature = (SimpleFeature) writer.next();
  feature.setAttributes(newRoad.getAttributes());
  writer.write();
  assertFalse(writer.hasNext());
  assertEquals(roadFeatures.length + 1, data.entry("road").getMemory().size());
}
origin: geotools/geotools

public void testGetFeatureWriterRemove() throws IOException {
  FeatureWriter<SimpleFeatureType, SimpleFeature> writer =
      data.getFeatureWriter("road", Transaction.AUTO_COMMIT);
  SimpleFeature feature;
  while (writer.hasNext()) {
    feature = writer.next();
    if (feature.getID().equals("road.rd1")) {
      writer.remove();
    }
  }
  assertEquals(roadFeatures.length - 1, data.entry("road").getMemory().size());
}
origin: geotools/geotools

public void testGetFeaturesWriterAdd() throws IOException {
  try (FeatureWriter<SimpleFeatureType, SimpleFeature> writer =
      dataStore.getFeatureWriter(tname("road"), Transaction.AUTO_COMMIT)) {
    SimpleFeature feature;
    while (writer.hasNext()) {
      feature = (SimpleFeature) writer.next();
    }
    assertFalse(writer.hasNext());
    feature = (SimpleFeature) writer.next();
    feature.setAttributes(td.newRoad.getAttributes());
    writer.write();
    assertFalse(writer.hasNext());
    assertEquals(td.roadFeatures.length + 1, count(tname("road")));
  }
}
origin: geotools/geotools

public void testGetFeaturesWriterModify() throws IOException {
  FeatureWriter<SimpleFeatureType, SimpleFeature> writer =
      data.getFeatureWriter("road", Transaction.AUTO_COMMIT);
  SimpleFeature feature;
  while (writer.hasNext()) {
    feature = writer.next();
    if (feature.getID().equals("road.rd1")) {
      feature.setAttribute("name", "changed");
      writer.write();
    }
  }
  feature = data.entry("road").getMemory().get("road.rd1");
  assertEquals("changed", feature.getAttribute("name"));
}
origin: geotools/geotools

public void testGetFeatureWriter() throws NoSuchElementException, IOException {
  FeatureWriter<SimpleFeatureType, SimpleFeature> writer =
      data.getFeatureWriter("road", Transaction.AUTO_COMMIT);
  assertEquals(roadFeatures.length, count(writer));
  assertFalse(writer.hasNext());
  try {
    writer.next();
    fail("Should not be able to use a closed writer");
  } catch (IOException expected) {
  }
}
origin: geotools/geotools

public void testGetFeatureWriterRemove() throws IOException {
  try (FeatureWriter<SimpleFeatureType, SimpleFeature> writer = writer(tname("road"))) {
    SimpleFeature feature;
    while (writer.hasNext()) {
      feature = (SimpleFeature) writer.next();
      if (feature.getID().equals(td.roadFeatures[0].getID())) {
        writer.remove();
      }
    }
  }
  assertEquals(td.roadFeatures.length - 1, count(tname("road")));
}
origin: geotools/geotools

public void testGetFeatureWriterRemoveAll() throws IOException {
  try (FeatureWriter<SimpleFeatureType, SimpleFeature> writer = writer(tname("road"))) {
    SimpleFeature feature;
    while (writer.hasNext()) {
      feature = (SimpleFeature) writer.next();
      writer.remove();
    }
  }
  assertEquals(0, count(tname("road")));
}
origin: geotools/geotools

public void testModifyFeatures() throws Exception {
  try (FeatureWriter<SimpleFeatureType, SimpleFeature> w =
      dataStore.getFeatureWriter(tname("guid"), Transaction.AUTO_COMMIT)) {
    w.hasNext();
    SimpleFeature f = w.next();
    f.setAttribute(aname("uuidProperty"), uuid2);
    assertEquals(uuid2, f.getAttribute(aname("uuidProperty")));
    w.write();
  }
}
origin: geotools/geotools

public void testGetFeatureWriterClose() throws Exception {
  try (FeatureWriter<SimpleFeatureType, SimpleFeature> writer =
      dataStore.getFeatureWriter(
          tname("road"), Filter.INCLUDE, Transaction.AUTO_COMMIT)) {
    writer.close();
    try {
      assertFalse(writer.hasNext());
      fail("Should not be able to use a closed writer");
    } catch (Exception expected) {
    }
    try {
      assertNull(writer.next());
      fail("Should not be able to use a closed writer");
    } catch (Exception expected) {
    }
  }
}
origin: geotools/geotools

public void testGetFeaturesWriterModify() throws IOException {
  try (FeatureWriter<SimpleFeatureType, SimpleFeature> writer = writer(tname("road"))) {
    while (writer.hasNext()) {
      SimpleFeature feature = (SimpleFeature) writer.next();
      if (feature.getID().equals(td.roadFeatures[0].getID())) {
        feature.setAttribute(aname("name"), "changed");
        writer.write();
      }
    }
  }
  SimpleFeature feature = (SimpleFeature) feature(tname("road"), td.roadFeatures[0].getID());
  assertNotNull(feature);
  assertEquals("changed", feature.getAttribute(aname("name")));
}
origin: geotools/geotools

public void testWrite() throws Exception {
  int count = dataStore.getFeatureSource(tname("udt")).getCount(Query.ALL);
  try (FeatureWriter w =
      dataStore.getFeatureWriterAppend(tname("udt"), Transaction.AUTO_COMMIT)) {
    w.hasNext();
    SimpleFeature f = (SimpleFeature) w.next();
    f.setAttribute(aname("ut"), "abcd");
    try {
      w.write();
      fail("Write should have failed with UDT constraint failure");
    } catch (Exception e) {
    }
    f.setAttribute(aname("ut"), "34cd");
    w.write();
  }
  assertEquals(count + 1, dataStore.getFeatureSource(tname("udt")).getCount(Query.ALL));
}
origin: geotools/geotools

public void testGetFeatureWriterWithFilter() throws IOException {
  FilterFactory ff = dataStore.getFilterFactory();
  Filter f = ff.equals(ff.property(aname("intProperty")), ff.literal(100));
  SimpleFeatureCollection features = dataStore.getFeatureSource(tname("ft1")).getFeatures(f);
  assertEquals(0, features.size());
  f = ff.equals(ff.property(aname("intProperty")), ff.literal(1));
  try (FeatureWriter<SimpleFeatureType, SimpleFeature> writer =
      dataStore.getFeatureWriter(tname("ft1"), f, Transaction.AUTO_COMMIT)) {
    while (writer.hasNext()) {
      SimpleFeature feature = writer.next();
      feature.setAttribute(aname("intProperty"), Integer.valueOf(100));
      writer.write();
    }
  }
  f = ff.equals(ff.property(aname("intProperty")), ff.literal(100));
  features = dataStore.getFeatureSource(tname("ft1")).getFeatures(f);
  assertEquals(1, features.size());
}
org.geotools.dataFeatureWriterhasNext

Javadoc

Query whether this FeatureWriter has another Feature.

Please note: it is more efficient to construct your FeatureWriter with a Filer (to skip entries you do not want), than to force the creation of entire Features only to skip over them.

FeatureWriters that support append operations will allow calls to next, even when hasNext() returns false.

Popular methods of FeatureWriter

  • next
  • write
    Wrties the current Feature, must be called before hasNext. FeautreWriters will need to allow Feature
  • close
    Release the underlying resources.
  • remove
    Removes current Feature, must be called before hasNext. FeatureWriters will need to allow all Featur
  • getFeatureType

Popular in Java

  • Making http requests using okhttp
  • setContentView (Activity)
  • putExtra (Intent)
  • startActivity (Activity)
  • InputStreamReader (java.io)
    An InputStreamReader is a bridge from byte streams to character streams: It reads bytes and decodes
  • InetAddress (java.net)
    This class represents an Internet Protocol (IP) address. An IP address is either a 32-bit or 128-bit
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate(i
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • JList (javax.swing)
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now