File img = imageParser.requestSave(filename); String newSrc = img.toURI().toString(); newAttrs.setValue(i, newSrc); } catch (IOException e) { System.err.println("Error creating temp image file " + filename);
File img = imageParser.requestSave(filename); String newSrc = img.toURI().toString(); newAttrs.setValue(i, newSrc); } catch(IOException e) { System.err.println("Error creating temp image file " + filename);
String v = newAttributes.getValue(att); if (v.startsWith("data:")) { newAttributes.setValue(att, "data:"); newAttributes.setValue(att, resolve(newAttributes.getValue(att))); } else if (isObject && "codebase".equals(normAttrName)) { newAttributes.setValue(att, codebase); } else if (isObject && ("data".equals(normAttrName) || "classid".equals(normAttrName))) { newAttributes.setValue( att, resolve(codebase, newAttributes.getValue(att)));
idatts.setValue(0, f.getID()); output.startElement(ftContext.featureQualifiedName, idatts);
/** * Write property element. * * @param category * String category * @param name * String property name * @param value * String property value * @throws SAXException * if I/O error or illegal content */ public final void write(final String category, final String name, final String value) throws SAXException { this.propertyAttributes.setValue(0, category); this.propertyAttributes.setValue(1, name); this.propertyAttributes.setValue(2, value); this.content.startElement(null, "property", "property", this.propertyAttributes); this.content.endElement(null, "property", "property"); } }
/** * Given a SAX2 Attributes and an index, remove the specified attribute as best we can. * If the implementation is the SAX Helpers AttributesImpl, use its setAttribute * If the implementation is TagSoup's, use its setAttribute * Otherwise, convert it to a SAX Helpers implementation and use its setAttribute */ public static Attributes clearAttribute(Attributes atts, int attNum) { if (atts instanceof org.ccil.cowan.tagsoup.AttributesImpl) { ((org.ccil.cowan.tagsoup.AttributesImpl)atts).setValue(attNum, ""); return atts; } else if (atts instanceof org.xml.sax.helpers.AttributesImpl) { ((org.xml.sax.helpers.AttributesImpl)atts).setValue(attNum, ""); return atts; } else { org.xml.sax.helpers.AttributesImpl newatts = new org.xml.sax.helpers.AttributesImpl(atts); newatts.setValue(attNum, ""); return newatts; } } }
private Attributes rebuildAttributes(final AttributesImpl newAttributes, final int index, final String path, final LibraryType libraryType) { final String versionedPath = this.getVersionedPath(path, libraryType); if (StringUtils.isNotBlank(versionedPath)) { log.debug("Rewriting to: {}", versionedPath); newAttributes.setValue(index, versionedPath); } else { log.debug("Versioned Path could not be created properly"); } return newAttributes; }
static protected Attributes setAttribute(Attributes attributes, String localName, String value){ int index = attributes.getIndex("", localName); AttributesImpl result = new AttributesImpl(attributes); if(index < 0){ result.addAttribute("", localName, "", "CDATA", value); // XXX } else { result.setValue(index, value); } return result; }
static protected Attributes setAttribute(Attributes attributes, String localName, String value){ int index = attributes.getIndex("", localName); AttributesImpl result = new AttributesImpl(attributes); if(index < 0){ result.addAttribute("", localName, "", "CDATA", value); // XXX } else { result.setValue(index, value); } return result; }
/** Replace {vars} in attributes. */ public void startElement(String uri, String localName, String qName, Attributes attr) throws SAXException { AttributesImpl newAttr = new AttributesImpl(attr); for (int i=0; i<attr.getLength(); i++) { newAttr.setValue(i, interp(attr.getValue(i))); } super.startElement(uri, localName, qName, newAttr); }
@Override public Attributes substitute(Attributes attributes) { AttributesImpl result = new AttributesImpl(attributes); for (int i = 0; i < result.getLength(); i++) { String name = result.getLocalName(i); if (name.matches("left|top|width|height")) { String value = result.getValue(i); if (value.matches("[0-9]*,[0-9]+")) result.setValue(i, value.replace(",", ".")); } } return result; } };
private Attributes rebuildAttributes(final AttributesImpl newAttributes, final int index, final String path, final LibraryType libraryType, final SlingHttpServletRequest request) { final String contextPath = request.getContextPath(); String libraryPath = path; if (StringUtils.isNotBlank(contextPath)) { libraryPath = path.substring(contextPath.length()); } String versionedPath = this.getVersionedPath(libraryPath, libraryType, request.getResourceResolver()); if (StringUtils.isNotBlank(versionedPath)) { if(StringUtils.isNotBlank(contextPath)) { versionedPath = contextPath + versionedPath; } log.debug("Rewriting to: {}", versionedPath); newAttributes.setValue(index, versionedPath); } else { log.debug("Versioned Path could not be created properly"); } return newAttributes; }
@Override public void startElement (String nsUri, String localname, String rawName, Attributes atts) throws SAXException { AttributesImpl linkAttributes = new AttributesImpl(atts); if (transform && A_TAG.equals(localname)) { for (int i=0; i < linkAttributes.getLength(); i++) { if (HREF_ATTRIBUTE.equals(linkAttributes.getLocalName(i))) { linkAttributes.setValue(i, transformHref(linkAttributes.getValue(i))); } } } super.startElement(nsUri, localname, rawName, linkAttributes); }
private Attributes copyAttributes(final Attributes a, final int role, final int view, boolean readOnly) { if (role < 0 && view < 0) { return a; } AttributesImpl attr = new AttributesImpl(); attr.setAttributes(a); if (role >= 0) { attr.removeAttribute(role); } if (view >= 0) { if (readOnly) { attr.setValue(view, ""); } else { attr.removeAttribute(view); } } return attr; }
/** * {@inheritDoc} * * @see org.xml.sax.helpers.XMLFilterImpl#startElement(java.lang.String, * java.lang.String, java.lang.String, org.xml.sax.Attributes) */ @Override public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { AttributesImpl attributes = (attrs instanceof AttributesImpl) ? (AttributesImpl) attrs : new AttributesImpl(attrs); int length = attributes.getLength(); for (int i = 0; i < length; ++i) { attributes.setValue(i, this.replace(attributes.getValue(i))); } super.startElement(uri, localName, qName, attributes); }
/** * {@inheritDoc} * @see org.xml.sax.helpers.XMLFilterImpl#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) */ @Override public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { AttributesImpl attributes = (attrs instanceof AttributesImpl) ? (AttributesImpl) attrs : new AttributesImpl(attrs); int length = attributes.getLength(); for (int i = 0; i < length; ++i) { attributes.setValue(i, StringPropertyReplacer.replaceProperties(attributes.getValue(i))); } super.startElement(uri, localName, qName, attributes); } }
protected Attributes rebuildAttributes(final SlingHttpServletRequest slingRequest, final String elementName, final Attributes attrs) { if (slingRequest == null || !attributes.containsKey(elementName)) { // element is not defined as a candidate to rewrite return attrs; } final String[] modifiableAttributes = attributes.get(elementName); // clone the attributes final AttributesImpl newAttrs = new AttributesImpl(attrs); final int len = newAttrs.getLength(); for (int i = 0; i < len; i++) { final String attrName = newAttrs.getLocalName(i); if (ArrayUtils.contains(modifiableAttributes, attrName)) { final String attrValue = newAttrs.getValue(i); if (StringUtils.startsWith(attrValue, "/") && !StringUtils.startsWith(attrValue, "//")) { // Only map absolute paths (starting w /), avoid relative-scheme URLs starting w // newAttrs.setValue(i, slingRequest.getResourceResolver().map(slingRequest, attrValue)); } } } return newAttrs; }
/** * Returns an attributes list which contains all the attributes * passed in, with any text of form "${xxx}" in an attribute value * replaced by the appropriate value from the system property. */ private Attributes updateAttributes(Attributes list) { if (list.getLength() == 0) { return list; } AttributesImpl newAttrs = new AttributesImpl(list); int nAttributes = newAttrs.getLength(); for (int i = 0; i < nAttributes; ++i) { String value = newAttrs.getValue(i); try { String newValue = IntrospectionUtils.replaceProperties(value, null, source); if (value != newValue) { newAttrs.setValue(i, newValue); } } catch (Exception e) { log.warn(sm.getString("digester.failedToUpdateAttributes", newAttrs.getLocalName(i), value), e); } } return newAttrs; }
/** * Set an attribute, adding the attribute if it isn't already present * in this element, and changing the value if it is. Passing null as the * value will cause any pre-existing attribute by this name to go away. */ public void setAttribute(String namespace, String localName, String value) { AttributesImpl attributes = makeAttributesEditable(); int idx = attributes.getIndex(namespace, localName); if (idx > -1) { // Got it, so replace it's value. if (value != null) { attributes.setValue(idx, value); } else { attributes.removeAttribute(idx); } return; } addAttribute(namespace, localName, value); }
/** * Set an attribute, adding the attribute if it isn't already present * in this element, and changing the value if it is. Passing null as the * value will cause any pre-existing attribute by this name to go away. */ public void setAttribute(String namespace, String localName, String value) { AttributesImpl attributes = makeAttributesEditable(); int idx = attributes.getIndex(namespace, localName); if (idx > -1) { // Got it, so replace it's value. if (value != null) { attributes.setValue(idx, value); } else { attributes.removeAttribute(idx); } return; } addAttribute(namespace, localName, value); }