Interface XMLAttributes
-
- All Superinterfaces:
Attributes,Attributes2
- All Known Implementing Classes:
XMLAttributesImpl
public interface XMLAttributes extends Attributes2
The XMLAttributes interface defines a collection of attributes for an element. In the parser, the document source would scan the entire start element and collect the attributes. The attributes are communicated to the document handler in the startElement method.The attributes are read-write so that subsequent stages in the document pipeline can modify the values or change the attributes that are propagated to the next stage.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intaddAttribute(QName attrName, String attrType, String attrValue)Adds an attribute.QNamegetName(int attrIndex)Returns the QName structure of the name.voidgetName(int attrIndex, QName attrName)Gets the fields in the given QName structure with the values of the attribute name at the specified index.StringgetNonNormalizedValue(int attrIndex)voidremoveAllAttributes()Removes all of the attributes.voidremoveAttributeAt(int attrIndex)Removes the attribute at the specified index.voidsetName(int attrIndex, QName attrName)Sets the name of the attribute at the specified index.voidsetSpecified(int attrIndex, boolean specified)Sets whether an attribute is specified in the instance document or not.voidsetValue(int attrIndex, String attrValue)Sets the value of the attribute at the specified index.-
Methods inherited from interface org.xml.sax.Attributes
getIndex, getIndex, getLength, getLocalName, getQName, getType, getType, getType, getURI, getValue, getValue, getValue
-
Methods inherited from interface org.xml.sax.ext.Attributes2
isDeclared, isDeclared, isDeclared, isSpecified, isSpecified, isSpecified
-
-
-
-
Method Detail
-
addAttribute
int addAttribute(QName attrName, String attrType, String attrValue)
Adds an attribute. The attribute's non-normalized value of the attribute will have the same value as the attribute value until. Also, the added attribute will be marked as specified in the XML instance document unless set otherwise using thesetSpecifiedmethod.Note: If an attribute of the same name already exists, the old values for the attribute are replaced by the new values.
- Parameters:
attrName- The attribute name.attrType- The attribute type. The type name is determined by the type specified for this attribute in the DTD. For example: "CDATA", "ID", "NMTOKEN", etc. However, attributes of type enumeration will have the type value specified as the pipe ('|') separated list of the enumeration values prefixed by an open parenthesis and suffixed by a close parenthesis. For example: "(true|false)".attrValue- The attribute value.- Returns:
- Returns the attribute index.
- See Also:
setSpecified(int, boolean)
-
removeAllAttributes
void removeAllAttributes()
Removes all of the attributes. This method will also remove all entities associated to the attributes.
-
removeAttributeAt
void removeAttributeAt(int attrIndex)
Removes the attribute at the specified index.Note: This operation changes the indexes of all attributes following the attribute at the specified index.
- Parameters:
attrIndex- The attribute index.
-
setName
void setName(int attrIndex, QName attrName)Sets the name of the attribute at the specified index.- Parameters:
attrIndex- The attribute index.attrName- The new attribute name.
-
getName
void getName(int attrIndex, QName attrName)Gets the fields in the given QName structure with the values of the attribute name at the specified index.- Parameters:
attrIndex- The attribute index.attrName- The attribute name structure to fill in.
-
getName
QName getName(int attrIndex)
Returns the QName structure of the name. Because QName is a modifiable data structure, make sure you know what you do when you take this shortcut route.- Parameters:
attrIndex- The attribute index.
-
setValue
void setValue(int attrIndex, String attrValue)Sets the value of the attribute at the specified index. This method will overwrite the non-normalized value of the attribute.- Parameters:
attrIndex- The attribute index.attrValue- The new attribute value.
-
getNonNormalizedValue
String getNonNormalizedValue(int attrIndex)
- Parameters:
attrIndex- The attribute index.- Returns:
- the non-normalized value of the attribute at the specified index. If
no non-normalized value is set, this method will return the same
value as the
getValue(int)method.
-
setSpecified
void setSpecified(int attrIndex, boolean specified)Sets whether an attribute is specified in the instance document or not.- Parameters:
attrIndex- The attribute index.specified- True if the attribute is specified in the instance document.
-
-