/** * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element, * java.lang.Object, org.geotools.xml.PrintHandler, java.util.Map) */ public void encode(Element element, Object value, PrintHandler output, Map hints) throws IOException { if (!canEncode(element, value, hints)) { return; } Id ff = (Id) value; Set<String> fids = (Set) ff.getIDs(); AttributesImpl att = new AttributesImpl(); att.addAttribute(null, null, null, null, null); output.startElement(element.getNamespace(), "Filter", null); for (String fid : fids) { att.setAttribute( 0, element.getNamespace().toString(), attrs[0].getName(), null, "anyUri", fid); output.element(element.getNamespace(), element.getName(), att); } output.endElement(element.getNamespace(), "Filter"); } }
private void setAttribute(AttributesImpl atts, String localName, String value) { int index; index = atts.getIndex("", localName); if (index < 0) { atts.addAttribute("", localName, localName, CDATA, value); } else { atts.setAttribute(index, "", localName, localName, CDATA, value); } }
@Override public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException { AttributesImpl resolvedAttributes = new AttributesImpl(atts); for (int i = 0; i < atts.getLength(); i++) { resolvedAttributes.setAttribute(i, atts.getURI(i), atts.getLocalName(i), atts.getQName(i), atts.getType(i), resolve(atts.getValue(i))); } if (inElement) { flushBuffer(false); } inElement = true; target.startElement(uri, localName, qName, resolvedAttributes); }
@Override public void setAttribute(int index, String uri, String localName, String qName, String type, String value) { qNames.remove(super.getQName(index)); if (qNames.add(qName)) { super.setAttribute(index, uri, localName, qName, type, value); } else { handleDuplicate(qName, value); } }
@Override public void setAttribute(int index, String uri, String localName, String qName, String type, String value) { qNames.remove(super.getQName(index)); if (qNames.add(qName)) { super.setAttribute(index, uri, localName, qName, type, value); } else { handleDuplicate(qName, value); } }
/** * Add or set attribute. * * @param atts attributes * @param uri namespace URI * @param localName local name * @param qName qualified name * @param type attribute type * @param value attribute value */ public static void addOrSetAttribute(final AttributesImpl atts, final String uri, final String localName, final String qName, final String type, final String value) { final int i = atts.getIndex(qName); if (i != -1) { atts.setAttribute(i, uri, localName, qName, type, value); } else { atts.addAttribute(uri, localName, qName, type, value); } }
@Override public void setAttribute(int index, String uri, String localName, String qName, String type, String value) { qNames.remove(super.getQName(index)); if (qNames.add(qName)) { super.setAttribute(index, uri, localName, qName, type, value); } else { handleDuplicate(qName, value); } }
/** * Updates the attributes so that the attributes include the new attribute. * * This method will automatically add or update the attribute. * * @param atts The attributes * @param name The name of the attribute to update * @param value The value of the attribute to update * * @return A new set of attributes */ private static Attributes update(Attributes atts, String name, String value) { AttributesImpl updated = new AttributesImpl(atts); int i = atts.getIndex(name); if (i != -1) { updated.setAttribute(i, "", name, name, "CDATA", value); } else { updated.addAttribute("", name, name, "CDATA", value); } return updated; }
@Override public void setAttribute(int index, String uri, String localName, String qName, String type, String value) { qNames.remove(super.getQName(index)); if (qNames.add(qName)) { super.setAttribute(index, uri, localName, qName, type, value); } else { handleDuplicate(qName, value); } }
@Override public void setAttribute(int index, String uri, String localName, String qName, String type, String value) { qNames.remove(super.getQName(index)); if (qNames.add(qName)) { super.setAttribute(index, uri, localName, qName, type, value); } else { handleDuplicate(qName, value); } }
/** * Add or set attribute. * * @param uri namespace URI * @param localName local name * @param qName qualified name * @param type attribute type * @param value attribute value * @return this builder */ public AttributesBuilder add(final String uri, final String localName, final String qName, final String type, final String value) { final int i = atts.getIndex(uri, localName); if (i != -1) { atts.setAttribute(i, uri, localName, qName, type, value); } else { atts.addAttribute(uri, localName, qName, type, value); } return this; }
this.setAttribute(index, uri, localName, qName, type, value); else super.addAttribute(uri, localName, qName, type, value);
/** * Add the contents of the attribute list to this list. * * @param atts List of attributes to add to this list */ public void addAttributes(Attributes atts) { int nAtts = atts.getLength(); for (int i = 0; i < nAtts; i++) { String uri = atts.getURI(i); if (null == uri) uri = ""; String localName = atts.getLocalName(i); String qname = atts.getQName(i); int index = this.getIndex(uri, localName); // System.out.println("MutableAttrListImpl#addAttributes: "+uri+":"+localName+", "+index+", "+atts.getQName(i)+", "+this); if (index >= 0) this.setAttribute(index, uri, localName, qname, atts.getType(i), atts.getValue(i)); else addAttribute(uri, localName, qname, atts.getType(i), atts.getValue(i)); } }
/** * Add the contents of the attribute list to this list. * * @param atts List of attributes to add to this list */ public void addAttributes(Attributes atts) { int nAtts = atts.getLength(); for (int i = 0; i < nAtts; i++) { String uri = atts.getURI(i); if (null == uri) uri = ""; String localName = atts.getLocalName(i); String qname = atts.getQName(i); int index = this.getIndex(uri, localName); // System.out.println("MutableAttrListImpl#addAttributes: "+uri+":"+localName+", "+index+", "+atts.getQName(i)+", "+this); if (index >= 0) this.setAttribute(index, uri, localName, qname, atts.getType(i), atts.getValue(i)); else addAttribute(uri, localName, qname, atts.getType(i), atts.getValue(i)); } }
protected void addAttribute(String qname, String value) { int index = _attributes.getIndex(qname); if (index != -1) { _attributes.setAttribute(index, "", Util.getLocalName(qname), qname, "CDATA", value); } else { _attributes.addAttribute("", Util.getLocalName(qname), qname, "CDATA", value); } }
protected void addAttribute(String qname, String value) { int index = _attributes.getIndex(qname); if (index != -1) { _attributes.setAttribute(index, "", Util.getLocalName(qname), qname, "CDATA", value); } else { _attributes.addAttribute("", Util.getLocalName(qname), qname, "CDATA", value); } }
private void set(AttributesImpl attrs, String uri, String localName, String qName, XmlAttributeType type, String value) { for (int i = 0, sz = attrs.getLength(); i < sz; i++) { if (Objects.equals(qName, attrs.getQName(i)) || Objects.equals(uri, attrs.getURI(i)) && Objects.equals(localName, attrs.getLocalName(i))) { attrs.setAttribute(i, uri, localName, qName, type.name(), value); return; } } attrs.addAttribute(uri, localName, qName, type.name(), value); } }
private void set(AttributesImpl attrs, String uri, String localName, String qName, XmlAttributeType type, String value) { for (int i = 0, sz = attrs.getLength(); i < sz; i++) { if (Objects.equals(qName, attrs.getQName(i)) || Objects.equals(uri, attrs.getURI(i)) && Objects.equals(localName, attrs.getLocalName(i))) { attrs.setAttribute(i, uri, localName, qName, type.name(), value); return; } } attrs.addAttribute(uri, localName, qName, type.name(), value); } }
/** * As currently GeoServer does not have support for nested layers, this * method declares a <code>LayerDescription</code> element for each * featuretype requested. * * @param req */ private void handleLayers(DescribeLayerRequest req) { MapLayerInfo layer; String url = RequestUtils.proxifiedBaseURL(req.getBaseUrl(),req.getServiceConfig().getGeoServer().getProxyBaseUrl()) + "wfs/WfsDispatcher?"; AttributesImpl layerAtts = new AttributesImpl(); layerAtts.addAttribute("", "name", "name", "", ""); layerAtts.addAttribute("", "wfs", "wfs", "", url); AttributesImpl queryAtts = new AttributesImpl(); queryAtts.addAttribute("", "typeName", "typeName", "", ""); for (Iterator it = req.getLayers().iterator(); it.hasNext();) { layer = (MapLayerInfo) it.next(); layerAtts.setAttribute(0, "", "name", "name", "", layer.getName()); start("LayerDescription", layerAtts); queryAtts.setAttribute(0, "", "typeName", "typeName", "", layer.getName()); element("Query", null, queryAtts); end("LayerDescription"); } } }
/** * Encodes a <code>DCPType</code> fragment for HTTP GET and POST methods. * * @param getUrl the URL of the onlineresource for HTTP GET method requests * @param postUrl the URL of the onlineresource for HTTP POST method requests */ private void handleDcpType(String getUrl, String postUrl) { AttributesImpl orAtts = new AttributesImpl(); orAtts.addAttribute(XLINK_NS, "type", "xlink:type", "", "simple"); orAtts.addAttribute(XLINK_NS, "href", "xlink:href", "", getUrl); start("DCPType"); start("HTTP"); if (getUrl != null) { start("Get"); element("OnlineResource", null, orAtts); end("Get"); } if (postUrl != null) { orAtts.setAttribute(1, "", "href", "xlink:href", "", postUrl); start("Post"); element("OnlineResource", null, orAtts); end("Post"); } end("HTTP"); end("DCPType"); }