/** * @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; }
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; }
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);
@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 (FeatureWrapper.class.isAssignableFrom(collectionType)) { for (Property property : targetAttribute.getProperties(xsdName)) { collection.add( wrap( for (Property property : targetAttribute.getProperties(xsdName)) { collection.add(property.getValue());
&& isNonStripedNestedElement(next, element)) { for (Property property : ((ComplexAttribute) next).getProperties()) {
Collection<Property> nestedProperties = complex.getProperties(); if (nestedProperties == null || nestedProperties.isEmpty()) { return false;
Object currStepValue = ((ComplexAttribute) parent).getProperties(attributeName); if (currStepValue instanceof Collection) { List<Attribute> values = new ArrayList((Collection) currStepValue);
} else if (object instanceof ComplexAttribute) { complexAtts = ((ComplexAttribute) object).getProperties(); } else { return null; (List<XSDElementDeclaration>) childElement.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();
/** * Helper method that returns TRUE if the provided complex property corresponds to a chained * feature resolved as a link. */ @SuppressWarnings("unchecked") private boolean checkIfFeatureIsLinked(Property property, Map<NameImpl, String> attributes) { if (!(property instanceof ComplexAttribute)) { // not a complex attribute, so we don't consider it a candidate to be a linked one return false; } ComplexAttribute complexProperty = (ComplexAttribute) property; if (complexProperty.getProperties() != null && !complexProperty.getProperties().isEmpty()) { // has properties, so not a chained feature resolved as a link return false; } for (NameImpl key : attributes.keySet()) { if (key != null && key.getLocalPart().equalsIgnoreCase("href")) { // we found a link return true; } } // no link was found, so not a chained feature resolved as a link return false; }
/** * @see org.geotools.xml.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); } return value; }
/** * Get a list of chained features, NULL will be returned if this properties are not chained * features. */ private List<Feature> getChainedFeatures(List<Property> properties) { List<Feature> features = new ArrayList<>(); for (Property property : properties) { if (!(property instanceof ComplexAttribute)) { // only the chaining of complex features is supported return null; } ComplexAttribute complexProperty = (ComplexAttribute) property; Collection<Property> subProperties = complexProperty.getProperties(); if (subProperties.size() > 1) { // more than one property means that this are not chained features return null; } Property subProperty = getElementAt(subProperties, 0); if (!(subProperty instanceof Feature)) { // if the only property is not a feature this are no chained features return null; } features.add((Feature) subProperty); } // this are chained features return features; }
public AttributeNodeIterator(AttributeNodePointer pointer, Name name) { this.pointer = pointer; feature = (ComplexAttribute) pointer.getImmediateNode(); 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; }
if (stepsIterator.hasNext()) { step = stepsIterator.next(); properties = ((ComplexAttribute) root).getProperties(Types.toTypeName(step.getName())); assert property instanceof ComplexAttribute; Collection<Property> tempProperties = ((ComplexAttribute) property) .getProperties(Types.toTypeName(step.getName())); if (!tempProperties.isEmpty()) { nestedProperties.addAll(tempProperties);
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; }
private Map<String, Object> getProperties(ComplexAttribute feature) { Map<String, Object> props = new TreeMap<>(); for (Property p : feature.getProperties()) { if (!(p instanceof Attribute) || (p instanceof GeometryAttribute)) { continue; } String name = p.getName().getLocalPart(); Object value; if (p instanceof ComplexAttribute) { value = getProperties((ComplexAttribute) p); } else { value = p.getValue(); } if (value != null) { props.put(name, value); } } return props; }
private Map<String, Object> getProperties(ComplexAttribute feature) { Map<String, Object> props = new TreeMap<>(); for (Property p : feature.getProperties()) { if (!(p instanceof Attribute) || (p instanceof GeometryAttribute)) { continue; } String name = p.getName().getLocalPart(); Object value; if (p instanceof ComplexAttribute) { value = getProperties((ComplexAttribute) p); } else { value = p.getValue(); } if (value != null) { props.put(name, value); } } return props; }
/** * Helper method that try to extract a simple content from a complex attribute, NULL is returned * if no simple content is present. */ private Object getSimpleContent(ComplexAttribute property) { Collection<Property> properties = property.getProperties(); if (properties.isEmpty() || properties.size() > 1) { // no properties or more than property mean no simple content return null; } Property simpleContent = getElementAt(properties, 0); if (simpleContent == null) { // simple content is NULL end extraction here return null; } Name name = simpleContent.getName(); if (name == null || !name.getLocalPart().equals("simpleContent")) { // not a simple content node return null; } Object value = simpleContent.getValue(); if (value instanceof Number || value instanceof String || value instanceof Character) { // the extract value is a simple Java type return value; } // not a valid simple content type return null; }
/** 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(); } }
@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; }