attributeDescr = property.getDescriptor();
private boolean getEncodeIfEmpty(Property p) { Object o = ((p.getDescriptor()).getUserData().get("encodeIfEmpty")); if (o == null) { return false; } return (Boolean) o; }
protected void cleanEmptyElements(Feature target) throws DataSourceException { try { ArrayList values = new ArrayList<Property>(); for (Iterator i = target.getValue().iterator(); i.hasNext(); ) { Property p = (Property) i.next(); if (hasChild(p) || p.getDescriptor().getMinOccurs() > 0 || getEncodeIfEmpty(p)) { values.add(p); } } target.setValue(values); } catch (DataSourceException e) { throw new DataSourceException("Unable to clean empty element", e); } }
values.add(o); result = true; } else if (((Property) o).getDescriptor().getMinOccurs() > 0) { if (((Property) o).getDescriptor().isNillable()) {
/** * Perform the visitation of an individual Feature. * * @param feature The Feature to explore. */ protected void walker(Feature feature) { handler.handleFeature(feature); for (Property property : feature.getProperties()) { Class<?> binding = property.getType().getBinding(); // recurse if attribute type is another collection if (FeatureCollection.class.isAssignableFrom(binding)) { walker((FeatureCollection) property.getValue()); // } else if (type instanceof FeatureType) { } else if (Feature.class.isAssignableFrom(binding)) { // recurse if attribute type is another feature walker((Feature) property.getValue()); } else { // normal handling handler.handleAttribute(property.getDescriptor(), property.getValue()); } } handler.endFeature(feature); }
/** * Perform a "deep copy" an existing feature resuling in a duplicate of any geometry attributes. * * <p>This method is scary, expensive and will result in a deep copy of Geometry which may take * a significant amount of memory/time to perform. * * @param original Content * @return copy */ public static SimpleFeature deep(SimpleFeature original) { if (original == null) return null; SimpleFeatureBuilder builder = new SimpleFeatureBuilder(original.getFeatureType()); for (Property property : original.getProperties()) { Object value = property.getValue(); try { Object copy = value; if (value instanceof Geometry) { Geometry geometry = (Geometry) value; copy = geometry.copy(); } builder.set(property.getName(), copy); } catch (Exception e) { throw new IllegalAttributeException( (AttributeDescriptor) property.getDescriptor(), value, e); } } return builder.buildFeature(original.getID()); }
private boolean getEncodeIfEmpty(Property p) { Object o = ((p.getDescriptor()).getUserData().get("encodeIfEmpty")); if (o == null) { return false; } return (Boolean) o; } }
public Object evaluate(Object object) { Feature feature = (Feature) object; List<Object> list = new ArrayList<Object>(feature.getProperties().size()); for (Property p : feature.getProperties()) { if (p.getDescriptor().getType() == CSWRecordDescriptor.SIMPLE_LITERAL) { Object value = ((ComplexAttribute) p).getProperty("value").getValue(); list.add(value); } } return list; }
public Object evaluate(Object object) { Feature feature = (Feature) object; List<Object> list = new ArrayList<Object>(feature.getProperties().size()); for (Property p : feature.getProperties()) { if (p.getDescriptor().getType() == CSWRecordDescriptor.SIMPLE_LITERAL) { Object value = ((ComplexAttribute) p).getProperty("value").getValue(); list.add(value); } } return list; }
protected void cleanEmptyElements(Feature target) throws DataSourceException { try { ArrayList values = new ArrayList<Property>(); for (Iterator i = target.getValue().iterator(); i.hasNext();) { Property p = (Property) i.next(); if (hasChild(p) || p.getDescriptor().getMinOccurs() > 0 || getEncodeIfEmpty(p)) { values.add(p); } } target.setValue(values); } catch (DataSourceException e) { throw new DataSourceException("Unable to clean empty element", e); } }
private void encodeSimpleLiteral(Property p) { String value = p.getValue().toString(); Name dn = p.getDescriptor().getName(); String name = dn.getLocalPart(); String prefix = MetaDataDescriptor.NAMESPACES.getPrefix(dn.getNamespaceURI()); AttributesImpl attributes = new AttributesImpl(); element(prefix + ":" + name, value, attributes); } }
private void encodeSimpleLiteral(Property p) { String value = p.getValue().toString(); Name dn = p.getDescriptor().getName(); String name = dn.getLocalPart(); String prefix = MetaDataDescriptor.NAMESPACES.getPrefix(dn.getNamespaceURI()); AttributesImpl attributes = new AttributesImpl(); element(prefix + ":" + name, value, attributes); }
values.add(o); result = true; } else if (((Property) o).getDescriptor().getMinOccurs() > 0) { if (((Property) o).getDescriptor().isNillable()) {
String name = property.getName().getLocalPart(); if (name.equals("id") || Geometry.class .isAssignableFrom(property.getDescriptor().getType().getBinding())) { continue;
String name = property.getName().getLocalPart(); if (name.equals("id") || name.equals("nodes") || Geometry.class .isAssignableFrom(property.getDescriptor().getType().getBinding())) { continue;
/** * Perform the visitation of an individual Feature. * * @param feature The Feature to explore. */ protected void walker(Feature feature) { final FeatureType schema = feature.getType(); //final int cnt = schema.getAttributeCount(); handler.handleFeature(feature); for( Property property : feature.getProperties() ){ Class<?> binding = property.getType().getBinding(); // recurse if attribute type is another collection if (FeatureCollection.class.isAssignableFrom( binding )) { walker((FeatureCollection) property.getValue() ); // } else if (type instanceof FeatureType) { } else if (Feature.class.isAssignableFrom(binding)) { // recurse if attribute type is another feature walker((Feature) property.getValue() ); } else { // normal handling handler.handleAttribute(property.getDescriptor(), property.getValue() ); } } handler.endFeature(feature); }
private void encodeSimpleLiteral(Property p) { ComplexAttribute sl = (ComplexAttribute) p; String scheme = sl.getProperty("scheme") == null ? null : (String) sl.getProperty("scheme").getValue(); String value = sl.getProperty("value") == null? "" : (String) sl.getProperty("value").getValue(); Name dn = p.getDescriptor().getName(); String name = dn.getLocalPart(); String prefix = CSWRecordDescriptor.NAMESPACES.getPrefix(dn.getNamespaceURI()); if (scheme == null) { element(prefix + ":" + name, value); } else { AttributesImpl attributes = new AttributesImpl(); addAttribute(attributes, "scheme", scheme); element(prefix + ":" + name, value, attributes); } }
private void encodeSimpleLiteral(Property p) { ComplexAttribute sl = (ComplexAttribute) p; String scheme = sl.getProperty("scheme") == null ? null : (String) sl.getProperty("scheme").getValue(); String value = sl.getProperty("value") == null ? "" : (String) sl.getProperty("value").getValue(); Name dn = p.getDescriptor().getName(); String name = dn.getLocalPart(); String prefix = CSWRecordDescriptor.NAMESPACES.getPrefix(dn.getNamespaceURI()); if (scheme == null) { element(prefix + ":" + name, value); } else { AttributesImpl attributes = new AttributesImpl(); addAttribute(attributes, "scheme", scheme); element(prefix + ":" + name, value, attributes); } }
((GeometryDescriptor) property.getDescriptor()) .getCoordinateReferenceSystem(); if (nativeCRS != null
} catch (Exception e) { throw new IllegalAttributeException( (AttributeDescriptor) property.getDescriptor(), value, e );