com.ibm.textlayout.attributes
Class AttributeMap

java.lang.Object
  |
  +--com.ibm.textlayout.attributes.AttributeMap
All Implemented Interfaces:
java.io.Externalizable, Map, java.util.Map, java.io.Serializable

public final class AttributeMap
extends java.lang.Object
implements java.util.Map, Map, java.io.Externalizable

AttributeMap is an immutable Map. Additionally, there are several methods for common operations (union, remove, intersect); these methods return new AttributeMap instances.

Although any non-null Object can be a key or value in an AttributeMap, typically the keys are fields of TextAttribute.

See Also:
TextAttribute, Serialized Form

Inner classes inherited from class java.util.Map
java.util.Map.Entry
 
Field Summary
static AttributeMap EMPTY_ATTRIBUTE_MAP
          An empty AttributeMap.
 
Fields inherited from interface com.ibm.textlayout.attributes.Map
COPYRIGHT
 
Constructor Summary
AttributeMap()
          Create a new, empty AttributeMap.
AttributeMap(java.util.Hashtable hashtable)
          Create an AttributeMap with the same key-value entries as the given Hashtable.
AttributeMap(java.util.Map map)
          Create an AttributeMap with the same key-value entries as the given Map.
AttributeMap(java.lang.Object key, java.lang.Object value)
          Create an AttributeMap with a single entry of {attribute, value}.
 
Method Summary
 AttributeMap addAttribute(java.lang.Object key, java.lang.Object value)
          Return a AttributeMap which contains entries in this AttributeMap, along with an entry for .
 AttributeMap addAttributes(AttributeMap rhs)
          Return a AttributeMap which contains entries in this AttributeMap and in rhs.
 AttributeMap addAttributes(java.util.Map rhs)
          Return a AttributeMap which contains entries in this AttributeMap and in rhs.
 void clear()
          Throws UnsupportedOperationException.
 boolean containsKey(java.lang.Object key)
          Return true if the given key is in this AttributeMap.
 boolean containsValue(java.lang.Object value)
          Return true if the given value is in this AttributeMap.
 java.util.Set entrySet()
          Return a Set containing all entries in this AttributeMap.
 boolean equals(java.lang.Object rhs)
           
 java.lang.Object get(java.lang.Object key)
          Return the value associated with the given key.
 AttributeSet getKeySet()
          Return an AttributeSet containing every key in this AttributeMap.
 int hashCode()
           
 AttributeMap intersectWith(AttributeSet attributes)
          Return a AttributeMap with the keys of this AttributeMap which are also in the Set.
 AttributeMap intersectWith(java.util.Set attributes)
          Return a AttributeMap with the keys of this AttributeMap which are also in the Set.
 boolean isEmpty()
          Return true if the number of entries in the AttributeMap is 0.
 java.util.Set keySet()
          Return an AttributeSet containing every key in this AttributeMap.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Throws UnsupportedOperationException.
 void putAll(java.util.Map t)
          Throws UnsupportedOperationException.
 void putAllInto(java.util.Map rhs)
          Put all entries in this AttributeMap into the given Map.
 void readExternal(java.io.ObjectInput in)
           
 java.lang.Object remove(java.lang.Object key)
          Throws UnsupportedOperationException.
 AttributeMap removeAttribute(java.lang.Object attribute)
          Return a AttributeMap with the entries in this AttributeMap, but without attribute as a key.
 AttributeMap removeAttributes(AttributeSet attributes)
          Return a AttributeMap with the entries of this AttributeMap whose attributes are not in the Set.
 AttributeMap removeAttributes(java.util.Set attributes)
          Return a AttributeMap with the entries of this AttributeMap whose attributes are not in the Set.
 int size()
          Return the number of entries in the AttributeMap.
 java.lang.String toString()
           
 java.util.Collection values()
          Return a Collection containing every value in this AttributeMap.
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_ATTRIBUTE_MAP

public static final AttributeMap EMPTY_ATTRIBUTE_MAP
An empty AttributeMap.
Constructor Detail

AttributeMap

public AttributeMap()
Create a new, empty AttributeMap. EMPTY_STYLE_SET can be used in place of an AttributeMap produced by this constructor.

AttributeMap

public AttributeMap(java.util.Map map)
Create an AttributeMap with the same key-value entries as the given Map.
Parameters:
map - a Map whose key-value entries will become the entries for this AttributeMap. map is not modified, and must not contain null keys or values.

AttributeMap

public AttributeMap(java.util.Hashtable hashtable)
Create an AttributeMap with the same key-value entries as the given Hashtable.
Parameters:
table - a Hashtable whose key-value entries will become the entries for this AttributeMap. table is not modified.

AttributeMap

public AttributeMap(java.lang.Object key,
                    java.lang.Object value)
