org.ujac.print
Class DefaultAttributeHandler

java.lang.Object
  extended by org.ujac.print.DefaultAttributeHandler
All Implemented Interfaces:
AttributeHandler

public class DefaultAttributeHandler
extends Object
implements AttributeHandler

Name: DefaultAttributeParser
Description: Default AttributeHandler implementation.

Author:
lauerc

Field Summary
 TypedAttributeHandler booleanHandler
          The boolean attribute handler.
 TypedAttributeHandler borderHandler
          The boolean attribute handler.
 TypedAttributeHandler colorHandler
          The color attribute handler.
 TypedAttributeHandler dimensionHandler
          The integer attribute handler.
 TypedAttributeHandler doubleHandler
          The double attribute handler.
 TypedAttributeHandler floatHandler
          The integer attribute handler.
 TypedAttributeHandler horizontalAlignmentHandler
          The horizontal alignment attribute handler.
 TypedAttributeHandler verticalAlignmentHandler
          The vertical alignment attribute handler.
 
Constructor Summary
DefaultAttributeHandler()
          Constructs a DefaultAttributeHandler instance with no specific attributes.
 
Method Summary
 TypedAttributeHandler getBooleanHandler()
          Gets the boolean attribute handler.
 TypedAttributeHandler getBorderHandler()
          Gets the boolean attribute handler.
 TypedAttributeHandler getColorHandler()
          Gets the color attribute handler.
 TypedAttributeHandler getDimensionHandler()
          Gets the dimension attribute handler.
 TypedAttributeHandler getDoubleHandler()
          Gets the double attribute handler.
 TypedAttributeHandler getEscapeSequenceTextHandler()
          Gets the integer attribute handler.
 TypedAttributeHandler getFloatHandler()
          Gets the float attribute handler.
 TypedAttributeHandler getHorizontalAlignmentHandler()
          Gets the horizontal alignment attribute handler.
 TypedAttributeHandler getIntegerHandler()
          Gets the integer attribute handler.
 TypedAttributeHandler getTextHandler()
          Gets the integer attribute handler.
 TypedAttributeHandler getVerticalAlignmentHandler()
          Gets the vertical alignment attribute handler.
 boolean parseBooleanAttribute(Locator locator, String attrName, Object attrValue, boolean evaluate)
          Gets the boolean value for the given attribute's name.
 int parseBorderAttribute(Locator locator, String attrName, Object attrValue, boolean evaluate)
          Parses the border value from the given attribute.
 Color parseColorAttribute(Locator locator, String attrName, Object attrValue, boolean evaluate)
          Parses the color value from the given attribute.
 float parseDimensionAttribute(Locator locator, String attrName, Object attrValue, boolean evaluate)
          Parses a dimension value from the given string.
 double parseDoubleAttribute(Locator locator, String attrName, Object attrValue, boolean evaluate)
          Parses a double value from the given string.
 float parseFloatAttribute(Locator locator, String attrName, Object attrValue, boolean evaluate)
          Parses a float value from the given string.
 int parseHorizontalAlignmentAttribute(Locator locator, String attrName, Object attrValue, boolean evaluate)
          Parses the horizontal alignment value from the given attribute.
 int parseIntAttribute(Locator locator, String attrName, Object attrValue, boolean evaluate)
          Parses an integer value from the given string.
 String parseTextAttribute(Locator locator, String attrName, Object attrValue, boolean evaluate, boolean translateEscapeSequences)
          Gets the value for the given attribute's name.
 int parseVerticalAlignmentAttribute(Locator locator, String attrName, Object attrValue, boolean evaluate)
          Parses the vertical alignment value from the given attribute.
protected  void processEscapeSequences(Locator locator, String attrName, String contents, StringBuffer buffer, boolean trimHead)
          Processes the escape sequences from the given content string and writes the result into the given buffer.
 void setDocumentHandler(DocumentHandler documentHandler)
          Sets the document handler.
 Object typeCastAttributeValue(Locator locator, AttributeDefinition attrDef, String attrName, Object value)
          Casts the given object value into a the correct type for the specified attribute definition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

floatHandler

public TypedAttributeHandler floatHandler
The integer attribute handler.


dimensionHandler

public TypedAttributeHandler dimensionHandler
The integer attribute handler.


doubleHandler

public TypedAttributeHandler doubleHandler
The double attribute handler.


booleanHandler

public TypedAttributeHandler booleanHandler
The boolean attribute handler.


colorHandler

public TypedAttributeHandler colorHandler
The color attribute handler.


borderHandler

public TypedAttributeHandler borderHandler
The boolean attribute handler.


horizontalAlignmentHandler

public TypedAttributeHandler horizontalAlignmentHandler
The horizontal alignment attribute handler.


verticalAlignmentHandler

public TypedAttributeHandler verticalAlignmentHandler
The vertical alignment attribute handler.

Constructor Detail

DefaultAttributeHandler

