net.sf.jett.parser
Class StyleParser

java.lang.Object
  extended by net.sf.jett.parser.StyleParser

public class StyleParser
extends java.lang.Object

A StyleParser parses "CSS" text, from beginning to end, in a CSS-like format: [.styleName { propertyName: value [; propertyName: value]* }]*

If a property value is an empty string or the property is not present, then it will be ignored. Unrecognized property names and unrecognized values for a property are ignored. Property names and values may be specified in a case insensitive-fashion, i.e. "CENTER" = "Center" = "center".

Both CSS files and the "style" attribute of the "style" tag recognize the following property names.

Properties: The following properties control alignment, borders, colors, etc., everything but the font characteristics.

Properties: The following properties control the font characteristics.

Since:
0.5.0
Author:
Randy Gettman

Field Summary
static short POI_ROTATION_STACKED
          POI value of rotation to use to produce vertically
static java.lang.String PROPERTY_ALIGNMENT
          The property to specify horizontal alignment of the text.
static java.lang.String PROPERTY_BORDER
          The property to specify the type of all 4 borders.
static java.lang.String PROPERTY_BORDER_BOTTOM
          The property to specify the type of the bottom border.
static java.lang.String PROPERTY_BORDER_COLOR
          The property to specify the color of all 4 borders.
static java.lang.String PROPERTY_BORDER_LEFT
          The property to specify the type of the left border.
static java.lang.String PROPERTY_BORDER_RIGHT
          The property to specify the type of the right border.
static java.lang.String PROPERTY_BORDER_TOP
          The property to specify the type of the top border.
static java.lang.String PROPERTY_BOTTOM_BORDER_COLOR
          The property to specify the color of the bottom border.
static java.lang.String PROPERTY_COLUMN_WIDTH_IN_CHARS
          The property to specify the width of the column in number of characters.
static java.lang.String PROPERTY_DATA_FORMAT
          The property to specify the numeric or date data format string.
static java.lang.String PROPERTY_FILL_BACKGROUND_COLOR
          The property to specify the fill background color to be used in a fill pattern.
static java.lang.String PROPERTY_FILL_FOREGROUND_COLOR
          The property to specify the fill foreground color to be used in a fill pattern.
static java.lang.String PROPERTY_FILL_PATTERN
          The property to specify the fill fattern to be used with the fill foreground color and the fill background color.
static java.lang.String PROPERTY_FONT_BOLDWEIGHT
          The property to specify whether the font is bold.
static java.lang.String PROPERTY_FONT_CHARSET
          The property to specify the charset used by the font.
static java.lang.String PROPERTY_FONT_COLOR
          The property to specify the font color.
static java.lang.String PROPERTY_FONT_HEIGHT_IN_POINTS
          The property to specify the font height in points.
static java.lang.String PROPERTY_FONT_ITALIC
          The property to specify whether the font is italic.
static java.lang.String PROPERTY_FONT_NAME
          The property to specify the font name.
static java.lang.String PROPERTY_FONT_STRIKEOUT
          The property to specify whether the font is strikeout.
static java.lang.String PROPERTY_FONT_TYPE_OFFSET
          The property to specify whether the font type is offset, and if it is, whether it's superscript or subscript.
static java.lang.String PROPERTY_FONT_UNDERLINE
          The property to specify how the font text is underlined.
static java.lang.String PROPERTY_HIDDEN
          The property to specify the "hidden" property.
static java.lang.String PROPERTY_INDENTION
          The property to specify the number of characters that the text is indented.
static java.lang.String PROPERTY_LEFT_BORDER_COLOR
          The property to specify the color of the left border.
static java.lang.String PROPERTY_LOCKED
          The property to specify the "locked" property.
static java.lang.String PROPERTY_RIGHT_BORDER_COLOR
          The property to specify the color of the right border.
static java.lang.String PROPERTY_ROTATION
          The property to specify the number of degrees that the text is rotated, from -90 to +90.
static java.lang.String PROPERTY_ROW_HEIGHT_IN_POINTS
          The property to specify the height of the row in points.
static java.lang.String PROPERTY_TOP_BORDER_COLOR
          The property to specify the color of the top border.
static java.lang.String PROPERTY_VERTICAL_ALIGNMENT
          The property to specify the vertical alignment of the text.
static java.lang.String PROPERTY_WRAP_TEXT
          The property to specify whether long text values are wrapped to the next physical line within the cell.
