public List<AttributeTypeInfo> loadAttributes(FeatureTypeInfo info) throws IOException { List<AttributeTypeInfo> attributes = new ArrayList(); FeatureType ft = getFeatureType(info); for (PropertyDescriptor pd : ft.getDescriptors()) { AttributeTypeInfo att = catalog.getFactory().createAttribute(); att.setFeatureType(info); att.setName(pd.getName().getLocalPart()); att.setMinOccurs(pd.getMinOccurs()); att.setMaxOccurs(pd.getMaxOccurs()); att.setNillable(pd.isNillable()); att.setBinding(pd.getType().getBinding()); int length = FeatureTypes.getFieldLength(pd); if (length > 0) { att.setLength(length); } attributes.add(att); } return attributes; }
/** * Extracts the AttributeTypeInfo by copying them from the specified feature type. * * @param ft The schema to be harvested * @param info The optional feature type info from which all the attributes belong to */ public List<AttributeTypeInfo> getAttributes(FeatureType ft, FeatureTypeInfo info) { List<AttributeTypeInfo> attributes = new ArrayList<AttributeTypeInfo>(); for (PropertyDescriptor pd : ft.getDescriptors()) { AttributeTypeInfo att = catalog.getFactory().createAttribute(); att.setFeatureType(info); att.setName(pd.getName().getLocalPart()); att.setMinOccurs(pd.getMinOccurs()); att.setMaxOccurs(pd.getMaxOccurs()); att.setNillable(pd.isNillable()); att.setBinding(pd.getType().getBinding()); int length = FeatureTypes.getFieldLength(pd); if (length > 0) { att.setLength(length); } attributes.add(att); } return attributes; }
/** * Returns if a property can contain null values, or not. If we don't have the schema * information, or we don't know the property, we are going to assume the property is nillable * to stay on the safe side */ private boolean isNillable(String name) { if (schema == null) { return true; } PropertyDescriptor descriptor = schema.getDescriptor(name); return descriptor == null || descriptor.isNillable(); } }
public boolean isNillable() { return getDescriptor().isNillable(); }
if (propertyDescriptor.isNillable()) { value = (Property) expectedClass.cast(null); } else {
if (propertyDescriptor.isNillable() && AttributeDescriptor.class.isAssignableFrom( propertyDescriptor.getClass())) {
result = true; } else if (((Property) o).getDescriptor().getMinOccurs() > 0) { if (((Property) o).getDescriptor().isNillable()) {
if (value != null || descriptor.isNillable()) { // add
public boolean isNillable() { return getDescriptor().isNillable(); }
private void writeProperty(PropertyDescriptor attr, DataOutput data) throws IOException { writeName(attr.getName(), data); data.writeBoolean(attr.isNillable()); data.writeInt(attr.getMinOccurs()); data.writeInt(attr.getMaxOccurs()); writePropertyType(attr.getType(), data); } }
private void writeProperty(PropertyDescriptor attr, DataOutput data) throws IOException { writeName(attr.getName(), data); data.writeBoolean(attr.isNillable()); data.writeInt(attr.getMinOccurs()); data.writeInt(attr.getMaxOccurs()); writePropertyType(attr.getType(), data); } }
private void writeProperty(PropertyDescriptor attr, DataOutput data) throws IOException { writeName(attr.getName(), data); data.writeBoolean(attr.isNillable()); data.writeInt(attr.getMinOccurs()); data.writeInt(attr.getMaxOccurs()); writePropertyType(attr.getType(), data); } }
private static void writeProperty(PropertyDescriptor attr, DataOutput data) throws IOException { writeName(attr.getName(), data); data.writeBoolean(attr.isNillable()); data.writeInt(attr.getMinOccurs()); data.writeInt(attr.getMaxOccurs()); writePropertyType(attr.getType(), data); }
private static void writeProperty(PropertyDescriptor attr, DataOutput data) throws IOException { writeName(attr.getName(), data); data.writeBoolean(attr.isNillable()); data.writeInt(attr.getMinOccurs()); data.writeInt(attr.getMaxOccurs()); writePropertyType(attr.getType(), data); }
private void printAttributeDescriptor(Writer w, PropertyDescriptor attrib) throws IOException { print(w, attrib.getName().toString()); print(w, "\t"); print(w, FieldType.forBinding(attrib.getType().getBinding()).name()); print(w, "\t"); print(w, Integer.toString(attrib.getMinOccurs())); print(w, "\t"); print(w, Integer.toString(attrib.getMaxOccurs())); print(w, "\t"); print(w, Boolean.toString(attrib.isNillable())); PropertyType attrType = attrib.getType(); if (attrType instanceof GeometryType) { GeometryType gt = (GeometryType) attrType; CoordinateReferenceSystem crs = gt.getCoordinateReferenceSystem(); String crsText = CrsTextSerializer.serialize(crs); print(w, "\t"); println(w, crsText); } else { println(w, ""); } }
private void printAttributeDescriptor(Writer w, PropertyDescriptor attrib) throws IOException { print(w, attrib.getName().toString()); print(w, "\t"); print(w, FieldType.forBinding(attrib.getType().getBinding()).name()); print(w, "\t"); print(w, Integer.toString(attrib.getMinOccurs())); print(w, "\t"); print(w, Integer.toString(attrib.getMaxOccurs())); print(w, "\t"); print(w, Boolean.toString(attrib.isNillable())); PropertyType attrType = attrib.getType(); if (attrType instanceof GeometryType) { GeometryType gt = (GeometryType) attrType; CoordinateReferenceSystem crs = gt.getCoordinateReferenceSystem(); String crsText = CrsTextSerializer.serialize(crs); print(w, "\t"); println(w, crsText); } else { println(w, ""); } }
public void writeFeatureType(RevFeatureType featureType, String tag) throws StreamWriterException { out.writeStartElement(tag); writeElement("id", featureType.getId().toString()); writeElement("name", featureType.getName().toString()); ImmutableList<PropertyDescriptor> descriptors = featureType.descriptors(); out.writeStartArray("attribute"); for (PropertyDescriptor descriptor : descriptors) { out.writeStartArrayElement("attribute"); writeElement("name", descriptor.getName().toString()); writeElement("type", FieldType.forBinding(descriptor.getType().getBinding()).name()); writeElement("minoccurs", Integer.toString(descriptor.getMinOccurs())); writeElement("maxoccurs", Integer.toString(descriptor.getMaxOccurs())); writeElement("nillable", Boolean.toString(descriptor.isNillable())); PropertyType attrType = descriptor.getType(); if (attrType instanceof GeometryType) { GeometryType gt = (GeometryType) attrType; CoordinateReferenceSystem crs = gt.getCoordinateReferenceSystem(); String crsText = CrsTextSerializer.serialize(crs); writeElement("crs", crsText); } out.writeEndArrayElement(); } out.writeEndArray(); out.writeEndElement(); }
@Override public void funnel(PropertyDescriptor descriptor, PrimitiveSink into) { NameFunnel.funnel(descriptor.getName(), into); PropertyType attrType = descriptor.getType(); NameFunnel.funnel(attrType.getName(), into); FieldType type = FieldType.forBinding(attrType.getBinding()); into.putInt(type.getTag()); into.putBoolean(descriptor.isNillable()); into.putInt(descriptor.getMaxOccurs()); into.putInt(descriptor.getMinOccurs()); if (descriptor instanceof GeometryDescriptor) { CoordinateReferenceSystem crs; crs = ((GeometryDescriptor) descriptor).getCoordinateReferenceSystem(); String srsName; if (crs == null) { srsName = RevObjects.NULL_CRS_IDENTIFIER; } else { srsName = CRS.toSRS(crs); } NullableStringFunnel.funnel(srsName, into); } } };
@Override public void funnel(PropertyDescriptor descriptor, PrimitiveSink into) { NameFunnel.funnel(descriptor.getName(), into); PropertyType attrType = descriptor.getType(); NameFunnel.funnel(attrType.getName(), into); GtEntityType type = GtEntityType.fromBinding(attrType.getBinding()); into.putInt(type.getValue()); into.putBoolean(descriptor.isNillable()); into.putInt(descriptor.getMaxOccurs()); into.putInt(descriptor.getMinOccurs()); if (descriptor instanceof GeometryDescriptor) { CoordinateReferenceSystem crs; crs = ((GeometryDescriptor) descriptor).getCoordinateReferenceSystem(); String srsName; if (crs == null) { srsName = "urn:ogc:def:crs:EPSG::0"; } else { srsName = CRS.toSRS(crs); } NullableStringFunnel.funnel(srsName, into); } } };
@Override public void funnel(PropertyDescriptor descriptor, PrimitiveSink into) { NameFunnel.funnel(descriptor.getName(), into); PropertyType attrType = descriptor.getType(); NameFunnel.funnel(attrType.getName(), into); FieldType type = FieldType.forBinding(attrType.getBinding()); into.putInt(type.getTag()); into.putBoolean(descriptor.isNillable()); into.putInt(descriptor.getMaxOccurs()); into.putInt(descriptor.getMinOccurs()); if (descriptor instanceof GeometryDescriptor) { CoordinateReferenceSystem crs; crs = ((GeometryDescriptor) descriptor).getCoordinateReferenceSystem(); String srsName; if (crs == null) { srsName = RevObjects.NULL_CRS_IDENTIFIER; } else { srsName = CRS.toSRS(crs); } NullableStringFunnel.funnel(srsName, into); } } };