private SimpleHash buildType(ComplexType ft) { // create a variable "attributes" which his a list of all the // attributes, but at the same time, is a map keyed by name Map<String, Object> attributeMap = new LinkedHashMap<String, Object>(); Collection<PropertyDescriptor> descriptors = ft.getDescriptors(); for (Iterator<PropertyDescriptor> it = descriptors.iterator(); it.hasNext(); ) { PropertyDescriptor descr = it.next(); Map<String, Object> attribute = new HashMap<String, Object>(); attribute.put("name", descr.getName().getLocalPart()); attribute.put("namespace", getNamespace(descr.getName())); attribute.put("prefix", getPrefix(descr.getName())); attribute.put("type", descr.getType().getBinding().getName()); attribute.put( "isGeometry", Boolean.valueOf(Geometry.class.isAssignableFrom(descr.getType().getBinding()))); attributeMap.put(descr.getName().toString(), attribute); } // build up the result, feature type is represented by its name an // attributes SimpleHash map = new SimpleHash(); map.put("attributes", new SequenceMapModel(attributeMap, this)); map.put("name", ft.getName().getLocalPart()); map.put("namespace", getNamespace(ft.getName())); map.put("prefix", getPrefix(ft.getName())); return map; }
entrySet.add( new MapEntry<Object, Object>( "type", attributeDescr.getType().getBinding().getName())); Geometry.class.isAssignableFrom(attributeDescr.getType().getBinding()); entrySet.add( new MapEntry<Object, Object>("isGeometry", Boolean.valueOf(isGeometry)));
String propName = prop.getName().toString(); if (propertyFields.contains(propName)) { Object binding = prop.getType().getBinding();
/** * Extracts the AttributeTypeInfo by copying them from the specified feature type. * * @param ft The schema to be harvested * @param info The optional feature type info from which all the attributes belong to */ public List<AttributeTypeInfo> getAttributes(FeatureType ft, FeatureTypeInfo info) { List<AttributeTypeInfo> attributes = new ArrayList<AttributeTypeInfo>(); for (PropertyDescriptor pd : ft.getDescriptors()) { AttributeTypeInfo att = catalog.getFactory().createAttribute(); att.setFeatureType(info); att.setName(pd.getName().getLocalPart()); att.setMinOccurs(pd.getMinOccurs()); att.setMaxOccurs(pd.getMaxOccurs()); att.setNillable(pd.isNillable()); att.setBinding(pd.getType().getBinding()); int length = FeatureTypes.getFieldLength(pd); if (length > 0) { att.setLength(length); } attributes.add(att); } return attributes; }
public List<AttributeTypeInfo> loadAttributes(FeatureTypeInfo info) throws IOException { List<AttributeTypeInfo> attributes = new ArrayList(); FeatureType ft = getFeatureType(info); for (PropertyDescriptor pd : ft.getDescriptors()) { AttributeTypeInfo att = catalog.getFactory().createAttribute(); att.setFeatureType(info); att.setName(pd.getName().getLocalPart()); att.setMinOccurs(pd.getMinOccurs()); att.setMaxOccurs(pd.getMaxOccurs()); att.setNillable(pd.isNillable()); att.setBinding(pd.getType().getBinding()); int length = FeatureTypes.getFieldLength(pd); if (length > 0) { att.setLength(length); } attributes.add(att); } return attributes; }
if (superType != null && superType.getBinding() != null) { + superType.getBinding());
protected Object convert(Object value, PropertyDescriptor descriptor) { // make sure the type of the value and the binding of the type match up if (value != null) { Class<?> target = descriptor.getType().getBinding(); Object converted = Converters.convert(value, target); if (converted != null) { value = converted; } } return value; }
sb.append(type.getName().getLocalPart()); sb.append(":"); sb.append(Classes.getShortName(type.getBinding())); sb.append(">");
sb.append(type.getName().getLocalPart()); sb.append(":"); sb.append(Classes.getShortName(type.getBinding())); sb.append(">");
Class<?> expectedClass = propertyDescriptor.getType().getBinding(); if (value != null) { Class<?> providedClass = value.getType().getBinding();
private Class getJsonSelectType(Expression expression) { if (expression instanceof JsonSelectFunction) { PropertyDescriptor descriptor = featureType.getDescriptor(((JsonSelectFunction) expression).getJsonPath()); return descriptor == null ? null : descriptor.getType().getBinding(); } if (expression instanceof JsonSelectAllFunction) { PropertyDescriptor descriptor = featureType.getDescriptor(((JsonSelectAllFunction) expression).getJsonPath()); return descriptor == null ? null : descriptor.getType().getBinding(); } return null; }
buf.append(type.getName().getLocalPart()); buf.append(":"); buf.append(typeMap(type.getType().getBinding())); if (type instanceof GeometryDescriptor) { GeometryDescriptor gd = (GeometryDescriptor) type;
public Object get(Object object, String xpath, Class target) { if (object instanceof Feature) return ((Feature) object).getDefaultGeometryProperty(); if (object instanceof FeatureType) { FeatureType ft = (FeatureType) object; GeometryDescriptor gd = ft.getGeometryDescriptor(); if (gd == null) { // look for any geometry descriptor for (PropertyDescriptor pd : ft.getDescriptors()) { if (Geometry.class.isAssignableFrom(pd.getType().getBinding())) { return pd; } } } return gd; } return null; }
buf.append(type.getName().getLocalPart()); buf.append(":"); buf.append(typeMap(type.getType().getBinding())); if (type instanceof GeometryDescriptor) { GeometryDescriptor gd = (GeometryDescriptor) type;
private Class[] getSortByAttributeClasses(LiteFeatureTypeStyle style) { SortBy[] sb = style.sortBy; FeatureType schema = style.layer.getFeatureSource().getSchema(); Class[] classes = new Class[sb.length]; for (int i = 0; i < classes.length; i++) { PropertyName property = sb[i].getPropertyName(); if (property == null) { // natural sorts classes[i] = String.class; } else { PropertyDescriptor pd = property.evaluate(schema, null); if (pd == null) { throw new IllegalArgumentException( "Property " + property + " could not be found in feature type " + schema.getName() + " in layer " + style.layer.getTitle()); } classes[i] = pd.getType().getBinding(); } } return classes; }
getSimpleContentType((AttributeType) simpleContent.getType()); Object convertedValue = FF.literal(value).evaluate(value, simpleContentType.getBinding()); simpleContent.setValue(convertedValue); return attribute;
/** * 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); }
/** * Visitor function, which looks at each feature and finds the value of the attribute given * attribute nearest to the given comparison value. * * @param feature the feature to be visited */ @SuppressWarnings("unchecked") public void visit(org.opengis.feature.Feature feature) { // bail out immediately if we have already found an exact match if (visited) { return; } if (attributeClass == null) { PropertyDescriptor desc = (PropertyDescriptor) expr.evaluate(feature.getType()); attributeClass = desc.getType().getBinding(); if (accumulator == null) { accumulator = getAccumulator(attributeClass); } } // extract the value Object attribValue = expr.evaluate(feature); if (attribValue == null) { return; } else { visited |= accumulator.visit(attribValue); } }
public boolean equals(Object other) { if (this == other) return true; if (!(other instanceof PropertyType)) { return false; } PropertyType prop = (PropertyType) other; if (!Utilities.equals(name, prop.getName())) { return false; } if (!Utilities.equals(binding, prop.getBinding())) { return false; } if (isAbstract != prop.isAbstract()) { return false; } if (!equals(getRestrictions(), prop.getRestrictions())) { return false; } if (!Utilities.equals(superType, prop.getSuper())) { return false; } if (!Utilities.equals(description, prop.getDescription())) { return false; } return true; }
if (pd.getType().getBinding() == Boolean.class) { int bool = 0; if (f.getAttribute(name) != null) {