コード例 #1
0
  public Element AbstractFeatureTypeEncode(
      Object object, Document document, Element value, XSDIdRegistry idSet) {
    Feature feature = (Feature) object;
    String id = feature.getIdentifier().getID();
    Name typeName;
    if (feature.getDescriptor() == null) {
      // no descriptor, assume WFS feature type name is the same as the name of the content
      // model type
      typeName = feature.getType().getName();
    } else {
      // honour the name set in the descriptor
      typeName = feature.getDescriptor().getName();
    }
    Element encoding =
        document.createElementNS(typeName.getNamespaceURI(), typeName.getLocalPart());
    if (!(feature instanceof SimpleFeature) && idSet != null) {
      if (idSet.idExists(id)) {
        // XSD type ids can only appear once in the same document, otherwise the document is
        // not schema valid. Attributes of the same ids should be encoded as xlink:href to
        // the existing attribute.
        encoding.setAttributeNS(XLINK.NAMESPACE, XLINK.HREF.getLocalPart(), "#" + id.toString());
        // make sure the attributes aren't encoded
        feature.setValue(Collections.emptyList());
        return encoding;
      } else {
        idSet.add(id);
      }
    }
    encoding.setAttributeNS(gml.getNamespaceURI(), "id", id);
    encodeClientProperties(feature, value);

    return encoding;
  }
コード例 #2
0
  /**
   * Check if the geometry contains a feature which id is pre-existing in the document. If it's
   * true, make the geometry empty and add xlink:href property
   *
   * @param value The complex attribute value
   * @param att The complex attribute itself
   */
  private void checkExistingId(Geometry geom) {
    if (geom != null) {
      String id = GML2EncodingUtils.getID(geom);

      if (id != null && idSet.idExists(id)) {
        // make geometry empty, href will added by getproperty
        makeEmpty = true;

      } else if (id != null) {

        idSet.add(id);
      }
    }
    return;
  }