public class MarkupParser
extends java.util.HashMap
Modifier and Type | Field and Description |
---|---|
protected java.util.HashMap |
fontcache
HashMap with fonts for each known combination of tag/id/class.
|
protected java.util.HashMap |
stylecache
HashMap with styles for each known combination of tag/id/class.
|
Constructor and Description |
---|
MarkupParser(java.lang.String file)
Creates new MarkupParser
|
Modifier and Type | Method and Description |
---|---|
private void |
applyBordersColors(Rectangle rect,
java.util.Properties attributes,
java.util.Properties styleattributes)
Applies colors to a Rectangle object.
|
static java.awt.Color |
decodeColor(java.lang.String color)
Converts a
Color into a HTML representation of this
Color . |
Font |
getFont(java.util.Properties attributes)
Returns a font based on the ID and CLASS attributes of a tag.
|
private java.lang.String |
getKey(java.util.Properties attributes)
Generates a key for an tag/id/class combination and adds the style
attributes to the stylecache.
|
Element |
getObject(java.util.Properties attributes)
Returns an object based on a tag and its attributes.
|
boolean |
getPageBreakAfter(java.util.Properties attributes)
Returns pagebreak information.
|
boolean |
getPageBreakBefore(java.util.Properties attributes)
Returns pagebreak information.
|
Rectangle |
getRectangle(java.util.Properties attrs)
Returns a rectangle based on the width and height attributes of a tag,
can be overridden by the ID and CLASS attributes.
|
static java.util.Properties |
parseAttributes(java.lang.String string)
This method parses a String with attributes and returns a Properties
object.
|
static float |
parseLength(java.lang.String string)
Parses a length.
|
static java.lang.String |
removeComment(java.lang.String string,
java.lang.String startComment,
java.lang.String endComment)
Removes the comments sections of a String.
|
Font |
retrieveFont(java.util.Properties styleAttributes)
Retrieves a font from the FontFactory based on some style attributes.
|
private Element |
retrieveListItem(Font font,
java.util.Properties styleattributes)
Returns a ListItem based on the styleattributes.
|
Element |
retrieveParagraph(Font font,
java.util.Properties styleattributes)
Retrieves a Paragraph based on some style attributes.
|
Element |
retrievePhrase(Font font,
java.util.Properties styleattributes)
Retrieves a Phrase based on some style attributes.
|
private Element |
retrieveTable(java.util.Properties attributes,
java.util.Properties styleattributes)
Gets a table based on the styleattributes.
|
private Element |
retrieveTableCell(java.util.Properties attributes,
java.util.Properties styleattributes)
Returns a Cell based on the styleattributes.
|
private Element |
retrieveTableRow(java.util.Properties attributes,
java.util.Properties styleattributes)
Returns a Cell based on the styleattributes.
|
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
protected java.util.HashMap stylecache
protected java.util.HashMap fontcache
public MarkupParser(java.lang.String file)
file
- the path to a CSS file.public static java.lang.String removeComment(java.lang.String string, java.lang.String startComment, java.lang.String endComment)
string
- the original StringstartComment
- the String that marks the start of a Comment sectionendComment
- the String that marks the end of a Comment section.public static java.util.Properties parseAttributes(java.lang.String string)
string
- a String of this form: 'key1="value1"; key2="value2";...
keyN="valueN" 'public static float parseLength(java.lang.String string)
string
- a length in the form of an optional + or -, followed by a
number and a unit.public static java.awt.Color decodeColor(java.lang.String color)
Color
into a HTML representation of this
Color
.color
- the Color
that has to be converted.private java.lang.String getKey(java.util.Properties attributes)
attributes
- a Properties object with the tagname and the attributes of the
tag.public boolean getPageBreakBefore(java.util.Properties attributes)
attributes
- public boolean getPageBreakAfter(java.util.Properties attributes)
attributes
- public Element getObject(java.util.Properties attributes)
attributes
- a Properties object with the tagname and the attributes of the
tag.public Font getFont(java.util.Properties attributes)
attributes
- a Properties object with the tagname and the attributes of the
tag.public Rectangle getRectangle(java.util.Properties attrs)
attrs
- the attributes that came with the tagpublic Element retrievePhrase(Font font, java.util.Properties styleattributes)
font
- styleattributes
- a Properties object containing keys and valuespublic Element retrieveParagraph(Font font, java.util.Properties styleattributes)
font
- styleattributes
- a Properties object containing keys and valuesprivate Element retrieveTable(java.util.Properties attributes, java.util.Properties styleattributes)
attributes
- styleattributes
- private Element retrieveTableRow(java.util.Properties attributes, java.util.Properties styleattributes)
attributes
- styleattributes
- private Element retrieveTableCell(java.util.Properties attributes, java.util.Properties styleattributes)
attributes
- styleattributes
- private Element retrieveListItem(Font font, java.util.Properties styleattributes)
font
- styleattributes
- private void applyBordersColors(Rectangle rect, java.util.Properties attributes, java.util.Properties styleattributes)
rect
- attributes
- styleattributes
- public Font retrieveFont(java.util.Properties styleAttributes)
styleAttributes
- a Properties object containing keys and values