static java.lang.String ROTATION_STACKED
          Specify this value of rotation to use to produce vertically
 
Constructor Summary
StyleParser()
          Create a StyleParser.
StyleParser(java.lang.String cssText)
          Create a StyleParser object that will parse the given css text.
 
Method Summary
static void addStyle(Style style, java.lang.String property, java.lang.String value)
          Depending on the given property, parse the given value and set the appropriate attribute in the given Style object.
 java.util.Map<java.lang.String,Style> getStyleMap()
          Returns the style map of style names to Styles.
 void parse()
          Parses the CSS text.
 void setCssText(java.lang.String cssText)
          Sets the CSS text to the given CSS text and resets the parser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_ALIGNMENT

public static final java.lang.String PROPERTY_ALIGNMENT
The property to specify horizontal alignment of the text.

See Also:
Alignment, Constant Field Values

PROPERTY_BORDER

public static final java.lang.String PROPERTY_BORDER
The property to specify the type of all 4 borders.

See Also:
BorderType, Constant Field Values

PROPERTY_BORDER_BOTTOM

public static final java.lang.String PROPERTY_BORDER_BOTTOM
The property to specify the type of the bottom border.

See Also:
BorderType, Constant Field Values

PROPERTY_BORDER_LEFT

public static final java.lang.String PROPERTY_BORDER_LEFT
The property to specify the type of the left border.

See Also:
BorderType, Constant Field Values

PROPERTY_BORDER_RIGHT

public static final java.lang.String PROPERTY_BORDER_RIGHT
The property to specify the type of the right border.

See Also:
BorderType, Constant Field Values

PROPERTY_BORDER_TOP

public static final java.lang.String PROPERTY_BORDER_TOP
The property to specify the type of the top border.

See Also:
BorderType, Constant Field Values

PROPERTY_BORDER_COLOR

public static final java.lang.String PROPERTY_BORDER_COLOR
The property to specify the color of all 4 borders.

See Also:
ExcelColor, Constant Field Values

PROPERTY_BOTTOM_BORDER_COLOR

public static final java.lang.String PROPERTY_BOTTOM_BORDER_COLOR
The property to specify the color of the bottom border.

See Also:
ExcelColor, Constant Field Values

PROPERTY_LEFT_BORDER_COLOR

public static final java.lang.String PROPERTY_LEFT_BORDER_COLOR
The property to specify the color of the left border.

See Also:
ExcelColor, Constant Field Values

PROPERTY_RIGHT_BORDER_COLOR

public static final java.lang.String PROPERTY_RIGHT_BORDER_COLOR
The property to specify the color of the right border.

See Also:
ExcelColor, Constant Field Values

PROPERTY_TOP_BORDER_COLOR

public static final java.lang.String PROPERTY_TOP_BORDER_COLOR
The property to specify the color of the top border.

See Also:
ExcelColor, Constant Field Values

PROPERTY_COLUMN_WIDTH_IN_CHARS

public static final java.lang.String PROPERTY_COLUMN_WIDTH_IN_CHARS
The property to specify the width of the column in number of characters.

See Also:
Constant Field Values

PROPERTY_DATA_FORMAT

public static final java.lang.String PROPERTY_DATA_FORMAT
The property to specify the numeric or date data format string.

See Also:
Constant Field Values

PROPERTY_FILL_BACKGROUND_COLOR

public static final java.lang.String PROPERTY_FILL_BACKGROUND_COLOR
The property to specify the fill background color to be used in a fill pattern.

See Also:
ExcelColor, Constant Field Values

PROPERTY_FILL_FOREGROUND_COLOR

public static final java.lang.String PROPERTY_FILL_FOREGROUND_COLOR
The property to specify the fill foreground color to be used in a fill pattern.

See Also:
ExcelColor, Constant Field Values

PROPERTY_FILL_PATTERN

public static final java.lang.String PROPERTY_FILL_PATTERN
The property to specify the fill fattern to be used with the fill foreground color and the fill background color.

See Also:
FillPattern, Constant Field Values

PROPERTY_HIDDEN

public static final java.lang.String PROPERTY_HIDDEN
The property to specify the "hidden" property.

See Also:
Constant Field Values

PROPERTY_INDENTION

public static final java.lang.String PROPERTY_INDENTION
The property to specify the number of characters that the text is indented.

