/** * This method clears the accumulated attributes. * * @see org.xml.sax.helpers.AttributesImpl#clear() */ public final void clear() { int len = super.getLength(); super.clear(); if (MAX <= len) { // if we have had enough attributes and are // using the Hashtable, then clear the Hashtable too. m_indexFromQName.clear(); } }
/** * Look up an attribute index by qualified (prefixed) name. * * @param qName The qualified name. * @return The attributes index, or -1 if none was found. * @see org.xml.sax.Attributes#getIndex(java.lang.String) */ public int getIndex (String qName) { int max = atts.getLength(); for (int i = 0; i < max; i++) { if (qAtts.getName(i).equals(qName)) { return i; } } return -1; }
/** * This method clears the accumulated attributes. * * @see org.xml.sax.helpers.AttributesImpl#clear() */ public final void clear() { int len = super.getLength(); super.clear(); if (MAX <= len) { // if we have had enough attributes and are // using the Hashtable, then clear the Hashtable too. m_indexFromQName.clear(); } }
/** * This method gets the index of an attribute given its qName. * @param qname the qualified name of the attribute, e.g. "prefix1:locName1" * @return the integer index of the attribute. * @see org.xml.sax.Attributes#getIndex(String) */ public final int getIndex(String qname) { int index; if (super.getLength() < MAX) { // if we haven't got too many attributes let the // super class look it up index = super.getIndex(qname); return index; } // we have too many attributes and the super class is slow // so find it quickly using our Hashtable. Integer i = (Integer)m_indexFromQName.get(qname); if (i == null) index = -1; else index = i.intValue(); return index; } /**
/** * This method gets the index of an attribute given its qName. * @param qname the qualified name of the attribute, e.g. "prefix1:locName1" * @return the integer index of the attribute. * @see org.xml.sax.Attributes#getIndex(String) */ public final int getIndex(String qname) { int index; if (super.getLength() < MAX) { // if we haven't got too many attributes let the // super class look it up index = super.getIndex(qname); return index; } // we have too many attributes and the super class is slow // so find it quickly using our Hashtable. Integer i = (Integer)m_indexFromQName.get(qname); if (i == null) index = -1; else index = i.intValue(); return index; } /**
if (super.getLength() < MAX)
if (super.getLength() < MAX)
String val) int index = super.getLength(); super.addAttribute(uri, local, qname, type, val);
String val) int index = super.getLength(); super.addAttribute(uri, local, qname, type, val);
atts.addAttribute("", "", DISK_STORE_NAME, "", this.cache.getPdxDiskStore()); if (!generateDefaults() && this.cache.getPdxSerializer() == null && atts.getLength() == 0) { return;
if (generateDefaults() || atts.getLength() > 0) generateResourceManagerElement(atts);
public void endNode() { try { if (!children) { Element element = new DefaultElement((String)elementStack.pop()); for (int i = 0; i < attributes.getLength(); ++i) { element.addAttribute(attributes.getQName(i), attributes.getValue(i)); } writer.write(element); attributes.clear(); children = true; // node just closed is child of node on top of stack started = true; } else { startElement(); writer.endElement("", "", (String)elementStack.pop()); } } catch (SAXException e) { throw new StreamException(e); } catch (IOException e) { throw new StreamException(e); } }
/** * Test method for {@link XmlGeneratorUtils#addAttribute(AttributesImpl, String, Object)}. */ @Test public void testAddAttributeAttributesImplStringObject() { final AttributesImpl attributes = new AttributesImpl(); assertEquals(0, attributes.getLength()); XmlGeneratorUtils.addAttribute(attributes, "localname", null); assertEquals(0, attributes.getLength()); XmlGeneratorUtils.addAttribute(attributes, "localname", "value"); assertEquals(1, attributes.getLength()); assertEquals("localname", attributes.getLocalName(0)); assertEquals("localname", attributes.getQName(0)); assertEquals(XMLConstants.NULL_NS_URI, attributes.getURI(0)); assertEquals("value", attributes.getValue(0)); }
if (!generateDefaults() && atts.getLength() == 0 && pa.getPartitionResolver() == null && pa.getPartitionListeners().length == 0 && (pa.getFixedPartitionAttributes() == null || pa.getFixedPartitionAttributes().isEmpty())) {
/** * Test method for {@link XmlGeneratorUtils#addAttribute(AttributesImpl, String, String, Object)}. */ @Test public void testAddAttributeAttributesImplStringStringObject() { final AttributesImpl attributes = new AttributesImpl(); assertEquals(0, attributes.getLength()); XmlGeneratorUtils.addAttribute(attributes, "prefix", "localname", null); assertEquals(0, attributes.getLength()); XmlGeneratorUtils.addAttribute(attributes, "prefix", "localname", "value"); assertEquals(1, attributes.getLength()); assertEquals("localname", attributes.getLocalName(0)); assertEquals("prefix:localname", attributes.getQName(0)); assertEquals(NULL_NS_URI, attributes.getURI(0)); assertEquals("value", attributes.getValue(0)); }
public void startElement( String uri, String localName, String name, Attributes attributes) throws SAXException { matchers.addFirst(matcher); matcher = matcher.descend(uri, localName); AttributesImpl matches = new AttributesImpl(); for (int i = 0; i < attributes.getLength(); i++) { String attributeURI = attributes.getURI(i); String attributeName = attributes.getLocalName(i); if (matcher.matchesAttribute(attributeURI, attributeName)) { matches.addAttribute( attributeURI, attributeName, attributes.getQName(i), attributes.getType(i), attributes.getValue(i)); } } if (matcher.matchesElement() || matches.getLength() > 0) { super.startElement(uri, localName, name, matches); if (!matcher.matchesElement()) { // Force the matcher to match the current element, so the // endElement method knows to emit the correct event matcher = new CompositeMatcher(matcher, ElementMatcher.INSTANCE); } } }
for(int i=0; i<newAttrs.getLength(); i++) { if("src".equals(newAttrs.getLocalName(i))) { String src = newAttrs.getValue(i);
for (int i = 0; i < newAttrs.getLength(); i++) { if ("src".equals(newAttrs.getLocalName(i))) { String src = newAttrs.getValue(i);
private void addFieldString(PDField field) throws SAXException { //Pick partial name to present in content and altName for attribute //Ignoring FullyQualifiedName for now String partName = field.getPartialName(); String altName = field.getAlternateFieldName(); StringBuilder sb = new StringBuilder(); AttributesImpl attrs = new AttributesImpl(); if (partName != null) { sb.append(partName).append(": "); } if (altName != null) { attrs.addAttribute("", "altName", "altName", "CDATA", altName); } //return early if PDSignature field if (field instanceof PDSignatureField) { handleSignature(attrs, (PDSignatureField) field); return; } String value = field.getValueAsString(); if (value != null && !value.equals("null")) { sb.append(value); } if (attrs.getLength() > 0 || sb.length() > 0) { xhtml.startElement("li", attrs); xhtml.characters(sb.toString()); xhtml.endElement("li"); } }
for (int att = 0; att < newAttributes.getLength(); att++) { String attrName = newAttributes.getLocalName(att); String normAttrName = mapper.mapSafeAttribute(name, attrName);