public Object get(Object object, String xpath, Class target) throws IllegalArgumentException { if (object instanceof Attribute) return ((Attribute) object).getValue(); else return object; }
public Object getValue() { return delegate.getValue(); }
public Object convert(Object source, Class target) { if (source instanceof Attribute) { // get the attribute value Attribute attribute = (Attribute) source; Object value = attribute.getValue(); // let the available converters do their job return Converters.convert(value, target); } // this should not happen, anyway we can only handle attributes return null; } };
protected Object getValue(final Expression expression, Object sourceFeature) { Object value = expression.evaluate(sourceFeature); if (value instanceof Attribute) { value = ((Attribute) value).getValue(); } return value; }
/** * Extract the value that might be wrapped in an attribute. If the value is a collection, gets * the first value. * * @param value * @return */ @SuppressWarnings("rawtypes") private Object extractAttributeValue(Object value) { if (value == null) { return null; } while (value instanceof Attribute) { // get real value value = ((Attribute) value).getValue(); } if (value == null) { return null; } if (value instanceof Collection) { if (((Collection) value).isEmpty()) { return null; } value = ((Collection) value).iterator().next(); while (value instanceof Attribute) { value = ((Attribute) value).getValue(); } } return value; }
protected Object peekValue(Object source, Expression prop) { Object o = prop.evaluate(source); if (o instanceof Attribute) { o = ((Attribute) o).getValue(); } return o; }
/** * Validates anattribute. <br> * * <p>Same result as calling: * * <pre> * <code> * validate(attribute.type(), attribute) * </code> * </pre> * * @param attribute The attribute. * @throws IllegalAttributeException In the event that content violates any restrictions * specified by the attribute. */ public static void validate(Attribute attribute) throws IllegalAttributeException { validate(attribute, attribute.getValue()); }
public Object convert(Object source, Class target) throws Exception { if (source instanceof ComplexAttribute) { Collection<? extends Property> valueMap = ((ComplexAttribute) source).getValue(); if (valueMap.isEmpty() || valueMap.size() > 1) { return null; } else { // there should only be one value source = valueMap.iterator().next(); if (AttributeImpl.class.equals(source.getClass())) { return Converters.convert(((Attribute) source).getValue(), target); } } } return null; } };
/** * Register the target of any hrefs' with the target id specified, to the attribute provided. * This has two effects: it puts the id and value in the discoveredComplexAttributes object so * that if we come across a href pointing to this id in the future, we'll be able to just use * the attribute provided as the value for that href. Secondly: it loops over any * placeholderComplexAttributes to see if any of them were waiting for this target, if their are * any they will have their values changed from the placeholder value to the value provided. * * @param id The id of the gml target. * @param value The parsed attribute value for this id. */ private void registerGmlTarget(String id, Attribute value) { // Add the value to the discoveredComplexAttributes object: discoveredComplexAttributes.put(id, value); // Check whether anything is waiting for this attribute and, if so, // populate them. if (placeholderComplexAttributes.containsKey(id)) { for (Attribute placeholderComplexAttribute : this.placeholderComplexAttributes.get(id)) { placeholderComplexAttribute.setValue(value.getValue()); } } }
/** * Ensures an attribute value is withing the restrictions of the AttributeDescriptor and * AttributeType. * * @param attribute * @return true if the attribute value is valid */ public static boolean isValid(Attribute attribute) { try { validate(attribute.getType(), attribute, attribute.getValue(), false); return true; } catch (IllegalAttributeException invalid) { return false; } } /**
@Override public List getProperties(Object object, XSDElementDeclaration element) throws Exception { ArrayList list = new ArrayList(); Object member = super.getProperty(object, org.geotools.gml3.GML._Feature); if (member != null) { // check for joined feature if (GMLEncodingUtils.isJoinedFeature(member)) { list.add(new Object[] {WFS.Tuple, GMLEncodingUtils.splitJoinedFeature(member)}); } else { list.add(new Object[] {GML.AbstractFeature, object}); } } else if (object instanceof FeatureCollectionType) { list.add(new Object[] {WFS.FeatureCollection, object}); } else if (object instanceof Attribute) { // encoding a ValueCollection Attribute att = (Attribute) object; list.add(new Object[] {particle(att), att.getValue()}); } return list; }
/** * 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; } }
Attribute att = (Attribute) itr.next(); if (att instanceof GeometryAttribute) { if (defaultGeometry.equals(att.getValue())) { feature.setDefaultGeometryProperty((GeometryAttribute) att);
/** * 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; }
private void traverse(Attribute f) { Object value; value = f.getValue(); if (f instanceof ComplexAttribute) { Collection values = (Collection) value; for (Iterator it = values.iterator(); it.hasNext(); ) { Attribute att = (Attribute) it.next(); assertNotNull(att); traverse(att); } } } }
add( att.getIdentifier() == null ? null : att.getIdentifier().toString(), att.getValue(), att.getName()); } else if (property instanceof Association) {
Attribute sampledFeatureVal = (Attribute) sampledFeatureName.evaluate(feature); assertNotNull("sa:sampledFeature evaluated to null", sampledFeatureVal); assertEquals(0, ((Collection) sampledFeatureVal.getValue()).size()); Map attributes = (Map) sampledFeatureVal.getUserData().get(Attributes.class); assertNotNull(attributes); assertNotNull(value.getValue()); assertNotNull(geom.getValue()); Object valueContent = geom.getValue(); Date sampleTimePosition = (Date) valueContent; Calendar cal = Calendar.getInstance();
.getProperty( new NameImpl(GCO.NAMESPACE, "Integer"))) .getValue());