diff options
author | Lillian Angel <langel@redhat.com> | 2006-05-16 20:39:00 +0000 |
---|---|---|
committer | Lillian Angel <langel@redhat.com> | 2006-05-16 20:39:00 +0000 |
commit | 3900dd4bad75a5319e439927136bd346d1fd9f0e (patch) | |
tree | d53ae9bf9e357d31be5b6bad39a62b8db147fc2f | |
parent | d3d3ba28515b19b8354e9964b101f460d7198fa6 (diff) | |
download | classpath-3900dd4bad75a5319e439927136bd346d1fd9f0e.tar.gz |
2006-05-16 Lillian Angel <langel@redhat.com>
* javax/swing/text/StyleContext.java:
Changed staticAttributeKeys to be a Hashtable.
(getStaticAttribute): Implemented.
(getStaticAttributeKey): Implemented.
(readAttributeSet): Implemented.
(writeAttributeSet): Added FIXME. Not sure how
to implement this.
(readAttributes): Implemented.
(writeAttributes): Implemented.
(registerStaticAttibuteKey): Fixed to add key to
the hash table.
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | javax/swing/text/StyleContext.java | 99 |
2 files changed, 96 insertions, 17 deletions
@@ -1,3 +1,17 @@ +2006-05-16 Lillian Angel <langel@redhat.com> + + * javax/swing/text/StyleContext.java: + Changed staticAttributeKeys to be a Hashtable. + (getStaticAttribute): Implemented. + (getStaticAttributeKey): Implemented. + (readAttributeSet): Implemented. + (writeAttributeSet): Added FIXME. Not sure how + to implement this. + (readAttributes): Implemented. + (writeAttributes): Implemented. + (registerStaticAttibuteKey): Fixed to add key to + the hash table. + 2006-05-16 David Gilbert <david.gilbert@object-refinery.com> * javax/swing/DefaultButtonModel.java diff --git a/javax/swing/text/StyleContext.java b/javax/swing/text/StyleContext.java index 8ef34400d..9d09047db 100644 --- a/javax/swing/text/StyleContext.java +++ b/javax/swing/text/StyleContext.java @@ -413,7 +413,7 @@ public class StyleContext /** * These attribute keys are handled specially in serialization. */ - private static HashSet staticAttributeKeys = new HashSet(); + private static Hashtable staticAttributeKeys = new Hashtable(); EventListenerList listenerList; Hashtable styleTable; @@ -708,44 +708,107 @@ public class StyleContext } } - - // FIXME: there's some sort of quasi-serialization stuff in here which I - // have left incomplete; I'm not sure I understand the intent properly. - + /** + * Gets the object previously registered with registerStaticAttributeKey. + * + * @param key - the key that was registered. + * @return the object previously registered with registerStaticAttributeKey. + */ public static Object getStaticAttribute(Object key) - throws NotImplementedException { - throw new InternalError("not implemented"); + if (key == null) + return null; + return staticAttributeKeys.get(key); } + /** + * Returns the String that key will be registered with + * registerStaticAttributeKey. + * + * @param key - the key that will be registered. + * @return the string the key will be registered with. + */ public static Object getStaticAttributeKey(Object key) - throws NotImplementedException { - throw new InternalError("not implemented"); + return key.getClass().getName() + "." + key.toString(); } + /** + * Reads a set of attributes from the given object input stream. This will + * attempt to restore keys that were static objects by considering only the + * keys that have were registered with registerStaticAttributeKey. The + * attributes retrieved will be placed into the given set. + * + * @param in - the stream to read from + * @param a - the set of attributes + * @throws ClassNotFoundException - may be encountered when reading from + * stream + * @throws IOException - any I/O error + */ public static void readAttributeSet(ObjectInputStream in, MutableAttributeSet a) - throws ClassNotFoundException, IOException, NotImplementedException + throws ClassNotFoundException, IOException { - throw new InternalError("not implemented"); + if (in == null || a == null) + return; + + Object key = in.readObject(); + Object val = in.readObject(); + while (key != null && val != null) + { + Object staticKey = staticAttributeKeys.get(key); + Object staticVal = staticAttributeKeys.get(val); + + if (staticKey != null) + key = staticKey; + if (staticVal != null) + val = staticVal; + + a.addAttribute(key, val); + key = in.readObject(); + val = in.readObject(); + } } + /** + * TODO: DOCUMENT ME! + * + * @param out - stream to write to + * @param a - the attribute set + * @throws IOException - any I/O error + */ public static void writeAttributeSet(ObjectOutputStream out, AttributeSet a) throws IOException, NotImplementedException { - throw new InternalError("not implemented"); + // FIXME: Not implemented } + /** + * Handles reading in the attributes. + * @see #readAttributeSet(ObjectInputStream, MutableAttributeSet) + * + * @param in - the stream to read from + * @param a - the set of attributes + * @throws ClassNotFoundException - may be encountered when reading from stream + * @throws IOException - any I/O error + */ public void readAttributes(ObjectInputStream in, MutableAttributeSet a) - throws ClassNotFoundException, IOException, NotImplementedException + throws ClassNotFoundException, IOException { - throw new InternalError("not implemented"); + readAttributeSet(in, a); } + /** + * Handles writing of the given attributes. + * @see #writeAttributeSet(ObjectOutputStream, AttributeSet) + * + * @param out - stream to write to + * @param a - the attribute set + * @throws IOException - any I/O error + */ public void writeAttributes(ObjectOutputStream out, AttributeSet a) - throws IOException, NotImplementedException + throws IOException { - throw new InternalError("not implemented"); + writeAttributeSet(out, a); } /** @@ -760,6 +823,8 @@ public class StyleContext */ public static void registerStaticAttributeKey(Object key) { - staticAttributeKeys.add(key); + if (key != null) + staticAttributeKeys.put(key.getClass().getName() + "." + key.toString(), + key); } } |