public void init(PropertyDescriptor descriptor) { init(); namespace = descriptor.getName().getNamespaceURI(); name = descriptor.getName().getLocalPart(); minOccurs = descriptor.getMinOccurs(); maxOccurs = descriptor.getMaxOccurs(); if (descriptor instanceof AttributeDescriptor) { AttributeDescriptor attribute = (AttributeDescriptor) descriptor; isNillable = attribute.isNillable(); propertyType = attribute.getType(); } if (descriptor instanceof AssociationDescriptor) { AssociationDescriptor association = (AssociationDescriptor) descriptor; propertyType = association.getType(); } }
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; }
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(); while (property == null && it.hasNext()) { property = feature.getProperty(it.next().getName()); 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)));
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; }
String expectedName = expected.getName().getLocalPart(); String actualName = actual.getName().getLocalPart(); if (!expectedName.equals(actualName)) { throw new IllegalAttributeException( for (PropertyDescriptor descriptor : actual.getDescriptors()) { names.add(descriptor.getName().getLocalPart()); for (PropertyDescriptor descriptor : expected.getDescriptors()) { expectedName = descriptor.getName().getLocalPart(); if (names.contains(expectedName)) { for (PropertyDescriptor expectedDescriptor : expected.getDescriptors()) { expectedName = expectedDescriptor.getName().getLocalPart(); PropertyDescriptor actualDescriptor = actual.getDescriptor(expectedName); Class<?> expectedBinding = expectedDescriptor.getType().getBinding(); Class<?> actualBinding = actualDescriptor.getType().getBinding(); if (!actualBinding.isAssignableFrom(expectedBinding)) { throw new IllegalArgumentException(
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; simpleProperties.add(((AttributeDescriptor) descriptor).getLocalName());
String uri = name.getNamespaceURI(); String local = name.getLocalPart(); String binding; if (typeBindings.containsKey(name)) { if (cType.getDescriptors().isEmpty()) { for (PropertyDescriptor pd : cType.getDescriptors()) { if ( !(pd instanceof AttributeDescriptor) ) { continue; AttributeType adType = ad.getType(); String adTypeName = adType.getName().getLocalPart().toUpperCase() + "_TYPE"; 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() + "\")";
PropertyDescriptor getDescriptor(String name) { for (PropertyDescriptor pd : schema.getDescriptors()) { if (name.equals(pd.getName().getLocalPart())) { return pd; } } return null; }
AttributeDescriptor parentDescriptor = parent.getDescriptor(); if (parentDescriptor != null) { rootName = parentDescriptor.getName(); Step rootStep = (Step) steps.get(0); QName stepName = rootStep.getName(); geomType, rootName, parentDescriptor.getMinOccurs(), parentDescriptor.getMaxOccurs(), if (_parentType.getName().equals(XSSchema.ANYTYPE_TYPE.getName()) && targetDescriptor != null) { Collection properties = parentType.getDescriptors(); for (Iterator it = properties.iterator(); it.hasNext(); ) { PropertyDescriptor desc = (PropertyDescriptor) it.next(); Name name = desc.getName(); currStep + " is not a valid location path for type " + parentType.getName() + ". " + currStep
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(); } }
AttributeBuilder ab = new AttributeBuilder(FEATURE_FACTORY); for (AttributeDescriptor ad : feature.getType().getAttributeDescriptors()) { String sourceName = ad.getLocalName(); 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);
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; }
if (d.getName().getLocalPart().equals(name)) { return d; (List<AttributeDescriptor>) it.next().getUserData().get("substitutionGroup"); if (substitutionGroup != null) { for (Iterator<AttributeDescriptor> it2 = substitutionGroup.iterator(); it2.hasNext(); ) { AttributeDescriptor d = it2.next(); if (d.getName().getLocalPart().equals(name)) { // BINGOOO !! return d;
public PropertyDescriptor getDescriptor(String name) { PropertyDescriptor result = getDescriptor(new NameImpl(name)); if (result == null) { // look in the same namespace as the complex type result = getDescriptor(new NameImpl(getName().getNamespaceURI(), name)); if (result == null) { // full scan for (PropertyDescriptor pd : properties) { if (pd.getName().getLocalPart().equals(name)) { return pd; } } } } return result; }
Entry<PropertyDescriptor, AttributeDiff> entry = iterator.next(); if (entry.getValue().getType() == TYPE.REMOVED) { removed.add(entry.getKey().getName().getLocalPart()); } else if (entry.getValue().getType() == TYPE.ADDED) { PropertyDescriptor pd = entry.getKey(); for (int i = 0; i < descriptors.size(); i++) { AttributeDescriptor descriptor = descriptors.get(i); if (!removed.contains(descriptor.getName().getLocalPart())) { featureTypeBuilder.add(descriptor);
Collection<PropertyDescriptor> attTypes = schema.getDescriptors(); Name attName; attName = pd.getName(); if ((attName.getLocalPart().equalsIgnoreCase("grid")) && !attributeNames.contains(attName.getLocalPart()) || (attName.getLocalPart().equalsIgnoreCase("params")) && !attributeNames.contains(attName.getLocalPart())) { atts.add(filterFactory.property(attName)); schema.getGeometryDescriptor().getName().toString())) { atts.add(filterFactory.property(schema.getGeometryDescriptor().getName()));
/** * 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()); } } } }
private void writeProperty(PropertyDescriptor attr, DataOutput data) throws IOException { writeName(attr.getName(), data); data.writeBoolean(attr.isNillable()); data.writeInt(attr.getMinOccurs()); data.writeInt(attr.getMaxOccurs()); writePropertyType(attr.getType(), data); } }
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));
CoordinateReferenceSystem crs) { if (descriptor.getUserData().get("substitutionGroup") != null) { descriptor.getUserData().put("substitutionGroup", substitutionGroup); Collection<PropertyDescriptor> children = complexType.getDescriptors(); if (desc.getName().getLocalPart().equals(element.getName()) && desc.getName() .getNamespaceURI() .equals(element.getTargetNamespace())) { childDesc = desc;