Refine search
buf.append(type.getName().getLocalPart()); buf.append(":"); buf.append(typeMap(type.getType().getBinding())); if (type instanceof GeometryDescriptor) { GeometryDescriptor gd = (GeometryDescriptor) type;
if (type == null) return; namespace = type.getName().getNamespaceURI(); name = type.getName().getLocalPart(); description = type.getDescription(); isAbstract = type.isAbstract(); restrictions = null; restrictions().addAll(type.getRestrictions()); properties.addAll(cType.getDescriptors()); defaultGeom = featureType.getGeometryDescriptor().getType().getName(); crs = featureType.getCoordinateReferenceSystem();
/** * Determines if <code>parent</code> is a super type of <code>type</code> * * @param type The type in question. * @param parent The possible parent type. */ public static boolean isSuperType(PropertyType type, PropertyType parent) { while (type.getSuper() != null) { type = type.getSuper(); if (type.equals(parent)) return true; } return false; }
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 (type != null) { sb.append(" <"); sb.append(type.getName().getLocalPart()); sb.append(":"); sb.append(Classes.getShortName(type.getBinding())); sb.append(">");
throws DataSourceException { List<PropertyDescriptor> attributes; Collection<PropertyDescriptor> descriptors = realType.getDescriptors(); attributes = new ArrayList<PropertyDescriptor>(descriptors); List<String> simpleProperties = new ArrayList<String>(); Set<String> firstAtts = new HashSet<String>(); for (int i = 0; i < ignoreList.size(); i++) { firstAtts.add(attributes.get(i).getName().getLocalPart()); Class<?> binding = descriptor.getType().getBinding(); int maxOccurs = descriptor.getMaxOccurs(); Name name = descriptor.getName(); if (GML.NAMESPACE.equals(name.getNamespaceURI()) || maxOccurs > 1 || Object.class.equals(binding)) { + name + " on feature type " + realType.getName()); continue;
/** * 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; }
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; }
stringBuffer.append(name.getLocalPart().toUpperCase()); stringBuffer.append(TEXT_11); stringBuffer.append(name.getLocalPart().toUpperCase()); stringBuffer.append(TEXT_12); stringBuffer.append(name.getLocalPart().toUpperCase()); stringBuffer.append(TEXT_13); ComplexType cType = (ComplexType)type; if (!cType.getDescriptors().isEmpty()) { for (Iterator adItr = cType.getDescriptors().iterator(); adItr.hasNext();) { PropertyDescriptor pd = (PropertyDescriptor) adItr.next(); if ( !(pd instanceof AttributeDescriptor) ) { Name n = (Name) entry.getKey(); PropertyDescriptor pd = (PropertyDescriptor) entry.getValue(); PropertyType pdType = pd.getType(); String pdTypeName = pdType.getName().getLocalPart().toUpperCase() + "_TYPE"; if (ns2import.containsKey(pdType.getName().getNamespaceURI())) { String importClassName = (String) ns2import.get(pdType.getName().getNamespaceURI()); pdTypeName = importClassName + "." + pdTypeName; String pdName = "new NameImpl(\"" + pd.getName().getNamespaceURI() + "\",\"" + pd.getName().getLocalPart() + "\")";
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(); } }
private void printAttributeDescriptor(Writer w, PropertyDescriptor attrib) throws IOException { print(w, attrib.getName().toString()); print(w, "\t"); print(w, FieldType.forBinding(attrib.getType().getBinding()).name()); print(w, "\t"); print(w, Integer.toString(attrib.getMinOccurs())); print(w, "\t"); print(w, Integer.toString(attrib.getMaxOccurs())); print(w, "\t"); print(w, Boolean.toString(attrib.isNillable())); PropertyType attrType = attrib.getType(); if (attrType instanceof GeometryType) { GeometryType gt = (GeometryType) attrType; CoordinateReferenceSystem crs = gt.getCoordinateReferenceSystem(); String crsText = CrsTextSerializer.serialize(crs); print(w, "\t"); println(w, crsText); } else { println(w, ""); } }
@Override public void funnel(PropertyDescriptor descriptor, PrimitiveSink into) { NameFunnel.funnel(descriptor.getName(), into); PropertyType attrType = descriptor.getType(); NameFunnel.funnel(attrType.getName(), into); FieldType type = FieldType.forBinding(attrType.getBinding()); into.putInt(type.getTag()); into.putBoolean(descriptor.isNillable()); into.putInt(descriptor.getMaxOccurs()); into.putInt(descriptor.getMinOccurs()); if (descriptor instanceof GeometryDescriptor) { CoordinateReferenceSystem crs; crs = ((GeometryDescriptor) descriptor).getCoordinateReferenceSystem(); String srsName; if (crs == null) { srsName = RevObjects.NULL_CRS_IDENTIFIER; } else { srsName = CRS.toSRS(crs); } NullableStringFunnel.funnel(srsName, into); } } };
@Test public void testParseHeader_NoFeatureId() throws Exception { final String simpleFormatExample = getClass().getResource("reader/simple_format_no_feature_id.txt").getFile(); final CsvSourceParser parser = CsvFile.createCsvSourceParser(simpleFormatExample); parser.parseMetadata(); final CsvSource csvSource = parser.parseMetadata(); final FeatureType featureType = csvSource.getFeatureType(); assertNotNull(featureType); final PropertyDescriptor[] propertyDescriptors = toPropertyDescriptorArray(featureType.getDescriptors()); assertEquals(7, propertyDescriptors.length); assertEquals("station", propertyDescriptors[0].getName().toString()); assertEquals("lat", propertyDescriptors[1].getName().toString()); assertEquals("lon", propertyDescriptors[2].getName().toString()); assertEquals("date_time", propertyDescriptors[3].getName().toString()); assertEquals("radiance_1", propertyDescriptors[4].getName().toString()); assertEquals("radiance_2", propertyDescriptors[5].getName().toString()); assertEquals("testTime", propertyDescriptors[6].getName().toString()); assertEquals(7, propertyDescriptors.length); assertTrue(propertyDescriptors[0].getType().getBinding().getSimpleName().matches(".*String")); assertTrue(propertyDescriptors[1].getType().getBinding().getSimpleName().matches(".*Float")); assertTrue(propertyDescriptors[2].getType().getBinding().getSimpleName().matches(".*Float")); assertTrue(propertyDescriptors[3].getType().getBinding().getSimpleName().matches(".*UTC")); assertTrue(propertyDescriptors[4].getType().getBinding().getSimpleName().matches(".*Float")); assertTrue(propertyDescriptors[5].getType().getBinding().getSimpleName().matches(".*Float")); assertTrue(propertyDescriptors[6].getType().getBinding().getSimpleName().matches(".*UTC")); }
/** * Test that this class can be loaded. */ public static void main(String[] args) { Schema schema = new GCOSchema(); for (Entry<Name, AttributeType> entry : new TreeMap<Name, AttributeType>(schema).entrySet()) { System.out.println("Type: " + entry.getValue().getName()); System.out.println(" Super type: " + entry.getValue().getSuper().getName()); if (entry.getValue() instanceof ComplexType) { for (PropertyDescriptor descriptor : ((ComplexType) entry.getValue()) .getDescriptors()) { System.out.println(" Property descriptor: " + descriptor.getName()); System.out.println(" Property type: " + descriptor.getType().getName()); } } } }
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; }
entrySet = new LinkedHashSet<MapEntry>(); final ComplexType featureType = feature.getType(); PropertyDescriptor attributeDescr = featureType.getDescriptor(attributeName); Property property = feature.getProperty(attributeName); List<AttributeDescriptor> substitutionGroup = (List<AttributeDescriptor>) attributeDescr.getUserData().get("substitutionGroup"); if (substitutionGroup != null) { Iterator<AttributeDescriptor> it = substitutionGroup.iterator(); entrySet.add(new MapEntry<Object, Object>("name", attributeName.getLocalPart())); entrySet.add( new MapEntry<Object, Object>("namespace", getNamespace(attributeName))); 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)));
Name pname = toName(sourceName, targetSch.getName().getNamespaceURI()); PropertyDescriptor pd = targetSch.getDescriptor(pname); if (pd == null) { throw new RestException( Object converted = convert(originalValue, pd.getType().getBinding()); Attribute attribute = ab.buildSimple(null, converted); builder.append(pd.getName(), attribute);
sb.append(superType.getName().getLocalPart());
throw new ProcessException(Errors.format(ErrorKeys.NULL_ARGUMENT_$1, "attribute")); PropertyDescriptor property = features.getSchema().getDescriptor(attribute); if (property == null) { throw new ProcessException("No such feature attribute '" + attribute + "'"); if (!Number.class.isAssignableFrom(property.getType().getBinding())) { throw new ProcessException("Feature attribute '" + attribute + "' is not numeric");
for (PropertyDescriptor propertyDescriptor : super.featureType.getDescriptors()) { Name name = propertyDescriptor.getName(); int minOccurs = propertyDescriptor.getMinOccurs(); int numberOfProperties = properties.size(); if (propertyDescriptor.isNillable() && AttributeDescriptor.class.isAssignableFrom( propertyDescriptor.getClass())) { Property nullProperty = new AttributeImpl( propertyDescriptor.getType().getBinding().cast(null), (AttributeDescriptor) propertyDescriptor, null); String.format( "Failed to build feature '%s'; its property '%s' requires at least %s occurrence(s) but number of occurrences was %s.", featureType.getName(), name, minOccurs, numberOfProperties));