Class ReportParserUtil


  • public final class ReportParserUtil
    extends Object
    A helper class to make parsing the xml files a lot easier.
    Author:
    Thomas Morgner
    • Method Detail

      • isIncluded

        public static boolean isIncluded​(org.pentaho.reporting.libraries.xmlns.parser.RootXmlReadHandler rootXmlReadHandler)
        Checks whether this report is a included report and not the main report definition.
        Parameters:
        rootXmlReadHandler - the root handler that provides access to the properties.
        Returns:
        true, if the report is included, false otherwise.
      • parseVerticalElementAlignment

        public static ElementAlignment parseVerticalElementAlignment​(String value,
                                                                     Locator locator)
                                                              throws org.pentaho.reporting.libraries.xmlns.parser.ParseException
        Parses a vertical alignment value.
        Parameters:
        value - the text to parse.
        locator - the locator provides the current parse position for meaningful error messages.
        Returns:
        the element alignment.
        Throws:
        org.pentaho.reporting.libraries.xmlns.parser.ParseException - if the alignment value is not recognised.
      • parseHorizontalElementAlignment

        public static ElementAlignment parseHorizontalElementAlignment​(String value,
                                                                       Locator locator)
                                                                throws org.pentaho.reporting.libraries.xmlns.parser.ParseException
        Parses a horizontal alignment value.
        Parameters:
        value - the text to parse.
        locator - the locator provides the current parse position for meaningful error messages.
        Returns:
        the element alignment.
        Throws:
        org.pentaho.reporting.libraries.xmlns.parser.ParseException - if a parse error occured.
      • parseFloat

        public static Float parseFloat​(String value,
                                       Locator locator)
                                throws org.pentaho.reporting.libraries.xmlns.parser.ParseException
        Reads an attribute as float and returns def if that fails.
        Parameters:
        value - the attribute value.
        locator - the locator provides the current parse position for meaningful error messages.
        Returns:
        the float value.
        Throws:
        org.pentaho.reporting.libraries.xmlns.parser.ParseException - if an parse error occured.
      • parseBoolean

        public static Boolean parseBoolean​(String value,
                                           Locator locator)
                                    throws org.pentaho.reporting.libraries.xmlns.parser.ParseException
        Throws:
        org.pentaho.reporting.libraries.xmlns.parser.ParseException
      • parseInteger

        public static Integer parseInteger​(String value,
                                           Locator locator)
                                    throws org.pentaho.reporting.libraries.xmlns.parser.ParseException
        Reads an attribute as float and returns def if that fails.
        Parameters:
        value - the attribute value.
        locator - the locator provides the current parse position for meaningful error messages.
        Returns:
        the float value.
        Throws:
        org.pentaho.reporting.libraries.xmlns.parser.ParseException - if an parse error occured.
      • parseColor

        public static Color parseColor​(String color)
        Parses a color entry. If the entry is in hexadecimal or ocal notation, the color is created using Color.decode(). If the string denotes a constant name of on of the color constants defined in java.awt.Color, this constant is used.

        As fallback the color black is returned if no color can be parsed.

        Parameters:
        color - the color (as a string).
        Returns:
        the paint.
      • parseColor

        public static Color parseColor​(String color,
                                       Color defaultValue)
        Parses a color entry. If the entry is in hexadecimal or octal notation, the color is created using Color.decode(). If the string denotes a constant name of one of the color constants defined in java.awt.Color, this constant is used.

        As fallback the supplied default value is returned if no color can be parsed.

        Parameters:
        color - the color (as a string).
        defaultValue - the default value (returned if no color can be parsed).
        Returns:
        the paint.
      • parseRelativeFloat

        public static float parseRelativeFloat​(String value,
                                               String exceptionMessage,
                                               Locator locator)
                                        throws org.pentaho.reporting.libraries.xmlns.parser.ParseException
        Parses a position of an element. If a relative postion is given, the returnvalue is a negative number between 0 and -100.
        Parameters:
        value - the value.
        exceptionMessage - the exception message.
        locator - the locator provides the current parse position for meaningful error messages.
        Returns:
        the float value.
        Throws:
        org.pentaho.reporting.libraries.xmlns.parser.ParseException - if there is a problem parsing the string.
      • parseStroke

        public static Stroke parseStroke​(String strokeStyle,
                                         float weight)
      • parseVerticalTextElementAlignment

        public static VerticalTextAlign parseVerticalTextElementAlignment​(String value,
                                                                          Locator locator)
                                                                   throws org.pentaho.reporting.libraries.xmlns.parser.ParseException
        Throws:
        org.pentaho.reporting.libraries.xmlns.parser.ParseException
      • parseVersion

        public static int parseVersion​(String s)