public void setValue(Object value) { if ( index == -1 ) return; //fids arent settable try { feature.setAttribute( index, value ); } catch( Exception e ) { throw new RuntimeException( e ); } }
public void setValue(Object value) { if (index == -1) { return; //fids arent settable } try { feature.setAttribute(index, value); } catch (Exception e) { throw new RuntimeException(e); } }
public void setProperty(Object object, String property, Object value) { Feature feature = (Feature) object; try { feature.setAttribute(property(property), value); } catch (IllegalAttributeException e) { throw new RuntimeException(e); } }
public void setProperty(Object object, String property, Object value) { Feature feature = (Feature) object; try { feature.setAttribute( property( property ), value ); } catch (IllegalAttributeException e) { throw new RuntimeException( e ); } }
public void set(Object object, String xpath, Object value, Class target) throws IllegalAttributeException { xpath = stripPrefix(xpath); if ( object instanceof Feature ) { ((Feature) object).setAttribute( xpath, value ); } if ( object instanceof FeatureType ) { throw new IllegalAttributeException("feature type is immutable"); } } }
f.setAttribute(childName,value);
public String createID(Connection conn, Feature feature, Statement statement) throws IOException { if (feature.getAttribute(colNames[1]) == null) { try { String id = autoIncrementMapper.createID(conn, feature, statement); feature.setAttribute(colNames[1], new Long(id)); } catch (Exception e) { throw new DataSourceException("Could not generate key for the " + "unset primary key column " + colNames[1], e); } } return super.createID(conn, feature, statement); }
writer = wrapped.getFeatureWriterAppend(VersionedPostgisDataStore.TBL_CHANGESETS, t); f = writer.next(); f.setAttribute("author", author); f.setAttribute("message", message); f.setAttribute("date", new Date());
public String createID(Connection conn, Feature feature, Statement statement) throws IOException { if (colNames.length == 2 && feature.getAttribute(colNames[1]) == null) { try { feature.setAttribute(colNames[1], (new UID()).toString()); } catch (IllegalAttributeException e) { throw new DataSourceException("Could not generate key for the " + "unset primary key column " + colNames[0], e); } } return super.createID(conn, feature, statement); }
currentFeature_.setAttribute(gmlInput_.columnName(index), l); currentFeature_.setAttribute(gmlInput_.columnName(index),
private void writeOldFeature(boolean expire) throws IOException, DataSourceException { try { if(expire) oldFeature.setAttribute("expired", new Long(state.getRevision())); updateWriter.write(); } catch (IllegalAttributeException e) { throw new DataSourceException("Error writing expiration tag on old feature. " + "Should not happen, there's a bug at work.", e); } catch (FeatureLockException fle) { // we have to mangle the id here too String unversionedFid = mapper.getUnversionedFid(fle.getFeatureID()); FeatureLockException mangled = new FeatureLockException(fle.getMessage(), unversionedFid, fle.getCause()); throw mangled; } }
newFeature.setAttribute( a, values[a] );
public void testGetFeaturesWriterModify() throws IOException, IllegalAttributeException { FeatureWriter writer = data.getFeatureWriter("ROAD", Transaction.AUTO_COMMIT); Feature feature; while (writer.hasNext()) { feature = writer.next(); if (feature.getID().equals(roadFeatures[0].getID())) { feature.setAttribute("NAME", "changed"); writer.write(); } } feature = null; FeatureReader reader = data.getFeatureReader(new DefaultQuery("ROAD", rd1Filter), Transaction.AUTO_COMMIT); if (reader.hasNext()) { feature = reader.next(); } // feature = (Feature) data.features("ROAD").get("road.rd1"); assertEquals("changed", feature.getAttribute("NAME")); }
protected void modifyFeatures( AttributeType[] type, Object[] value, FeatureWriter writer ) throws DataSourceException, IOException{ Feature feature; try { while (writer.hasNext()) { feature = writer.next(); for (int i = 0; i < type.length; i++) { try { feature.setAttribute(type[i].getName(), value[i]); } catch (IllegalAttributeException e) { throw new DataSourceException( "Could not update feature " + feature.getID() + " with " + type[i].getName() + "=" + value[i], e); } } writer.write(); } } finally { writer.close(); } } /**
/** * Applies transform to all geometry attribute. * * @param feature Feature to be transformed * @param schema Schema for target transformation - transform( schema, crs ) * @param transform MathTransform used to transform coordinates - reproject( crs, crs ) * @return transformed Feature of type schema * @throws TransformException * @throws MismatchedDimensionException * @throws IllegalAttributeException */ public static Feature transform( Feature feature, FeatureType schema, MathTransform transform ) throws MismatchedDimensionException, TransformException, IllegalAttributeException { feature = schema.create(feature.getAttributes(null), feature.getID()); GeometryAttributeType geomType = schema.getDefaultGeometry(); Geometry geom = (Geometry) feature.getAttribute(geomType.getName()); geom = JTS.transform(geom, transform); try { feature.setAttribute(geomType.getName(), geom); } catch (IllegalAttributeException shouldNotHappen) { // we are expecting the transform to return the same geometry type } return feature; }
Object newValue = liveFeature.getAttribute(at.getName()); Object oldValue = oldFeature.getAttribute(at.getName()); newFeature.setAttribute(at.getName(), newValue); if (!DataUtilities.attributesEqual(newValue, oldValue)) { dirty = true; oldFeature.setAttribute(at.getName(), liveFeature.getAttribute(at.getName())); newFeature.setAttribute(at.getName(), liveFeature.getAttribute(at.getName())); newFeature.setAttribute("expired", NON_EXPIRED); newFeature.setAttribute("revision", new Long(state.getRevision())); newFeature.setAttribute("created", oldFeature.getAttribute("created")); } else { newFeature.setAttribute("created", new Long(state.getRevision())); if (oldFeature != null) { id = mapper.createVersionedFid(liveFeature.getID(), state.getRevision()); newFeature.setAttribute("created", oldFeature.getAttribute("created")); } else if (!mapper.hasAutoIncrementColumns()) { id = mapper.createID(state.getConnection(), newFeature, null); newFeature.setAttribute("created", new Long(state.getRevision())); newFeature.setAttribute(mapper.getColumnName(i), pkatts[i]);
Feature restored = fw.next(); for (int i = 0; i < original.getFeatureType().getAttributeCount(); i++) { restored.setAttribute(i, original.getAttribute(i)); restored.setAttribute("revision", new Long(revision)); restored.setAttribute("expired", new Long(Long.MAX_VALUE)); fw.write(); Feature original = fr.next(); for (int i = 0; i < original.getFeatureType().getAttributeCount(); i++) { current.setAttribute(i, original.getAttribute(i));
public void testGetFeatureReaderMutability() throws IOException, IllegalAttributeException { Query query = new DefaultQuery(roadType.getTypeName()); FeatureReader reader = data.getFeatureReader(query, Transaction.AUTO_COMMIT); Feature feature; while (reader.hasNext()) { feature = (Feature) reader.next(); feature.setAttribute("NAME", null); } reader.close(); reader = data.getFeatureReader(query, Transaction.AUTO_COMMIT); while (reader.hasNext()) { feature = (Feature) reader.next(); assertNotNull(feature.getAttribute("NAME")); } reader.close(); try { reader.next(); fail( "next should fail with an IOException or NoSuchElementException"); } catch (IOException expected) { } catch (NoSuchElementException expected) { } }
feature.setAttribute(type[i].getName(), value[i]); } catch (IllegalAttributeException e) { throw new DataSourceException(
feature.setDefaultGeometry(_zone.getGeometry(i)); for (int j = 1; j < nbAttribute; j++) { feature.setAttribute(j, _zone.getModel(attIdx.get(atts[j])).getObjectValueAt(i));