public DefaultAttributeHandler()
Constructs a DefaultAttributeHandler instance with no specific attributes.

Method Detail

setDocumentHandler

public void setDocumentHandler(DocumentHandler documentHandler)
Sets the document handler.

Specified by:
setDocumentHandler in interface AttributeHandler
Parameters:
documentHandler - The document handler to set.

typeCastAttributeValue

public Object typeCastAttributeValue(Locator locator,
                                     AttributeDefinition attrDef,
                                     String attrName,
                                     Object value)
                              throws DocumentHandlerException
Casts the given object value into a the correct type for the specified attribute definition.

Specified by:
typeCastAttributeValue in interface AttributeHandler
Parameters:
locator - The source locator.
attrDef - The attribute definition.
attrName - The attribute name.
value - The value to convert.
Returns:
The converted value.
Throws:
DocumentHandlerException - In case the type conversion failed.

parseTextAttribute

public String parseTextAttribute(Locator locator,
                                 String attrName,
                                 Object attrValue,
                                 boolean evaluate,
                                 boolean translateEscapeSequences)
                          throws TagAttributeException
Gets the value for the given attribute's name. Works like method getStringAttribute(java.lang.String, java.lang.String, boolean) but takes care of escape sequences.

Specified by:
parseTextAttribute in interface AttributeHandler
Parameters:
locator - The tag source locator.
attrName - The attribute's name.
attrValue - The argument value.
evaluate - If this flag is set to true, the attribute will get evaluated.
translateEscapeSequences - Tells whether or not to translate escape sequences.
Returns:
The determined value.
Throws:
TagAttributeException - if the item contains an invalid value or an required attribute was not defined.

parseIntAttribute

public int parseIntAttribute(Locator locator,
                             String attrName,
                             Object attrValue,
                             boolean evaluate)
                      throws TagAttributeException
Parses an integer value from the given string.

Specified by:
parseIntAttribute in interface AttributeHandler
Parameters:
locator - The tag source locator.
attrName - The attribute's name.
attrValue - The argument value.
evaluate - If this flag is set to true, the attribute will get evaluated.
Returns:
The determined value.
Throws:
TagAttributeException - Thrown in case the item contained an invalid value.

parseFloatAttribute

public float parseFloatAttribute(Locator locator,
                                 String attrName,
                                 Object attrValue,
                                 boolean evaluate)
                          throws TagAttributeException
Parses a float value from the given string.

Specified by:
parseFloatAttribute in interface AttributeHandler
Parameters:
locator - The tag source locator.
attrName - The attribute's name.
attrValue - The argument value.
evaluate - If this flag is set to true, the attribute will get evaluated.
Returns:
The determined value.
Throws:
TagAttributeException - Thrown in case the item contained an invalid value.

parseDimensionAttribute

public float parseDimensionAttribute(Locator locator,
                                     String attrName,
                                     Object attrValue,
                                     boolean evaluate)
                              throws TagAttributeException
Parses a dimension value from the given string.

Specified by:
parseDimensionAttribute in interface AttributeHandler
Parameters:
locator - The tag source locator.
attrName - The attribute's name.
attrValue - The argument value.
evaluate - If this flag is set to true, the attribute will get evaluated.
Returns:
The determined value.
Throws:
TagAttributeException - Thrown in case the item contained an invalid value.

parseDoubleAttribute

public double parseDoubleAttribute(Locator locator,
                                   String attrName,
                                   Object attrValue,
                                   boolean evaluate)
                            throws TagAttributeException
Parses a double value from the given string.

Specified by:
parseDoubleAttribute in interface AttributeHandler
Parameters:
locator - The tag source locator.
attrName - The attribute's name.
attrValue - The argument value.
evaluate - If this flag is set to true, the attribute will get evaluated.
Returns:
The determined value.
Throws:
TagAttributeException - Thrown in case the item contained an invalid value.

parseBooleanAttribute

public boolean parseBooleanAttribute(Locator locator,
                                     String attrName,
                                     Object attrValue,
                                     boolean evaluate)
                              throws TagAttributeException
Gets the boolean value for the given attribute's name.

Specified by:
parseBooleanAttribute in interface AttributeHandler
Parameters:
locator - The tag source locator.
attrName - The attribute's name.
attrValue - The argument value.
evaluate - If this flag is set to true, the attribute will get evaluated.
Returns:
The determined value.
Throws:
TagAttributeException - if the item contains an invalid value or an required attribute was not defined.

parseColorAttribute

public Color parseColorAttribute(Locator locator,
                                 String attrName,
                                 Object attrValue,
                                 boolean evaluate)
                          throws TagAttributeException
Parses the color value from the given attribute.

Specified by:
parseColorAttribute in interface AttributeHandler
Parameters:
locator - The tag source locator.
attrName - The name of the attribute to parse.
attrValue - The attribute value to parse.
evaluate - If this flag is set to true, the attribute will get evaluated.
Returns:
The resulting border style.
Throws:
TagAttributeException - Thrown in case the item contained an invalid value.

