/** * Builds an attribute descriptor first building an attribute type from internal state. * * <p>If {@link #crs} has been set via {@link #setCRS(CoordinateReferenceSystem)} the internal * attribute type will be built via {@link #buildGeometryType()}, otherwise it will be built via * {@link #buildType()}. * * <p>This method calls through to {@link #buildDescriptor(String, AttributeType)}. * * @param name The name of the descriptor. * @see #buildDescriptor(String, AttributeType) */ public AttributeDescriptor buildDescriptor(String name) { setName(name); if (binding == null) throw new IllegalStateException("No binding has been provided for this attribute"); if (crs != null || Geometry.class.isAssignableFrom(binding)) { return buildDescriptor(name, buildGeometryType()); } else { return buildDescriptor(name, buildType()); } }
descriptor = attributeBuilder.buildDescriptor(name, type); } else { AttributeType type = attributeBuilder.buildType(); descriptor = attributeBuilder.buildDescriptor(name, type);
/** * Create a fake property to store arbitrary text in a complex type. * * <p>Passed in value is converted to a string and then stored in the special <code> * simpleContent</code> attribute. * * @param type * @param value * @return */ Attribute buildTextContent(AttributeType type, Object value) { AttributeTypeBuilder atb = new AttributeTypeBuilder(); atb.setName(ComplexFeatureConstants.SIMPLE_CONTENT.getLocalPart()); atb.setBinding(String.class); AttributeType textContentType = atb.buildType(); return buildSimpleContentInternal(textContentType, value); }
builder.setName("date"); builder.setBinding(Date.class); hack.put(new NameImpl(XS.DATETIME), builder.buildType());
@Override protected SimpleFeatureType buildTargetFeatureType() { // create schema SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); for (AttributeDescriptor descriptor : delegate.getSchema().getAttributeDescriptors()) { if (!(descriptor.getType() instanceof GeometryTypeImpl) || (!delegate.getSchema().getGeometryDescriptor().equals(descriptor))) { tb.add(descriptor); } else { AttributeTypeBuilder builder = new AttributeTypeBuilder(); builder.setBinding(MultiPolygon.class); AttributeDescriptor attributeDescriptor = builder.buildDescriptor(descriptor.getLocalName(), builder.buildType()); tb.add(attributeDescriptor); if (tb.getDefaultGeometry() == null) { tb.setDefaultGeometry(descriptor.getLocalName()); } } } tb.setDescription(delegate.getSchema().getDescription()); tb.setCRS(delegate.getSchema().getCoordinateReferenceSystem()); tb.setName(delegate.getSchema().getName()); return tb.buildFeatureType(); }
att = ab.buildDescriptor(name, ab.buildType());
/** * Builds an attribute descriptor first building an attribute type from * internal state. * <p> * If {@link #crs} has been set via {@link #setCRS(CoordinateReferenceSystem)} * the internal attribute type will be built via {@link #buildGeometryType()}, * otherwise it will be built via {@link #buildType()}. * </p> * <p> * This method calls through to {@link #buildDescriptor(String, AttributeType)}. * </p> * @param name The name of the descriptor. * * @see #buildDescriptor(String, AttributeType) */ public AttributeDescriptor buildDescriptor( String name ) { setName(name); if(binding == null) throw new IllegalStateException("No binding has been provided for this attribute"); if ( crs != null || Geometry.class.isAssignableFrom(binding)) { return buildDescriptor(name, buildGeometryType()); } else { return buildDescriptor(name, buildType()); } }
descriptor = attributeBuilder.buildDescriptor(name, type); } else { AttributeType type = attributeBuilder.buildType(); descriptor = attributeBuilder.buildDescriptor(name, type);
.getCoordinateReferenceSystem()); AttributeDescriptor attributeDescriptor = builder.buildDescriptor(descriptor.getName(), builder.buildType()); tb.add(attributeDescriptor); } else {
descriptor = attributeBuilder.buildDescriptor(name, type); } else { AttributeType type = attributeBuilder.buildType(); descriptor = attributeBuilder.buildDescriptor(name, type);
protected SimpleFeatureType getFeatureType(SimpleFeatureType origType, JoiningQuery query) throws IOException { SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.init(origType); AttributeTypeBuilder ab = new AttributeTypeBuilder(); for (int i=0; i<query.getQueryJoins().size(); i++) { for (int j=0; j<query.getQueryJoins().get(i).getSortBy().length; j++) { ab.setBinding(String.class); builder.add(ab.buildDescriptor(new NameImpl(FOREIGN_ID) + "_" + i + "_" + j, ab.buildType() ) ); } } return builder.buildFeatureType(); }
public void testAttributeBuilder() { FilterFactory ff = CommonFactoryFinder.getFilterFactory(); AttributeTypeBuilder builder = new AttributeTypeBuilder(); builder.binding(Integer.class); builder.minOccurs(1).maxOccurs(1); builder.defaultValue(0); builder.name("percent").description("Percent between 0 and 100"); builder.restriction(ff.greaterOrEqual(ff.property("."), ff.literal(0))) .restriction(ff.lessOrEqual(ff.property("."), ff.literal(100))); final AttributeType PERCENT = builder.buildType(); builder.minOccurs(1).maxOccurs(1); builder.defaultValue(0); builder.name("percent").description("Percent between 0 and 100"); AttributeDescriptor a = builder.buildDescriptor("a", PERCENT); assertSame(a.getType(), PERCENT); assertEquals(a.getDefaultValue(), 0); Filter restrictions = ff.and(PERCENT.getRestrictions()); assertTrue(restrictions.evaluate(50)); assertFalse(restrictions.evaluate(150)); }
private AttributeDescriptor buildSimpleDescriptor(Name name, Class binding) { AttributeTypeBuilder ab = new AttributeTypeBuilder(); ab.name(name.getLocalPart()).namespaceURI(name.getNamespaceURI()); ab.setBinding(binding); AttributeDescriptor descriptor = ab.buildDescriptor(name, ab.buildType()); return descriptor; }
mappedDescriptor = ab.buildDescriptor(new NameImpl(namespaceURI, name), at); } else { AttributeType at = ab.buildType(); mappedDescriptor = ab.buildDescriptor(new NameImpl(namespaceURI, name), at);
private AttributeDescriptor buildAttributeDescriptor( SolrAttribute solrAttribute, GeometryConfig geometry) { AttributeTypeBuilder attributeBuilder = new AttributeTypeBuilder(); if (geometry == null) { attributeBuilder.setName(solrAttribute.getName()); attributeBuilder.setBinding(solrAttribute.getType()); return attributeBuilder.buildDescriptor( solrAttribute.getName(), attributeBuilder.buildType()); } attributeBuilder.setCRS(geometry.getCrs()); attributeBuilder.setName(geometry.getAttributeName()); attributeBuilder.setBinding(geometry.getType()); return attributeBuilder.buildDescriptor( geometry.getAttributeName(), attributeBuilder.buildGeometryType()); }
ab.setName(attribute.getName()); ab.setBinding(attribute.getType()); att = ab.buildDescriptor(attribute.getName(), ab.buildType());
@Override protected SimpleFeatureType buildTargetFeatureType() { // create schema SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); for (AttributeDescriptor descriptor : delegate.getSchema().getAttributeDescriptors()) { if (!(descriptor.getType() instanceof GeometryTypeImpl) || (!delegate.getSchema().getGeometryDescriptor().equals(descriptor))) { tb.add(descriptor); } else { AttributeTypeBuilder builder = new AttributeTypeBuilder(); builder.setBinding(MultiPolygon.class); AttributeDescriptor attributeDescriptor = builder.buildDescriptor(descriptor .getLocalName(), builder.buildType()); tb.add(attributeDescriptor); if(tb.getDefaultGeometry() == null) { tb.setDefaultGeometry(descriptor.getLocalName()); } } } tb.setDescription(delegate.getSchema().getDescription()); tb.setCRS(delegate.getSchema().getCoordinateReferenceSystem()); tb.setName(delegate.getSchema().getName()); return tb.buildFeatureType(); }
builder.setCRS(delegate.getSchema().getCoordinateReferenceSystem()); AttributeDescriptor attributeDescriptor = builder.buildDescriptor( descriptor.getName(), builder.buildType()); tb.add(attributeDescriptor); } else {
.getCoordinateReferenceSystem()); AttributeDescriptor attributeDescriptor = builder.buildDescriptor(descriptor .getName(), builder.buildType()); tb.add(attributeDescriptor); } else {