public boolean isDeclared (String uri, String localName) { int index = getIndex (uri, localName); if (index < 0) throw new IllegalArgumentException ( "No such attribute: local=" + localName + ", namespace=" + uri); return declared [index]; }
public boolean isDeclared (int index) { if (index < 0 || index >= getLength ()) throw new ArrayIndexOutOfBoundsException ( "No attribute at index: " + index); return declared [index]; }
static Attributes copy(Attributes atts) { return new Attributes2Impl(atts); }
Attributes2Impl attrs = new Attributes2Impl(attributes); attrs.addAttribute("http://myNamespace", "location", "myns:location", "CDATA", location); super.startElement(uri, localName, qName, attrs);
@Test public void testStartElementThrowsNullPointerException() throws Throwable { Attributes atts = new Attributes2Impl(); try { xMLPackager.startElement("testXMLPackagerNs", null, "testXMLPackagerQName", atts); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); } }
Attributes2Impl a2 = new Attributes2Impl(); a2.addAttribute(a_uri, a_localName, a_qName, a_type, a_value);
/** * Returns the current value of an attribute's "specified" flag. * * @param index The attribute index (zero-based). * @return current flag value * @exception java.lang.ArrayIndexOutOfBoundsException When the * supplied index does not identify an attribute. */ public boolean isSpecified (int index) { if (index < 0 || index >= getLength ()) throw new ArrayIndexOutOfBoundsException ( "No attribute at index: " + index); return specified [index]; }
public boolean isDeclared (String qName) { int index = getIndex (qName); if (index < 0) throw new IllegalArgumentException ( "No such attribute: " + qName); return declared [index]; }
@Test public void testGenericValidatorContentHandlerStartElementThrowsSAXException10() throws Throwable { GenericValidatingPackager.GenericValidatorContentHandler genericValidatorContentHandler = new GenericValidatingPackager().new GenericValidatorContentHandler(); Attributes atts = new Attributes2Impl(); try { genericValidatorContentHandler.startElement("testGenericValidatorContentHandlerNamespaceURI", "isopackager", "testGenericValidatorContentHandlerQName", atts); fail("Expected SAXException to be thrown"); } catch (SAXException ex) { assertNull("ex.getMessage()", ex.getMessage()); assertNull("ex.getException().getMessage()", ex.getException().getMessage()); } }
/** * Assign a value to the "specified" flag of a specific attribute. * This is the only way this flag can be cleared, except clearing * by initialization with the copy constructor. * * @param index The index of the attribute (zero-based). * @param value The desired flag value. * @exception java.lang.ArrayIndexOutOfBoundsException When the * supplied index does not identify an attribute. */ public void setSpecified (int index, boolean value) { if (index < 0 || index >= getLength ()) throw new ArrayIndexOutOfBoundsException ( "No attribute at index: " + index); specified [index] = value; } }
/** * Returns the current value of an attribute's "specified" flag. * * @param qName The XML qualified (prefixed) name. * @return current flag value * @exception java.lang.IllegalArgumentException When the * supplied name does not identify an attribute. */ public boolean isSpecified (String qName) { int index = getIndex (qName); if (index < 0) throw new IllegalArgumentException ( "No such attribute: " + qName); return specified [index]; }
@Test public void testGenericValidatorContentHandlerStartElementThrowsSAXException2() throws Throwable { GenericValidatingPackager.GenericValidatorContentHandler genericValidatorContentHandler = new GenericValidatingPackager().new GenericValidatorContentHandler(); Attributes atts = new Attributes2Impl(); try { genericValidatorContentHandler.startElement("testGenericValidatorContentHandlerNamespaceURI", null, "testGenericValidatorContentHandlerQName", atts); fail("Expected SAXException to be thrown"); } catch (SAXException ex) { assertNull("ex.getMessage()", ex.getMessage()); assertNull("ex.getException().getMessage()", ex.getException().getMessage()); } }
/** * Assign a value to the "declared" flag of a specific attribute. * This is normally needed only for attributes of type CDATA, * including attributes whose type is changed to or from CDATA. * * @param index The index of the attribute (zero-based). * @param value The desired flag value. * @exception java.lang.ArrayIndexOutOfBoundsException When the * supplied index does not identify an attribute. * @see #setType */ public void setDeclared (int index, boolean value) { if (index < 0 || index >= getLength ()) throw new ArrayIndexOutOfBoundsException ( "No attribute at index: " + index); declared [index] = value; }
/** * Returns the current value of an attribute's "specified" flag. * * @param uri The Namespace URI, or the empty string if * the name has no Namespace URI. * @param localName The attribute's local name. * @return current flag value * @exception java.lang.IllegalArgumentException When the * supplied names do not identify an attribute. */ public boolean isSpecified (String uri, String localName) { int index = getIndex (uri, localName); if (index < 0) throw new IllegalArgumentException ( "No such attribute: local=" + localName + ", namespace=" + uri); return specified [index]; }
@Test public void testGenericContentHandlerStartElementThrowsSAXException2() throws Throwable { GenericPackager.GenericContentHandler genericContentHandler = new GenericSubFieldPackager().new GenericContentHandler(); Attributes atts = new Attributes2Impl(); try { genericContentHandler .startElement("testGenericContentHandlerNamespaceURI", null, "testGenericContentHandlerQName", atts); fail("Expected SAXException to be thrown"); } catch (SAXException ex) { assertNull("ex.getMessage()", ex.getMessage()); assertNull("ex.getException().getMessage()", ex.getException().getMessage()); } }
public void removeAttribute (int index) { int origMax = getLength () - 1; super.removeAttribute (index); if (index != origMax) { System.arraycopy (declared, index + 1, declared, index, origMax - index); System.arraycopy (specified, index + 1, specified, index, origMax - index); } }
public boolean isDeclared (String uri, String localName) { int index = getIndex (uri, localName); if (index < 0) throw new IllegalArgumentException ( "No such attribute: local=" + localName + ", namespace=" + uri); return declared [index]; }
@Test public void testGenericContentHandlerStartElementThrowsSAXException4() throws Throwable { GenericPackager.GenericContentHandler genericContentHandler = new X92GenericPackager().new GenericContentHandler(); Attributes atts = new Attributes2Impl(); try { genericContentHandler.startElement("testGenericContentHandlerNamespaceURI", "isofieldpackager", "testGenericContentHandlerQName", atts); fail("Expected SAXException to be thrown"); } catch (SAXException ex) { assertEquals("ex.getMessage()", "null", ex.getMessage()); assertEquals("ex.getException().getMessage()", "null", ex.getException().getMessage()); } }
int length = getLength ();
public boolean isDeclared (String uri, String localName) { int index = getIndex (uri, localName); if (index < 0) throw new IllegalArgumentException ( "No such attribute: local=" + localName + ", namespace=" + uri); return declared [index]; }