/** * 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(); } }
public AttributeNodeIterator(AttributeNodePointer pointer, Name name) { this.pointer = pointer; feature = (ComplexAttribute) pointer.getImmediateAttribute(); AttributeDescriptor descriptor = feature.getDescriptor(); Name attName = descriptor == null ? feature.getType().getName() : descriptor.getName(); if (attName.equals(name)) { children = Collections.<Property>singletonList(feature); } else { children = new ArrayList<Property>(feature.getProperties(name)); } position = children.size() > 0 ? 1 : 0; }
public AttributeNodeIterator(AttributeNodePointer pointer) { this.pointer = pointer; feature = (ComplexAttribute) pointer.getImmediateAttribute(); children = new ArrayList<Property>(feature.getValue()); position = 1; }
if (entrySet == null) { entrySet = new LinkedHashSet<MapEntry>(); 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());
info = cat.getResourceByName( att.getType().getName().getNamespaceURI(), att.getType().getName().getLocalPart(), FeatureTypeInfo.class); if (att.getIdentifier() != null) { map.put("fid", att.getIdentifier().getID()); } else { map.put("fid", ""); map.put("typeName", att.getType().getName().getLocalPart());
(ComplexAttribute) targetAttribute.getProperty(steps[i]); (ComplexAttribute) targetAttribute.getProperty(xsdName); String.format( "Unable to wrap attribute in class '%s'. '%s' doesn't have required property '%s'.", clazz.getName(), targetAttribute.getName(), xsdName)); Name typeName = featureWrapperAttribute.getType().getName(); ComplexAttribute nestedComplexAttribute = (ComplexAttribute) featureWrapperAttribute.getProperty(typeName); if (FeatureWrapper.class.isAssignableFrom(collectionType)) { for (Property property : targetAttribute.getProperties(xsdName)) { collection.add( wrap( for (Property property : targetAttribute.getProperties(xsdName)) { collection.add(property.getValue()); Property property = targetAttribute.getProperty(xsdName);
/** * @see AbstractComplexBinding#encode(java.lang.Object, org.w3c.dom.Document, * org.w3c.dom.Element) */ @Override public Element encode(Object object, Document document, Element value) throws Exception { if (object instanceof ComplexAttribute) { ComplexAttribute complex = (ComplexAttribute) object; if (complex.getProperties().size() == 1) { Property prop = complex.getProperties().iterator().next(); checkXlinkHref(prop, complex); } GML3EncodingUtils.encodeClientProperties(complex, value); GML3EncodingUtils.encodeSimpleContent(complex, document, value); } else if (!isPlaceholderObject(object) && !(object instanceof Collection)) { GML3EncodingUtils.encodeAsText(document, value, object); } return value; }
/** @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; }
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()); } }
/** Encode a complex attribute as a JSON object. */ private void encodeComplexAttribute( ComplexAttribute attribute, Map<NameImpl, String> attributes) { // get the attribute name and start a JSON object String name = attribute.getName().getLocalPart(); jsonWriter.key(name); if (attributes != null && !attributes.isEmpty()) { // we have some attributes to encode jsonWriter.array(); } // let's see if we have actually some properties to encode if (attribute.getProperties() != null && !attribute.getProperties().isEmpty()) { jsonWriter.object(); // encode the object properties, since this is not a top feature or a // chained feature we don't need to explicitly handle the geometry attribute encodeProperties(null, attribute.getType(), attribute.getProperties()); // end the attribute JSON object jsonWriter.endObject(); } if (attributes != null && !attributes.isEmpty()) { // encode the attributes list encodeAttributes(attributes); jsonWriter.endArray(); } }
Collection<Property> nestedProperties = complex.getProperties(); if (nestedProperties == null || nestedProperties.isEmpty()) { return false; .allMatch( property -> property.getType().getName().equals(complex.getType().getName()))) { .getType() .getName() .equals(complex.getType().getName().getLocalPart())) {
@Override public Object getProperty(Object object, QName name) throws Exception { if (GML._Feature.equals(name)) { if (object instanceof SimpleFeature) { return object; } else if (object instanceof FeatureImpl) { ComplexAttribute complex = (ComplexAttribute) object; Identifier ident = complex.getIdentifier(); if (ident == null) { return object; } String id; if (ident instanceof FeatureId) { id = ((FeatureId) ident).getRid(); } else { id = Converters.convert(ident.getID(), String.class); } if (idSet.idExists(id)) { return null; } return object; } else if (object instanceof ComplexAttribute) { return ((ComplexAttribute) object).getProperties().iterator().next(); } } return null; }
if (!(object.getType() instanceof FeatureTypeImpl)) { Identifier ident = object.getIdentifier(); if (ident == null) { return; Object clientProperties = att.getUserData().get(Attributes.class); Map<Name, Object> map = null; if (clientProperties == null) { map = new HashMap<Name, Object>(); att.getUserData().put(Attributes.class, map); } else { map = (Map<Name, Object>) clientProperties; att.setValue(Collections.emptyList());
} else if (object instanceof ComplexAttribute) { complexAtts = ((ComplexAttribute) object).getProperties(); } else { return null; .getSubstitutionGroup()) { Name name = new NameImpl(e.getTargetNamespace(), e.getName()); Collection<Property> nameProperties = complex.getProperties(name); if (!nameProperties.isEmpty()) { } else if (object instanceof ComplexAttribute) { complexAtts = ((ComplexAttribute) object).getProperties(); PropertyDescriptor descriptor = newComplexAtt.getDescriptor(); if (descriptor.getUserData() != null) { Object propertyElement = descriptor.getUserData().get( String newName = newComplexAtt.getDescriptor().getName() .getLocalPart(); if (existingName.equals(newName)) {
if (!content.isEmpty()) { throw new IllegalAttributeException( attribute.getDescriptor(), "Type indicates empty attribute collection, content does not");
private Map<String, Object> buildDummyFeatureTypeInfo(ComplexAttribute f) { Map<String, Object> dummy = new HashMap<String, Object>(); dummy.put("name", f.getType().getName().getLocalPart()); dummy.put("namespace", getNamespace(f.getType().getName())); dummy.put("prefix", getPrefix(f.getType().getName())); dummy.put("title", "Layer: " + f.getType().getName().getLocalPart()); dummy.put("abstract", "[No Abstract Provided]"); dummy.put("description", "[No Description Provided]"); dummy.put("keywords", new ArrayList<String>()); dummy.put("metadataLinks", new ArrayList<String>()); dummy.put("SRS", "[SRS]"); if (f instanceof Feature) { final GeometryDescriptor gd = ((Feature) f).getType().getGeometryDescriptor(); if (gd != null) { dummy.put("nativeCRS", gd.getCoordinateReferenceSystem()); } } return dummy; }
Identifier ident = att.getIdentifier(); if (ident == null) { return; Object clientProperties = att.getUserData().get(Attributes.class); Map<Name, Object> map = null; if (clientProperties == null) { map = new HashMap<Name, Object>(); att.getUserData().put(Attributes.class, map); } else { map = (Map<Name, Object>) clientProperties; att.setValue(Collections.emptyList());
(ComplexAttribute) targetAttribute.getProperty(steps[i]); (ComplexAttribute) targetAttribute.getProperty(xsdName); String.format( "Unable to wrap attribute in class '%s'. '%s' doesn't have required property '%s'.", clazz.getName(), targetAttribute.getName(), xsdName)); Name typeName = featureWrapperAttribute.getType().getName(); ComplexAttribute nestedComplexAttribute = (ComplexAttribute) featureWrapperAttribute.getProperty(typeName); if (FeatureWrapper.class.isAssignableFrom(collectionType)) { for (Property property : targetAttribute.getProperties(xsdName)) { collection.add( wrap( for (Property property : targetAttribute.getProperties(xsdName)) { collection.add(property.getValue()); Property property = targetAttribute.getProperty(xsdName);
if (stepsIterator.hasNext()) { step = stepsIterator.next(); properties = ((ComplexAttribute) root).getProperties(Types.toTypeName(step.getName())); Collection<Property> tempProperties = ((ComplexAttribute) property) .getProperties(Types.toTypeName(step.getName())); if (!tempProperties.isEmpty()) { nestedProperties.addAll(tempProperties);
/** * @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; }