public void encode(CSWRecordsResult response, Feature f) { String element = "csw:" + getRecordElement(response); start(element); List<Name> elements = getElements(response); if(properties != null && !properties.isEmpty()) { for (Property p : properties) { encodeProperty(f, p); element("dc:title", null); encodeProperty(f, p); addAttribute(attributes, "crs", CSWRecordDescriptor.DEFAULT_CRS_NAME); start("ows:BoundingBox", attributes); element("ows:LowerCorner", minx + " " + miny); element("ows:UpperCorner", maxx + " " + maxy); end("ows:BoundingBox"); } catch (Exception e) { throw new ServiceException("Failed to encode the current record: " + f, end(element);
private void encodeProperty(Feature f, Property p) { if (p.getType() == CSWRecordDescriptor.SIMPLE_LITERAL) { encodeSimpleLiteral(p); } else if (CSWRecordDescriptor.RECORD_BBOX_NAME.equals(p.getName())) { // skip it for the moment, it is constrained to be last } else { throw new IllegalArgumentException("Don't know how to encode property " + p + " in record " + f); } }
public void encode(CSWRecordsResult response, Feature f) { String element = "csw:" + getRecordElement(response); start(element); List<Name> elements = getElements(response); if (properties != null && !properties.isEmpty()) { for (Property p : properties) { encodeProperty(f, p); element("dc:title", null); encodeProperty(f, p); addAttribute(attributes, "crs", CSWRecordDescriptor.DEFAULT_CRS_NAME); start("ows:BoundingBox", attributes); element("ows:LowerCorner", minx + " " + miny); element("ows:UpperCorner", maxx + " " + maxy); end("ows:BoundingBox"); } catch (Exception e) { throw new ServiceException( end(element);
private void encodeSimpleLiteral(Property p) { ComplexAttribute sl = (ComplexAttribute) p; String scheme = sl.getProperty("scheme") == null ? null : (String) sl.getProperty("scheme").getValue(); String value = sl.getProperty("value") == null ? "" : (String) sl.getProperty("value").getValue(); Name dn = p.getDescriptor().getName(); String name = dn.getLocalPart(); String prefix = CSWRecordDescriptor.NAMESPACES.getPrefix(dn.getNamespaceURI()); if (scheme == null) { element(prefix + ":" + name, value); } else { AttributesImpl attributes = new AttributesImpl(); addAttribute(attributes, "scheme", scheme); element(prefix + ":" + name, value, attributes); } }
private void encodeSimpleLiteral(Property p) { ComplexAttribute sl = (ComplexAttribute) p; String scheme = sl.getProperty("scheme") == null ? null : (String) sl.getProperty("scheme").getValue(); String value = sl.getProperty("value") == null? "" : (String) sl.getProperty("value").getValue(); Name dn = p.getDescriptor().getName(); String name = dn.getLocalPart(); String prefix = CSWRecordDescriptor.NAMESPACES.getPrefix(dn.getNamespaceURI()); if (scheme == null) { element(prefix + ":" + name, value); } else { AttributesImpl attributes = new AttributesImpl(); addAttribute(attributes, "scheme", scheme); element(prefix + ":" + name, value, attributes); } }
@Override public Translator createTranslator(ContentHandler handler) { return new CSWRecordTranslator(handler); }
@Override public Translator createTranslator(ContentHandler handler) { return new CSWRecordTranslator(handler); }
private void encodeProperty(Feature f, Property p) { if (p.getType() == CSWRecordDescriptor.SIMPLE_LITERAL) { encodeSimpleLiteral(p); } else if (CSWRecordDescriptor.RECORD_BBOX_NAME.equals(p.getName())) { // skip it for the moment, it is constrained to be last } else { throw new IllegalArgumentException( "Don't know how to encode property " + p + " in record " + f); } }