private final void writeAttributes(final Attributes atts) throws IOException { StringBuilder sb = new StringBuilder(); int len = atts.getLength(); for (int i = 0; i < len; i++) { sb.append(' ') .append(atts.getLocalName(i)) .append("=\"") .append(esc(atts.getValue(i))) .append('\"'); } w.write(sb.toString()); }
/** * Copy an entire Attributes object. * * <p>It may be more efficient to reuse an existing object * rather than constantly allocating new ones.</p> * * @param atts The attributes to copy. */ public void setAttributes (Attributes atts) { clear(); length = atts.getLength(); if (length > 0) { data = new String[length*5]; for (int i = 0; i < length; i++) { data[i*5] = atts.getURI(i); data[i*5+1] = atts.getLocalName(i); data[i*5+2] = atts.getQName(i); data[i*5+3] = atts.getType(i); data[i*5+4] = atts.getValue(i); } } }
public String getName(int i) { String n = mAttrs.getQName(i); return (n == null) ? mAttrs.getLocalName(i) : n; }
/** * Add the given attributes to the currently collected ones. These * attributes are always added, regardless of whether on not an element * is currently open. * @param atts List of attributes to add to this list */ public void addAttributes(Attributes atts) throws SAXException { int nAtts = atts.getLength(); for (int i = 0; i < nAtts; i++) { String uri = atts.getURI(i); if (null == uri) uri = ""; addAttributeAlways( uri, atts.getLocalName(i), atts.getQName(i), atts.getType(i), atts.getValue(i), false); } }
@Override public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { if (localName.equalsIgnoreCase(SHEET)) { String name = null; String id = null; for (int i = 0; i < attrs.getLength(); i++) { final String attrName = attrs.getLocalName(i); if (attrName.equalsIgnoreCase(NAME)) { name = attrs.getValue(i); } else if (attrName.equalsIgnoreCase(ID)) { id = attrs.getValue(i); } if (name != null && id != null) { sheetRefs.add(new XSSFSheetRef(id, name)); break; } } } }
/** * Copy an entire Attributes object. * * <p>It may be more efficient to reuse an existing object * rather than constantly allocating new ones.</p> * * @param atts The attributes to copy. */ public void setAttributes (Attributes atts) { clear(); length = atts.getLength(); if (length > 0) { data = new String[length*5]; for (int i = 0; i < length; i++) { data[i*5] = atts.getURI(i); data[i*5+1] = atts.getLocalName(i); data[i*5+2] = atts.getQName(i); data[i*5+3] = atts.getType(i); data[i*5+4] = atts.getValue(i); } } }
for (int i = 0, n = atts.getLength(); i < n; i++) { if (atts.getLocalName(i).equals("service")) { this.service = atts.getValue(i);
/** * Add the given attributes to the currently collected ones. These * attributes are always added, regardless of whether on not an element * is currently open. * @param atts List of attributes to add to this list */ public void addAttributes(Attributes atts) throws SAXException { int nAtts = atts.getLength(); for (int i = 0; i < nAtts; i++) { String uri = atts.getURI(i); if (null == uri) uri = ""; addAttributeAlways( uri, atts.getLocalName(i), atts.getQName(i), atts.getType(i), atts.getValue(i), false); } }
throws SAXException { if (LitePalParser.NODE_DB_NAME.equalsIgnoreCase(localName)) { for (int i = 0; i < attributes.getLength(); i++) { if (LitePalParser.ATTR_VALUE.equalsIgnoreCase(attributes.getLocalName(i))) { litePalAttr.setDbName(attributes.getValue(i).trim()); for (int i = 0; i < attributes.getLength(); i++) { if (LitePalParser.ATTR_VALUE.equalsIgnoreCase(attributes.getLocalName(i))) { litePalAttr.setVersion(Integer.parseInt(attributes.getValue(i).trim())); for (int i = 0; i < attributes.getLength(); i++) { if (LitePalParser.ATTR_CLASS.equalsIgnoreCase(attributes.getLocalName(i))) { litePalAttr.addClassName(attributes.getValue(i).trim()); for (int i = 0; i < attributes.getLength(); i++) { if (LitePalParser.ATTR_VALUE.equalsIgnoreCase(attributes.getLocalName(i))) { litePalAttr.setCases(attributes.getValue(i).trim()); for (int i = 0; i < attributes.getLength(); i++) { if (LitePalParser.ATTR_VALUE.equalsIgnoreCase(attributes.getLocalName(i))) { litePalAttr.setStorage(attributes.getValue(i).trim());
public void startElement(String namespaceURI, String localName, String qName, Attributes list) throws SAXException { addTextToNode(); Object nodeName = getElementName(namespaceURI, localName, qName); int size = list.getLength(); Map<Object, String> attributes = new LinkedHashMap<Object, String>(size); for (int i = 0; i < size; i++) { Object attributeName = getElementName(list.getURI(i), list.getLocalName(i), list.getQName(i)); String value = list.getValue(i); attributes.put(attributeName, value); } parent = createNode(parent, nodeName, attributes); stack.add(parent); }
private void addToOutgoingUrls(String href, String tag, Attributes attributes) { curUrl = new ExtractedUrlAnchorPair(); curUrl.setHref(href); curUrl.setTag(tag); for (int x = 0; x < attributes.getLength(); x++) { String attrName = attributes.getLocalName(x); String attrVal = attributes.getValue(attrName); curUrl.setAttribute(attrName, attrVal); } outgoingUrls.add(curUrl); }
@Override public void startElement(String uri, String localName, String qName, final Attributes attributes) throws SAXException { super.startElement(uri, localName, qName, attributes); Map.Entry[] attributeMap = new Map.Entry[attributes.getLength()]; for (int i = 0; i < attributeMap.length; i++) { attributeMap[i] = new AbstractMap.SimpleEntry<>( attributes.getLocalName(i), attributes.getValue(i) ); } try { EventedValue esv = createValue(localName, attributeMap); if (esv != null) getInstance().getValues().add(esv); } catch (Exception ex) { // Don't exit, just log a warning log.warning("Error reading event XML, ignoring value: " + Exceptions.unwrap(ex)); } }
/** * 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)); } }
private static String getVal(String localName, Attributes atts) { for (int i = 0; i < atts.getLength(); i++) { if (localName.equals(atts.getLocalName(i))) { return atts.getValue(i); } } return null; }
if (atts.getLength() == 1) { SAXRecorder.this.sequence.addEvent(this.efactory.makeAttribute(atts.getURI(0), atts.getLocalName(0), atts.getQName(0), atts.getValue(0))); } else if (atts.getLength() > 1) { AttributeEvent[] attEvents = new AttributeEvent[atts.getLength()]; for (int i = 0; i < atts.getLength(); i++) { attEvents[i] = this.efactory.makeAttribute(atts.getURI(i), atts.getLocalName(i), atts.getQName(i), atts.getValue(i)); attEvents[i].setWeight(2); this.currentWeight += 2;
new DIDLObject.Class( getCharacters(), getAttributes().getValue("name") getInstance().addProperty( new DIDLObject.Property.UPNP.ARTIST( new PersonWithRole(getCharacters(), getAttributes().getValue("role")) getInstance().addProperty( new DIDLObject.Property.UPNP.ACTOR( new PersonWithRole(getCharacters(), getAttributes().getValue("role")) for (int i = 0; i < albumArtURIAttributes.getLength(); i++) { if ("profileID".equals(albumArtURIAttributes.getLocalName(i))) { albumArtURI.addAttribute( new DIDLObject.Property.DLNA.PROFILE_ID(
public void startElement(final String namespaceURI, final String localName, final String qName, final Attributes atts) throws SAXException { addCdata(); final Map<String, String> attributes = new NamespaceAwareHashMap(); final Map<String, String> attributeNamespaces = new HashMap<String, String>(); for (int i = atts.getLength() - 1; i != -1; i--) { if (atts.getURI(i).length() == 0) { attributes.put(atts.getQName(i), atts.getValue(i)); } else { String key = new QName(atts.getURI(i), atts.getLocalName(i)).toString(); attributes.put(key, atts.getValue(i)); attributeNamespaces.put(key, atts.getURI(i)); } } final Node newElement; if (namespaceURI.length() == 0) { newElement = new Node(currentNode, qName, attributes, attributeNamespaces, namespaceURI); } else { newElement = new Node(currentNode, localName, attributes, attributeNamespaces, namespaceURI); } if (currentNode != null) { currentNode.addChild(newElement); } stack.push(currentNode); currentNode = newElement; }
@Override public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException { if ("cmAuthor".equals(localName)) { for (int i = 0; i < atts.getLength(); i++) { if ("id".equals(atts.getLocalName(i))) { id = atts.getValue(i); } else if ("name".equals(atts.getLocalName(i))) { name = atts.getValue(i); } else if ("initials".equals(atts.getLocalName(i))) { initials = atts.getValue(i); } } commentAuthors.add(id, name, initials); //clear out id = null; name = null; initials = null; } }
top = doc.createElementNS(namespaceURI, localName); for (int i = 0; i < atts.getLength(); i++) { Attr attr = null; if ((atts.getLocalName(i) == null) || (atts.getLocalName(i).length() == 0)) { attr = doc.createAttribute(atts.getQName(i)); attr.setNodeValue(atts.getValue(i)); ((Element)top).setAttributeNode(attr); } else { attr = doc.createAttributeNS(atts.getURI(i), atts.getLocalName(i)); attr.setNodeValue(atts.getValue(i)); ((Element)top).setAttributeNodeNS(attr);