com.ibm.richtext.styledtext
Class StyleModifier

java.lang.Object
  |
  +--com.ibm.richtext.styledtext.StyleModifier

public class StyleModifier
extends java.lang.Object

StyleModifier is the base class for operations on AttributeMap. To implement an operation on AttributeMap, subclass StyleModifier and override modifyStyle. StyleModifiers are used by MText.

For convenience, this class contains factory methods which will create a StyleModifier for certain common operations: attribute union, attribute removal, and AttributeMap replacement.

See Also:
AttributeMap, AttributeSet, MText

Field Summary
static StyleModifier IDENTITY
          A StyleModifier which simply returns the given style.
 
Constructor Summary
protected StyleModifier()
          Create a StyleModifier.
 
Method Summary
static StyleModifier createAddModifier(AttributeMap s)
          Create a StyleModifier whose operation is style.addAttributes(s), where style is the AttributeMap passed to modifyStyle.
static StyleModifier createAddModifier(java.lang.Object key, java.lang.Object value)
          Create a StyleModifier whose operation is style.addAttribute(key, value), where style is the AttributeMap passed to modifyStyle.
static StyleModifier createRemoveModifier(AttributeSet s)
          Create a StyleModifier whose operation is style.removeAttributes(s), where style is the AttributeMap passed to modifyStyle.
static StyleModifier createReplaceModifier(AttributeMap s)
          Create a StyleModifier whose operation returns s, ignoring the parameter to modifyStyle.
 AttributeMap modifyStyle(AttributeMap style)
          Return the result of this StyleModifier's operation on the given style.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IDENTITY

public static final StyleModifier IDENTITY
A StyleModifier which simply returns the given style.
Constructor Detail

StyleModifier

protected StyleModifier()
Create a StyleModifier.
Method Detail

modifyStyle

public AttributeMap modifyStyle(AttributeMap style)
Return the result of this StyleModifier's operation on the given style. Default implementation just returns the given style.
Parameters:
style - the AttributeMap to perform the operation on

createAddModifier

public static StyleModifier createAddModifier(AttributeMap s)
Create a StyleModifier whose operation is style.addAttributes(s), where style is the AttributeMap passed to modifyStyle.
Parameters:
s - the AttributeMap to union with
Returns:
a StyleModifier for this operation

createAddModifier

public static StyleModifier createAddModifier(java.lang.Object key,
                                              java.lang.Object value)
Create a StyleModifier whose operation is style.addAttribute(key, value), where style is the AttributeMap passed to modifyStyle.
Parameters:
key - the key to add
value - the value to add
Returns:
a StyleModifier for this operation

createReplaceModifier

public static StyleModifier createReplaceModifier(AttributeMap s)
Create a StyleModifier whose operation returns s, ignoring the parameter to modifyStyle.
Parameters:
s - the AttributeMap which will replace any other AttributeMap
Returns:
a StyleModifier for this operation

createRemoveModifier

public static StyleModifier createRemoveModifier(AttributeSet s)
Create a StyleModifier whose operation is style.removeAttributes(s), where style is the AttributeMap passed to modifyStyle.
Parameters:
s - the AttributeSet of attributes to remove
Returns:
a StyleModifier for this operation


Copyright (c) 1998-2000 IBM Corporation and others.