final ComplexType featureType = feature.getType(); PropertyDescriptor attributeDescr = featureType.getDescriptor(attributeName); Property property = feature.getProperty(attributeName); Iterator<AttributeDescriptor> it = substitutionGroup.iterator(); while (property == null && it.hasNext()) { property = feature.getProperty(it.next().getName());
/** * Return the simple content of a {@link ComplexAttribute} if it represents a complexType with * simpleContent, otherwise null. * * @param complex * @return */ public static Object getSimpleContent(ComplexAttribute complex) { Property simpleContent = complex.getProperty(new NameImpl("simpleContent")); if (simpleContent == null) { return null; } else { return simpleContent.getValue(); } }
/** @see AbstractComplexBinding#getProperty(java.lang.Object, javax.xml.namespace.QName) */ @Override public Object getProperty(Object object, QName name) throws Exception { if (object instanceof ComplexAttribute) { ComplexAttribute complex = (ComplexAttribute) object; Property property = complex.getProperty(toTypeName(name)); if (property != null && !(property instanceof ComplexAttribute)) { return property.getValue(); } if ("id".equals(name.getLocalPart())) { return complex.getIdentifier(); } } return null; }
/** * Unpacks a value from an attribute container * * @param value * @return */ public static Object unpack(Object value) { if (value instanceof org.opengis.feature.ComplexAttribute) { Property simpleContent = ((org.opengis.feature.ComplexAttribute) value).getProperty(SIMPLE_CONTENT); if (simpleContent == null) { return null; } else { return simpleContent.getValue(); } } if (value instanceof org.opengis.feature.Attribute) { return ((org.opengis.feature.Attribute) value).getValue(); } return value; } }
@SuppressWarnings("unchecked") public Object getImmediateNode() { // first try regular way if (feature instanceof ComplexAttribute) { ComplexAttribute ca = (ComplexAttribute) feature; Property p = ca.getProperty("@" + name.getLocalPart()); if (p != null) { return p; } } // FIXME - better id checking if (name.getLocalPart().equals("id")) { Identifier id = feature.getIdentifier(); if (id != null) { return id.getID(); } } Map<Name, Object> map = (Map<Name, Object>) feature.getUserData().get(Attributes.class); if (map != null) { return map.get(name); } else { return null; } }
/** * Unpacks a value from an attribute container * * @param value * @return */ private Object unpack(Object value) { if (value instanceof org.opengis.feature.ComplexAttribute) { Property simpleContent = ((org.opengis.feature.ComplexAttribute) value) .getProperty(new NameImpl("simpleContent")); if (simpleContent == null) { return null; } else { return simpleContent.getValue(); } } if (value instanceof org.opengis.feature.Attribute) { return ((org.opengis.feature.Attribute) value).getValue(); } return value; }
(ComplexAttribute) targetAttribute.getProperty(steps[i]); (ComplexAttribute) targetAttribute.getProperty(xsdName); (ComplexAttribute) featureWrapperAttribute.getProperty(typeName); Property property = targetAttribute.getProperty(xsdName);
simpleContent = ((ComplexAttribute) attribute) .getProperty(ComplexFeatureConstants.SIMPLE_CONTENT);
@Test public void testSweValues() { Map<String, String> expected = new HashMap<String, String>(); expected.put( "ID1.2", "missing missing 8.9 7.9 14.2 15.4 18.1 19.1 21.7 20.8 19.6 14.9 10.8 8.8 8.5 10.4"); expected.put( "ID2.2", "16.2 17.1 22.0 25.1 23.9 22.8 17.0 10.2 9.2 7.1 12.3 12.9 17.2 23.6 21.6 21.9 17.6 14.0 9.3 3.8"); FeatureIterator<? extends Feature> featIt = obsFeatures.features(); while (featIt.hasNext()) { Feature f = featIt.next(); PropertyName pf = ff.property("om:result/swe:DataArray/swe:values", namespaces); Object sweValues = pf.evaluate(f); assertNotNull(sweValues); assertTrue(sweValues instanceof ComplexAttribute); ComplexAttribute sweValuesAttr = (ComplexAttribute) sweValues; assertEquals( expected.get(f.getIdentifier().getID()), sweValuesAttr.getProperty(ComplexFeatureConstants.SIMPLE_CONTENT).getValue()); } } }
.get("mf.1") .getProperty(new NameImpl(GML.NAMESPACE, "name"))) .getProperty(new NameImpl("simpleContent")) .getValue()); Assert.assertEquals( .get("mf.2") .getProperty(new NameImpl(GML.NAMESPACE, "name"))) .getProperty(new NameImpl("simpleContent")) .getValue()); GSML, "resolutionScale"))) .getProperty( new NameImpl( GMD.NAMESPACE, "MD_RepresentativeFraction"))) .getProperty( new NameImpl( GMD.NAMESPACE, "denominator"))) .getProperty( new NameImpl(GCO.NAMESPACE, "Integer"))) .getValue());
/** * Return the simple content of a {@link ComplexAttribute} if it represents a complexType with * simpleContent, otherwise null. * * @param complex * @return */ public static Object getSimpleContent(ComplexAttribute complex) { Property simpleContent = complex.getProperty(new NameImpl("simpleContent")); if (simpleContent == null) { return null; } else { return simpleContent.getValue(); } }
/** * @see org.geotools.xml.AbstractComplexBinding#getProperty(java.lang.Object, * javax.xml.namespace.QName) */ @Override public Object getProperty(Object object, QName name) throws Exception { if (object instanceof ComplexAttribute) { ComplexAttribute complex = (ComplexAttribute) object; Property property = complex.getProperty(toTypeName(name)); if (property != null && !(property instanceof ComplexAttribute)) { return property.getValue(); } if ("id".equals(name.getLocalPart())) { return complex.getIdentifier(); } } return null; }
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; }
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); } }
@Override public void visit(Feature feature) { ComplexAttribute ca = (ComplexAttribute) feature.getProperty(property); String value = (String) ca.getProperty("value").getValue(); values.add(value); } }, null);
private String getSimpleLiteralValue(Feature f, String name) { ComplexAttribute ca = (ComplexAttribute) f.getProperty(name); return (String) ca.getProperty("value").getValue(); }
private String getSimpleLiteralScheme(Feature f, String name) { ComplexAttribute ca = (ComplexAttribute) f.getProperty(name); return (String) ca.getProperty("scheme").getValue(); }
@Override public void visit(Feature feature) { // has the id ComplexAttribute id = (ComplexAttribute) feature.getProperty("identifier"); assertNotNull(id); String value = (String) id.getProperty("value").getValue(); values.add(value); // only has the id assertEquals(1, feature.getProperties().size()); } }, null);
private void assertRecordElement(Feature f, String elementName, Object... values) { AttributeDescriptor identifierDescriptor = CSWRecordDescriptor.getDescriptor(elementName); Collection<Property> propertyList = f.getProperties(identifierDescriptor.getName()); Property[] properties = (Property[]) propertyList.toArray(new Property[propertyList.size()]); assertEquals(properties.length, values.length); for (int i = 0; i < properties.length; i++) { ComplexAttribute cad = (ComplexAttribute) properties[i]; assertEquals(identifierDescriptor, cad.getDescriptor()); assertEquals(values[i], cad.getProperty(CSWRecordDescriptor.SIMPLE_LITERAL_VALUE).getValue()); } }