Class JRStyledTextParser

  • All Implemented Interfaces:
    org.xml.sax.ErrorHandler

    public class JRStyledTextParser
    extends java.lang.Object
    implements org.xml.sax.ErrorHandler
    Author:
    Teodor Danciu (teodord@users.sourceforge.net)
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void error​(org.xml.sax.SAXParseException e)  
      void fatalError​(org.xml.sax.SAXParseException e)  
      static JRStyledTextParser getInstance()
      Return a cached instance.
      static java.util.Locale getLocale()  
      JRStyledText getStyledText​(java.util.Map<java.text.AttributedCharacterIterator.Attribute,​java.lang.Object> parentAttributes, java.lang.String text, boolean isStyledText, java.util.Locale locale)
      Creates a styled text object by either parsing a styled text String or by wrapping an unstyled String.
      JRStyledText parse​(java.util.Map<java.text.AttributedCharacterIterator.Attribute,​java.lang.Object> attributes, java.lang.String text, java.util.Locale locale)  
      static void setLocale​(java.util.Locale locale)  
      void warning​(org.xml.sax.SAXParseException e)  
      java.lang.String write​(java.util.Map<java.text.AttributedCharacterIterator.Attribute,​java.lang.Object> parentAttrs, java.text.AttributedCharacterIterator iterator, java.lang.String text)
      Outputs a styled text String given a set of element-level styled text attributes and a styled text in the form of a String text and an iterator of style attributes.
      java.lang.String write​(JRStyledText styledText)
      Outputs a styled text String given a styled text instance.
      java.lang.String write​(JRStyledText styledText, int startIndex, int endIndex)
      Outputs the String representation of a styled text chunk.
      void writeChunk​(StyledTextWriteContext context, java.lang.StringBuilder sb, java.util.Map<java.text.AttributedCharacterIterator.Attribute,​java.lang.Object> parentAttrs, java.util.Map<java.text.AttributedCharacterIterator.Attribute,​java.lang.Object> attrs, java.lang.String chunk)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getInstance

        public static JRStyledTextParser getInstance()
        Return a cached instance.
        Returns:
        a cached instance
      • setLocale

        public static void setLocale​(java.util.Locale locale)
      • getLocale

        public static java.util.Locale getLocale()
      • parse

        public JRStyledText parse​(java.util.Map<java.text.AttributedCharacterIterator.Attribute,​java.lang.Object> attributes,
                                  java.lang.String text,
                                  java.util.Locale locale)
                           throws org.xml.sax.SAXException
        Throws:
        org.xml.sax.SAXException
      • getStyledText

        public JRStyledText getStyledText​(java.util.Map<java.text.AttributedCharacterIterator.Attribute,​java.lang.Object> parentAttributes,
                                          java.lang.String text,
                                          boolean isStyledText,
                                          java.util.Locale locale)
        Creates a styled text object by either parsing a styled text String or by wrapping an unstyled String.
        Parameters:
        parentAttributes - the element-level styled text attributes
        text - the (either styled or unstyled) text
        isStyledText - flag indicating that the text is styled
        locale - the locale for the text
        Returns:
        a styled text object
      • write

        public java.lang.String write​(JRStyledText styledText)
        Outputs a styled text String given a styled text instance.
        Parameters:
        styledText - the styled text object
        Returns:
        the String styled text representation
      • write

        public java.lang.String write​(java.util.Map<java.text.AttributedCharacterIterator.Attribute,​java.lang.Object> parentAttrs,
                                      java.text.AttributedCharacterIterator iterator,
                                      java.lang.String text)
        Outputs a styled text String given a set of element-level styled text attributes and a styled text in the form of a String text and an iterator of style attributes.
        Parameters:
        parentAttrs - the element-level styled text attributes
        iterator - iterator of styled text attributes
        text - the text
        Returns:
        the String styled text representation
      • write

        public java.lang.String write​(JRStyledText styledText,
                                      int startIndex,
                                      int endIndex)
        Outputs the String representation of a styled text chunk.
        Parameters:
        styledText - the styled text
        startIndex - the start index
        endIndex - the end index
        Returns:
        the String styled text representation of the chunk delimited by the start index and the end index
        See Also:
        write(Map, AttributedCharacterIterator, String)
      • writeChunk

        public void writeChunk​(StyledTextWriteContext context,
                               java.lang.StringBuilder sb,
                               java.util.Map<java.text.AttributedCharacterIterator.Attribute,​java.lang.Object> parentAttrs,
                               java.util.Map<java.text.AttributedCharacterIterator.Attribute,​java.lang.Object> attrs,
                               java.lang.String chunk)
      • error

        public void error​(org.xml.sax.SAXParseException e)
        Specified by:
        error in interface org.xml.sax.ErrorHandler
      • fatalError

        public void fatalError​(org.xml.sax.SAXParseException e)
        Specified by:
        fatalError in interface org.xml.sax.ErrorHandler
      • warning

        public void warning​(org.xml.sax.SAXParseException e)
        Specified by:
        warning in interface org.xml.sax.ErrorHandler