public Object get(Object key) {
ValueWrapper valueWrapper = (ValueWrapper)super.get(key);
Object value = valueWrapper.getValue(); if (value instanceof ValueWrapper) thrownew RuntimeException("Hashtable.get bug"); return value;
}
public Object put(Object key, Object value) { if (value instanceof ValueWrapper) thrownew RuntimeException( "Hashtable.put bug: value is already wrapped");
ValueWrapper valueWrapper = new ValueWrapper(value); super.put(key, valueWrapper); return value;
}
privatestatic Object copyObject(Object oldObj) {
Object newObj = null; try { //Create a stream in which to serialize the object.
ByteArrayOutputStream ostream = new ByteArrayOutputStream();
ObjectOutputStream p = new ObjectOutputStream(ostream); //Serialize the object into the stream
p.writeObject(oldObj);
//Create an input stream from which to deserialize the object byte[] byteArray = ostream.toByteArray();
ByteArrayInputStream istream = new ByteArrayInputStream(byteArray);
ObjectInputStream q = new ObjectInputStream(istream); //Deserialize the object
newObj = q.readObject();
} catch (Exception ex) {
ex.printStackTrace();
} return newObj;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.