See Also:
Constant Field Values

PROPERTY_LOCKED

public static final java.lang.String PROPERTY_LOCKED
The property to specify the "locked" property.

See Also:
Constant Field Values

PROPERTY_ROTATION

public static final java.lang.String PROPERTY_ROTATION
The property to specify the number of degrees that the text is rotated, from -90 to +90.

See Also:
Constant Field Values

PROPERTY_ROW_HEIGHT_IN_POINTS

public static final java.lang.String PROPERTY_ROW_HEIGHT_IN_POINTS
The property to specify the height of the row in points.

See Also:
Constant Field Values

PROPERTY_VERTICAL_ALIGNMENT

public static final java.lang.String PROPERTY_VERTICAL_ALIGNMENT
The property to specify the vertical alignment of the text.

See Also:
VerticalAlignment, Constant Field Values

PROPERTY_WRAP_TEXT

public static final java.lang.String PROPERTY_WRAP_TEXT
The property to specify whether long text values are wrapped to the next physical line within the cell.

See Also:
Constant Field Values

PROPERTY_FONT_BOLDWEIGHT

public static final java.lang.String PROPERTY_FONT_BOLDWEIGHT
The property to specify whether the font is bold.

See Also:
Constant Field Values

PROPERTY_FONT_CHARSET

public static final java.lang.String PROPERTY_FONT_CHARSET
The property to specify the charset used by the font.

See Also:
FontCharset, Constant Field Values

PROPERTY_FONT_COLOR

public static final java.lang.String PROPERTY_FONT_COLOR
The property to specify the font color.

See Also:
ExcelColor, Constant Field Values

PROPERTY_FONT_HEIGHT_IN_POINTS

public static final java.lang.String PROPERTY_FONT_HEIGHT_IN_POINTS
The property to specify the font height in points.

See Also:
Constant Field Values

PROPERTY_FONT_NAME

public static final java.lang.String PROPERTY_FONT_NAME
The property to specify the font name.

See Also:
Constant Field Values

PROPERTY_FONT_ITALIC

public static final java.lang.String PROPERTY_FONT_ITALIC
The property to specify whether the font is italic.

See Also:
Constant Field Values

PROPERTY_FONT_STRIKEOUT

public static final java.lang.String PROPERTY_FONT_STRIKEOUT
The property to specify whether the font is strikeout.

See Also:
Constant Field Values

PROPERTY_FONT_TYPE_OFFSET

public static final java.lang.String PROPERTY_FONT_TYPE_OFFSET
The property to specify whether the font type is offset, and if it is, whether it's superscript or subscript.

See Also:
FontTypeOffset, Constant Field Values

PROPERTY_FONT_UNDERLINE

public static final java.lang.String PROPERTY_FONT_UNDERLINE
The property to specify how the font text is underlined.

See Also:
FontUnderline, Constant Field Values

ROTATION_STACKED

public static final java.lang.String ROTATION_STACKED

Specify this value of rotation to use to produce vertically


s
t
a
c
k
e
d

text.

See Also:
PROPERTY_ROTATION, Constant Field Values

POI_ROTATION_STACKED

public static final short POI_ROTATION_STACKED

POI value of rotation to use to produce vertically


s
t
a
c
k
e
d

text.

See Also:
PROPERTY_ROTATION, Constant Field Values
Constructor Detail

StyleParser

public StyleParser()
Create a StyleParser.


StyleParser

public StyleParser(java.lang.String cssText)
Create a StyleParser object that will parse the given css text.

Parameters:
cssText - The CSS text.
Method Detail

setCssText

public void setCssText(java.lang.String cssText)
Sets the CSS text to the given CSS text and resets the parser.

Parameters:
cssText - The new CSS text.

parse

public void parse()
Parses the CSS text.


addStyle

public static void addStyle(Style style,
                            java.lang.String property,
                            java.lang.String value)
Depending on the given property, parse the given value and set the appropriate attribute in the given Style object.

Parameters:
style - A Style.
property - A property name, which should be one of the property name constants defined in this class.
value - The property value, the meaning of which is property-specific.

getStyleMap

public java.util.Map<java.lang.String,Style> getStyleMap()
Returns the style map of style names to Styles.

Returns:
A Map of style names to Styles.


Copyright © 2012-2013 Jett Team. All Rights Reserved.