parseBorderAttribute

public int parseBorderAttribute(Locator locator,
                                String attrName,
                                Object attrValue,
                                boolean evaluate)
                         throws TagAttributeException
Parses the border value from the given attribute.

Specified by:
parseBorderAttribute in interface AttributeHandler
Parameters:
locator - The tag source locator.
attrName - The name of the attribute to parse.
attrValue - The attribute value to parse.
evaluate - If this flag is set to true, the attribute will get evaluated.
Returns:
The resulting border style.
Throws:
TagAttributeException - Thrown in case the item contained an invalid value.

parseHorizontalAlignmentAttribute

public int parseHorizontalAlignmentAttribute(Locator locator,
                                             String attrName,
                                             Object attrValue,
                                             boolean evaluate)
                                      throws TagAttributeException
Parses the horizontal alignment value from the given attribute.

Specified by:
parseHorizontalAlignmentAttribute in interface AttributeHandler
Parameters:
locator - The tag source locator.
attrName - The name of the attribute to parse.
attrValue - The attribute value to parse.
evaluate - If this flag is set to true, the attribute will get evaluated.
Returns:
The resulting horizontal alignment.
Throws:
TagAttributeException - Thrown in case the item contained an invalid value.

parseVerticalAlignmentAttribute

public int parseVerticalAlignmentAttribute(Locator locator,
                                           String attrName,
                                           Object attrValue,
                                           boolean evaluate)
                                    throws TagAttributeException
Parses the vertical alignment value from the given attribute.

Specified by:
parseVerticalAlignmentAttribute in interface AttributeHandler
Parameters:
locator - The tag source locator.
attrName - The name of the attribute to parse.
attrValue - The attribute value to parse.
evaluate - If this flag is set to true, the attribute will get evaluated.
Returns:
The resulting vertical alignment.
Throws:
TagAttributeException - Thrown in case the item contained an invalid value.

processEscapeSequences

protected void processEscapeSequences(Locator locator,
                                      String attrName,
                                      String contents,
                                      StringBuffer buffer,
                                      boolean trimHead)
                               throws DocumentHandlerException
Processes the escape sequences from the given content string and writes the result into the given buffer.

Parameters:
locator - The tag source locator.
attrName - The attribute name.
contents - The contents to parse for escape sequences
buffer - The buffer to write to.
trimHead - Tells whether or not to trim the leading white spaces
Throws:
DocumentHandlerException

getTextHandler

public TypedAttributeHandler getTextHandler()
Gets the integer attribute handler.

Specified by:
getTextHandler in interface AttributeHandler
Returns:
The integer attribute handler

getEscapeSequenceTextHandler

public TypedAttributeHandler getEscapeSequenceTextHandler()
Gets the integer attribute handler.

Specified by:
getEscapeSequenceTextHandler in interface AttributeHandler
Returns:
The integer attribute handler

getIntegerHandler

public TypedAttributeHandler getIntegerHandler()
Gets the integer attribute handler.

Specified by:
getIntegerHandler in interface AttributeHandler
Returns:
The integer attribute handler

getFloatHandler

public TypedAttributeHandler getFloatHandler()
Gets the float attribute handler.

Specified by:
getFloatHandler in interface AttributeHandler
Returns:
The integer attribute handler

getDimensionHandler

public TypedAttributeHandler getDimensionHandler()
Gets the dimension attribute handler.

Specified by:
getDimensionHandler in interface AttributeHandler
Returns:
The integer attribute handler

getDoubleHandler

public TypedAttributeHandler getDoubleHandler()
Gets the double attribute handler.

Specified by:
getDoubleHandler in interface AttributeHandler
Returns:
The double attribute handler

getBooleanHandler

public TypedAttributeHandler getBooleanHandler()
Gets the boolean attribute handler.

Specified by:
getBooleanHandler in interface AttributeHandler
Returns:
The boolean attribute handler

getColorHandler

public TypedAttributeHandler getColorHandler()
Gets the color attribute handler.

Specified by:
getColorHandler in interface AttributeHandler
Returns:
The color attribute handler

getBorderHandler

public TypedAttributeHandler getBorderHandler()
Gets the boolean attribute handler.

Specified by:
getBorderHandler in interface AttributeHandler
Returns:
The boolean attribute handler

getHorizontalAlignmentHandler

public TypedAttributeHandler getHorizontalAlignmentHandler()
Gets the horizontal alignment attribute handler.

Specified by:
getHorizontalAlignmentHandler in interface AttributeHandler
Returns:
The horizontal alignment attribute handler

getVerticalAlignmentHandler

public TypedAttributeHandler getVerticalAlignmentHandler()
Gets the vertical alignment attribute handler.

Specified by:
getVerticalAlignmentHandler in interface AttributeHandler
Returns:
The vertical alignment attribute handler


Copyright © 2003-2004 UJAC.org. All Rights Reserved.