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>("prefix", getPrefix(attributeName))); if (attributeDescr.getType() instanceof ComplexType) { entrySet.add( new MapEntry<Object, Object>( "type", buildType((ComplexType) attributeDescr.getType()))); } else { 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)));
/** * 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; }
public PropertyType getType() { return getDescriptor().getType(); }
/** * Creates the pointer. * * @param parent The parent pointer, pointer at the feature type. * @param parentType Feature Type of parent * @param name Name of Attribute */ public FeatureTypeAttributePointer(NodePointer parent, ComplexType parentType, Name name) { super(parent); this.parentType = parentType; this.name = name; descriptor = getDescriptor(); attType = (AttributeType) descriptor.getType(); }
public String toString() { StringBuffer sb = new StringBuffer(getClass().getSimpleName()).append(":"); sb.append(getDescriptor().getName().getLocalPart()); sb.append("<"); sb.append(getDescriptor().getType().getName().getLocalPart()); sb.append(">="); sb.append(value); return sb.toString(); } }
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; }
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; }
Class<?> expectedClass = propertyDescriptor.getType().getBinding(); if (value != null) { Class<?> providedClass = value.getType().getBinding();
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;
Class<?> binding = descriptor.getType().getBinding(); int maxOccurs = descriptor.getMaxOccurs(); Name name = descriptor.getName();
sb.append(property.getType().getName().getLocalPart());
public Object getImmediateNode() { // first try regular way PropertyType pt = descriptor.getType(); if (pt instanceof ComplexType) { ComplexType ct = (ComplexType) pt; PropertyDescriptor ad = ct.getDescriptor("@" + name.getLocalPart()); if (ad != null) { return ad; } } XSDElementDeclaration decl = (XSDElementDeclaration) descriptor.getUserData().get(XSDElementDeclaration.class); Iterator it = Schemas.getAttributeDeclarations(decl).iterator(); while (it.hasNext()) { XSDAttributeDeclaration attDecl = ((XSDAttributeDeclaration) it.next()); if (attDecl.getURI() .equals( (name.getNamespaceURI() == null ? "" : name.getNamespaceURI()) + "#" + name.getLocalPart())) { return name; } } 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; }
/** * 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); } }
PropertyType type = descriptor.getType(); Integer length = null; while (type != null) {
if (pd.getType().getBinding() == Boolean.class) { int bool = 0; if (f.getAttribute(name) != null) {