(Action)arrayTable.get(key);
if (value == null) {
ActionMap parent = getParent();
if (parent != null) {
return parent.get(key);
}
}
return value;
}
/**
* Removes the binding for <code>key</code> from this <code>ActionMap</code>.
*/
public void remove(Object key) {
if (arrayTable != null) {
arrayTable.remove(key);
}
}
/**
* Removes all the mappings from this <code>ActionMap</code>.
*/
public void clear() {
if (arrayTable != null) {
arrayTable.clear();
}
}
/**
* Returns the <code>Action</code> names that are bound in this <code>ActionMap</code>.
*/
public Object[] keys() {
if (arrayTable == null) {
return null;
}
return arrayTable.getKeys(null);
}
/**
* Returns the number of <code>KeyStroke</code> bindings.
*/
public int size() {
if (arrayTable == null) {
return 0;
}
return arrayTable.size();
}
/**
* Returns an array of the keys defined in this <code>ActionMap</code> and
* its parent. This method differs from <code>keys()</code> in that
* this method includes the keys defined in the parent.
*/
public Object[] allKeys() {
int count = size();
ActionMap parent = getParent();
if (count == 0) {
if (parent != null) {
return parent.allKeys();
}
return keys();
}
if (parent == null) {
return keys();
}
Object[] keys = keys();
Object[] pKeys = parent.allKeys();
if (pKeys == null) {
return keys;
}
if (keys == null) {
// Should only happen if size() != keys.length, which should only
// happen if mutated from multiple threads (or a bogus subclass).
return pKeys;
}
HashMap keyMap = new HashMap();
int counter;
for (counter = keys.length - 1; counter >= 0; counter--) {
keyMap.put(keys[counter], keys[counter]);
}
for (counter = pKeys.length - 1; counter >= 0; counter--) {
keyMap.put(pKeys[counter], pKeys[counter]);
}
return keyMap.keySet().toArray();
}
private void writeObject(ObjectOutputStream s) throws IOException {
s.defaultWriteObject();
ArrayTable.writeArrayTable(s, arrayTable);
}
private void readObject(ObjectInputStream s) throws ClassNotFoundException,
IOException {
=2= |