Create an AttributeMap with a single entry of {attribute, value}.
Parameters:
attribute - the key in this AttributeMap's single entry
value - the value in this AttributeMap's single entry
Method Detail

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable

size

public int size()
Return the number of entries in the AttributeMap.
Specified by:
size in interface java.util.Map
Returns:
the number of entries in the AttributeMap

isEmpty

public boolean isEmpty()
Return true if the number of entries in the AttributeMap is 0.
Specified by:
isEmpty in interface java.util.Map
Returns:
true if the number of entries in the AttributeMap is 0

containsKey

public boolean containsKey(java.lang.Object key)
Return true if the given key is in this AttributeMap.
Specified by:
containsKey in interface java.util.Map
Parameters:
key - the key to test
Returns:
true if key is in this AttributeMap

containsValue

public boolean containsValue(java.lang.Object value)
Return true if the given value is in this AttributeMap.
Specified by:
containsValue in interface java.util.Map
Parameters:
key - the value to test
Returns:
true if value is in this AttributeMap

get

public java.lang.Object get(java.lang.Object key)
Return the value associated with the given key. If the key is not in this AttributeMap null is returned.
Specified by:
get in interface java.util.Map
Parameters:
key - the key to look up
Returns:
the value associated with key, or null if key is not in this AttributeMap

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Throws UnsupportedOperationException.
Specified by:
put in interface java.util.Map
Throws:
UnsupportedOperationException -  
See Also:
addAttribute(java.lang.Object, java.lang.Object)

remove

public java.lang.Object remove(java.lang.Object key)
Throws UnsupportedOperationException.
Specified by:
remove in interface java.util.Map
Throws:
UnsupportedOperationException -  
See Also:
removeAttributes(com.ibm.textlayout.attributes.AttributeSet)

putAll

public void putAll(java.util.Map t)
Throws UnsupportedOperationException.
Specified by:
putAll in interface java.util.Map
Throws:
UnsupportedOperationException -  
See Also:
addAttributes(com.ibm.textlayout.attributes.AttributeMap)

clear

public void clear()
Throws UnsupportedOperationException.
Specified by:
clear in interface java.util.Map
Throws:
UnsupportedOperationException -  
See Also:
EMPTY_ATTRIBUTE_MAP

keySet

public java.util.Set keySet()
Return an AttributeSet containing every key in this AttributeMap.
Specified by:
keySet in interface java.util.Map
Returns:
an AttributeSet containing every key in this AttributeMap

getKeySet

public AttributeSet getKeySet()
Return an AttributeSet containing every key in this AttributeMap.
Returns:
an AttributeSet containing every key in this AttributeMap

values

public java.util.Collection values()
Return a Collection containing every value in this AttributeMap.
Specified by:
values in interface java.util.Map
Returns:
a Collection containing every value in this AttributeMap

entrySet

public java.util.Set entrySet()
Return a Set containing all entries in this AttributeMap.
Specified by:
entrySet in interface java.util.Map

equals

public boolean equals(java.lang.Object rhs)
Specified by:
equals in interface java.util.Map
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Map
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

addAttribute

public AttributeMap addAttribute(java.lang.Object key,
                                 java.lang.Object value)
Return a AttributeMap which contains entries in this AttributeMap, along with an entry for . If attribute is already present in this AttributeMap its value becomes value.

addAttributes

public AttributeMap addAttributes(AttributeMap rhs)
Return a AttributeMap which contains entries in this AttributeMap and in rhs. If an attribute appears in both StyleSets the value from rhs is used.

addAttributes

public AttributeMap addAttributes(java.util.Map rhs)
Return a AttributeMap which contains entries in this AttributeMap and in rhs. If an attribute appears in both StyleSets the value from rhs is used. The Map's keys and values must be non-null.

removeAttribute

public AttributeMap removeAttribute(java.lang.Object attribute)
Return a AttributeMap with the entries in this AttributeMap, but without attribute as a key.

removeAttributes

public AttributeMap removeAttributes(AttributeSet attributes)
Return a AttributeMap with the entries of this AttributeMap whose attributes are not in the Set.

removeAttributes

public AttributeMap removeAttributes(java.util.Set attributes)
Return a AttributeMap with the entries of this AttributeMap whose attributes are not in the Set.

intersectWith

public AttributeMap intersectWith(AttributeSet attributes)
Return a AttributeMap with the keys of this AttributeMap which are also in the Set. The set must not contain null.

intersectWith

public AttributeMap intersectWith(java.util.Set attributes)
Return a AttributeMap with the keys of this AttributeMap which are also in the Set. The set must not contain null.

putAllInto

public void putAllInto(java.util.Map rhs)
Put all entries in this AttributeMap into the given Map.
Parameters:
rhs - the Map into which entries are placed


Copyright (c) 2001 IBM Corporation and others.