Methods Summary |
---|
public void | add(java.lang.String qname, java.lang.String value)Adds an attribute to the list
// Initialize the internal vectors at the first usage.
if (_attributes == null)
alloc();
// Stuff the QName into the names vector & hashtable
Integer obj = (Integer)_attributes.get(qname);
if (obj == null) {
_attributes.put(qname, obj = new Integer(_length++));
_qnames.addElement(qname);
_values.addElement(value);
int col = qname.lastIndexOf(':");
if (col > -1) {
_uris.addElement(qname.substring(0,col));
_names.addElement(qname.substring(col+1));
}
else {
_uris.addElement(EMPTYSTRING);
_names.addElement(qname);
}
}
else {
final int index = obj.intValue();
_values.set(index, value);
}
|
private void | alloc()Allocate memory for the AttributeList
%OPT% Use on-demand allocation for the internal vectors. The memory
is only allocated when there is an attribute. This reduces the cost
of creating many small RTFs.
_attributes = new Hashtable();
_names = new Vector();
_values = new Vector();
_qnames = new Vector();
_uris = new Vector();
|
public void | clear()Clears the attribute list
_length = 0;
if (_attributes != null) {
_attributes.clear();
_names.removeAllElements();
_values.removeAllElements();
_qnames.removeAllElements();
_uris.removeAllElements();
}
|
public int | getIndex(java.lang.String qname)SAX2: Look up the index of an attribute by XML 1.0 qualified name.
return(-1);
|
public int | getIndex(java.lang.String namespaceURI, java.lang.String localPart)SAX2: Look up the index of an attribute by Namespace name.
return(-1);
|
public int | getLength()SAX2: Return the number of attributes in the list.
return(_length);
|
public java.lang.String | getLocalName(int index)SAX2: Look up an attribute's local name by index.
if (index < _length)
return((String)_names.elementAt(index));
else
return(null);
|
public java.lang.String | getQName(int pos)Return the name of an attribute in this list (by position).
if (pos < _length)
return((String)_qnames.elementAt(pos));
else
return(null);
|
public java.lang.String | getType(java.lang.String uri, java.lang.String localName)SAX2: Look up an attribute's type by Namespace name.
return(CDATASTRING);
|
public java.lang.String | getType(java.lang.String qname)SAX2: Look up an attribute's type by qname.
return(CDATASTRING);
|
public java.lang.String | getType(int index)SAX2: Look up an attribute's type by index.
return(CDATASTRING);
|
public java.lang.String | getURI(int index)SAX2: Look up an attribute's Namespace URI by index.
if (index < _length)
return((String)_uris.elementAt(index));
else
return(null);
|
public java.lang.String | getValue(int pos)SAX2: Look up an attribute's value by index.
if (pos < _length)
return((String)_values.elementAt(pos));
else
return(null);
|
public java.lang.String | getValue(java.lang.String qname)SAX2: Look up an attribute's value by qname.
if (_attributes != null) {
final Integer obj = (Integer)_attributes.get(qname);
if (obj == null) return null;
return(getValue(obj.intValue()));
}
else
return null;
|
public java.lang.String | getValue(java.lang.String uri, java.lang.String localName)SAX2: Look up an attribute's value by Namespace name - SLOW!
return(getValue(uri+':"+localName));
|