Sorts the key strings so that they can be very quickly compared
in the attribute set searchs.
| Method from javax.swing.text.StyleContext$KeyBuilder Detail: |
public void addAttribute(Object key,
Object value) {
keys.addElement(key);
data.addElement(value);
}
Adds a key/value to the set. |
public void addAttributes(AttributeSet attr) {
if (attr instanceof SmallAttributeSet) {
// avoid searching the keys, they are already interned.
Object[] tbl = ((SmallAttributeSet)attr).attributes;
int n = tbl.length;
for (int i = 0; i < n; i += 2) {
addAttribute(tbl[i], tbl[i+1]);
}
} else {
Enumeration names = attr.getAttributeNames();
while (names.hasMoreElements()) {
Object name = names.nextElement();
addAttribute(name, attr.getAttribute(name));
}
}
}
Adds a set of key/value pairs to the set. |
public Object[] createTable() {
int n = keys.size();
Object[] tbl = new Object[2 * n];
for (int i = 0; i < n; i ++) {
int offs = 2 * i;
tbl[offs] = keys.elementAt(i);
tbl[offs + 1] = data.elementAt(i);
}
return tbl;
}
Creates a table of sorted key/value entries
suitable for creation of an instance of
SmallAttributeSet. |
int getCount() {
return keys.size();
}
The number of key/value pairs contained
in the current key being forged. |
public void initialize(AttributeSet a) {
if (a instanceof SmallAttributeSet) {
initialize(((SmallAttributeSet)a).attributes);
} else {
keys.removeAllElements();
data.removeAllElements();
Enumeration names = a.getAttributeNames();
while (names.hasMoreElements()) {
Object name = names.nextElement();
addAttribute(name, a.getAttribute(name));
}
}
}
|
public void removeAttribute(Object key) {
int n = keys.size();
for (int i = 0; i < n; i++) {
if (keys.elementAt(i).equals(key)) {
keys.removeElementAt(i);
data.removeElementAt(i);
return;
}
}
}
Removes the given name from the set. |
public void removeAttributes(Enumeration names) {
while (names.hasMoreElements()) {
Object name = names.nextElement();
removeAttribute(name);
}
}
Removes the set of keys from the set. |
public void removeAttributes(AttributeSet attr) {
Enumeration names = attr.getAttributeNames();
while (names.hasMoreElements()) {
Object name = names.nextElement();
Object value = attr.getAttribute(name);
removeSearchAttribute(name, value);
}
}
Removes the set of matching attributes from the set. |