protected void fireChange(Feature feature, int type) { fireChange(new Feature[] {feature}, type); }
protected void fireChange(SimpleFeature feature, int type) { fireChange(new SimpleFeature[] {feature}, type); }
public void remove() { iterator.remove(); fireChange(currFeature, CollectionEvent.FEATURES_REMOVED); } };
public void remove() { iterator.remove(); fireChange(currFeature, CollectionEvent.FEATURES_REMOVED); } };
protected void fireChange(Collection coll, int type) { Feature[] features = new Feature[coll.size()]; features = (Feature[]) coll.toArray(features); fireChange(features, type); }
protected void fireChange(Collection coll, int type) { SimpleFeature[] features = new SimpleFeature[coll.size()]; features = (SimpleFeature[]) coll.toArray(features); fireChange(features, type); }
/** * Removes all of the elements from this collection (optional operation). * This collection will be empty after this method returns unless it * throws an exception. */ public void clear() { if(contents.isEmpty() ) return; SimpleFeature[] oldFeatures = new SimpleFeature[contents.size()]; oldFeatures = (SimpleFeature[]) contents.values().toArray(oldFeatures); contents.clear(); fireChange(oldFeatures, CollectionEvent.FEATURES_REMOVED); }
/** * Removes all of the elements from this collection (optional operation). * This collection will be empty after this method returns unless it * throws an exception. */ public void clear() { if(contents.isEmpty() ) return; Feature[] oldFeatures = new Feature[contents.size()]; oldFeatures = (Feature[]) contents.values().toArray(oldFeatures); contents.clear(); fireChange(oldFeatures, CollectionEvent.FEATURES_REMOVED); }
/** * Removes a single instance of the specified element from this collection, * if it is present (optional operation). More formally, removes an * element <tt>e</tt> such that <tt>(o==null ? e==null : * o.equals(e))</tt>, if this collection contains one or more such * elements. Returns true if this collection contained the specified * element (or equivalently, if this collection changed as a result of the * call). * * @param o element to be removed from this collection, if present. * * @return <tt>true</tt> if this collection changed as a result of the call */ public boolean remove(Object o) { if( !(o instanceof SimpleFeature)) return false; SimpleFeature f = (SimpleFeature) o; boolean changed = contents.values().remove(f); if (changed) { fireChange(f, CollectionEvent.FEATURES_REMOVED); } return changed; }
/** * Removes a single instance of the specified element from this collection, * if it is present (optional operation). More formally, removes an * element <tt>e</tt> such that <tt>(o==null ? e==null : * o.equals(e))</tt>, if this collection contains one or more such * elements. Returns true if this collection contained the specified * element (or equivalently, if this collection changed as a result of the * call). * * @param o element to be removed from this collection, if present. * * @return <tt>true</tt> if this collection changed as a result of the call */ public boolean remove(Object o) { if( !(o instanceof Feature)) return false; Feature f = (Feature) o; boolean changed = contents.values().remove(f); if (changed) { fireChange(f, CollectionEvent.FEATURES_REMOVED); } return changed; }
public void setAttribute(int position, Object val) throws IllegalAttributeException, ArrayIndexOutOfBoundsException { if(position == 0 && val instanceof List){ List nw = (List)val; if( !FeatureState.isFeatures( nw )) return; contents.clear(); for( Iterator i = nw.iterator(); i.hasNext(); ){ Feature feature = (Feature) i.next(); contents.put( feature.getID(), feature ); } fireChange(nw,0); } }
fireChange(removedFeatures, CollectionEvent.FEATURES_REMOVED);
fireChange(removedFeatures, CollectionEvent.FEATURES_REMOVED);
fireChange(removedFeatures, CollectionEvent.FEATURES_REMOVED);
fireChange(removedFeatures, CollectionEvent.FEATURES_REMOVED);
fireChange(featuresAdded, CollectionEvent.FEATURES_ADDED);
fireChange(featuresAdded, CollectionEvent.FEATURES_ADDED);
public boolean addAll(FeatureCollection collection) { //TODO check inheritance with FeatureType here!!! boolean changed = false; Iterator iterator = collection.iterator(); try { List featuresAdded = new ArrayList(collection.size()); while (iterator.hasNext()) { SimpleFeature f = (SimpleFeature) iterator.next(); boolean added = add(f,false); changed |= added; if(added) featuresAdded.add(f); } if (changed) { fireChange(featuresAdded, CollectionEvent.FEATURES_ADDED); } return changed; } finally { collection.close( iterator ); } }
protected boolean add(Feature feature, boolean fire) { // This cast is neccessary to keep with the contract of Set! if( feature == null ) return false; // cannot add null! final String ID = feature.getID(); if( ID == null ) return false; // ID is required! if( contents.containsKey( ID ) ) return false; // feature all ready present if ( childType==null ){ childType=feature.getFeatureType(); }else{ if( !feature.getFeatureType().equals(childType) ) Logging.getLogger("org.geotools.feature.collections").warning("Feature Collection contains a heterogeneous" + " mix of features"); } //TODO check inheritance with FeatureType here!!! contents.put( ID, feature ); if(fire) { fireChange(feature, CollectionEvent.FEATURES_ADDED); } return true; }
protected boolean add(SimpleFeature feature, boolean fire) { // This cast is neccessary to keep with the contract of Set! if( feature == null ) return false; // cannot add null! final String ID = feature.getID(); if( ID == null ) return false; // ID is required! if( contents.containsKey( ID ) ) return false; // feature all ready present if( this.schema == null ) { this.schema = feature.getFeatureType(); } SimpleFeatureType childType = (SimpleFeatureType) getSchema(); // if ( childType==null ){ // //this.childType= // }else{ if( !feature.getFeatureType().equals(childType) ) LOGGER.warning("Feature Collection contains a heterogeneous" + " mix of features"); // } //TODO check inheritance with FeatureType here!!! contents.put( ID, feature ); if(fire) { fireChange(feature, CollectionEvent.FEATURES_ADDED); } return true; }