## com.lowagie.text.markup
Class MarkupParser

    java.lang.Object
      java.util.AbstractMap<K,V>
          java.util.HashMap
              com.lowagie.text.markup.MarkupParser

All Implemented Interfaces:
  java.io.Serializable, java.lang.Cloneable, java.util.Map

    public class MarkupParser

extends java.util.HashMap

This class is a HashMap that contains selectors (String) and styles (a Properties object). Given a tag and its attributes (id/class), this class can return an iText object with the according style.

Author:
  blowagie
See Also:
  Serialized Form

Field Summary
`static java.util.HashMap` `colorTable`
`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 Summary
`MarkupParser(java.lang.String file)` Creates new MarkupParser

Method Summary
`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 s)` 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.

Methods inherited from class java.util.HashMap
`clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values`

Methods inherited from class java.util.AbstractMap
`equals, hashCode, toString`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Methods inherited from interface java.util.Map
`equals, hashCode`

Field Detail

### stylecache

    protected java.util.HashMap stylecache

  HashMap with styles for each known combination of tag/id/class. The key is a String-combination, the value a Properties object.

### fontcache

    protected java.util.HashMap fontcache

  HashMap with fonts for each known combination of tag/id/class. The key is the same String-combination used for the stylecache.

### colorTable

    public static java.util.HashMap colorTable

Constructor Detail

### MarkupParser

    public MarkupParser(java.lang.String file)

  Creates new MarkupParser

  Parameters:
    `file` - the path to a CSS file.

Method Detail

### removeComment

    public static java.lang.String removeComment(java.lang.String string,
                                                 java.lang.String startComment,
                                                 java.lang.String endComment)

  Removes the comments sections of a String.

  Parameters:
    `string` - the original String
    `startComment` - the String that marks the start of a Comment section
    `endComment` - the String that marks the end of a Comment section.
  Returns:
    the String stripped of its comment section

### parseAttributes

    public static java.util.Properties parseAttributes(java.lang.String string)

  This method parses a String with attributes and returns a Properties object.

  Parameters:
    `string` - a String of this form: 'key1="value1"; key2="value2";... keyN="valueN" '
  Returns:
    a Properties object

### parseLength

    public static float parseLength(java.lang.String string)

  Parses a length.

  Parameters:
    `string` - a length in the form of an optional + or -, followed by a number and a unit.
  Returns:
    a float

### decodeColor

    public static java.awt.Color decodeColor(java.lang.String s)

  Converts a `Color` into a HTML representation of this `Color`.

  Parameters:
    `color` - the `Color` that has to be converted.
  Returns:
    the HTML representation of this <COLOR>Color </COLOR>

### getKey

    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.

  Parameters:
    `attributes` - a Properties object with the tagname and the attributes of the tag.
  Returns:
    a key

### getPageBreakBefore

    public boolean getPageBreakBefore(java.util.Properties attributes)

  Returns pagebreak information.

  Parameters:
    `attributes` -
  Returns:
    true if a page break is needed before the tag

### getPageBreakAfter

    public boolean getPageBreakAfter(java.util.Properties attributes)

  Returns pagebreak information.

  Parameters:
    `attributes` -
  Returns:
    true if a page break is needed after the tag

### getObject

    public Element getObject(java.util.Properties attributes)

  Returns an object based on a tag and its attributes.

  Parameters:
    `attributes` - a Properties object with the tagname and the attributes of the tag.
  Returns:
    an iText object

### getFont

    public Font getFont(java.util.Properties attributes)

  Returns a font based on the ID and CLASS attributes of a tag.

  Parameters:
    `attributes` - a Properties object with the tagname and the attributes of the tag.
  Returns:
    an iText Font;

### getRectangle

    public 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.

  Parameters:
    `attrs` - the attributes that came with the tag
  Returns:
    an iText Rectangle object

### retrievePhrase

    public Element retrievePhrase(Font font,
                                  java.util.Properties styleattributes)

  Retrieves a Phrase based on some style attributes.

  Parameters:
    `font` -
    `styleattributes` - a Properties object containing keys and values
  Returns:
    an iText Phrase object

### retrieveParagraph

    public Element retrieveParagraph(Font font,
                                     java.util.Properties styleattributes)

  Retrieves a Paragraph based on some style attributes.

  Parameters:
    `font` -
    `styleattributes` - a Properties object containing keys and values
  Returns:
    an iText Paragraph object

### retrieveTable

    private Element retrieveTable(java.util.Properties attributes,
                                  java.util.Properties styleattributes)

  Gets a table based on the styleattributes.

  Parameters:
    `attributes` -
    `styleattributes` -
  Returns:
    an iText Table

### retrieveTableRow

    private Element retrieveTableRow(java.util.Properties attributes,
                                     java.util.Properties styleattributes)

  Returns a Cell based on the styleattributes.

  Parameters:
    `attributes` -
    `styleattributes` -
  Returns:
    an iText Cell

### retrieveTableCell

    private Element retrieveTableCell(java.util.Properties attributes,
                                      java.util.Properties styleattributes)

  Returns a Cell based on the styleattributes.

  Parameters:
    `attributes` -
    `styleattributes` -
  Returns:
    an iText Cell

### retrieveListItem

    private Element retrieveListItem(Font font,
                                     java.util.Properties styleattributes)

  Returns a ListItem based on the styleattributes.

  Parameters:
    `font` -
    `styleattributes` -
  Returns:
    an iText ListItem

### applyBordersColors

    private void applyBordersColors(Rectangle rect,
                                    java.util.Properties attributes,
                                    java.util.Properties styleattributes)

  Applies colors to a Rectangle object.

  Parameters:
    `rect` -
    `attributes` -
    `styleattributes` -

### retrieveFont

    public Font retrieveFont(java.util.Properties styleAttributes)

  Retrieves a font from the FontFactory based on some style attributes. Looks for the font-family, font-size, font-weight, font-style and color. Takes the default encoding and embedded value.

  Parameters:
    `styleAttributes` - a Properties object containing keys and values
  Returns:
    an iText Font object