com.ibm.as400.util.html

Class HTMLText

  • All Implemented Interfaces:
    HTMLConstants, HTMLTagElement, java.io.Serializable


    public class HTMLText
    extends HTMLTagAttributes
    implements HTMLConstants, java.io.Serializable
    The HTMLText class encapsulates HTML text attributes.

    This example creates an HTMLText object and sets its attributes.

      HTMLText text = new HTMLText("IBM");
      text.setBold(true);
      text.setSize(3);
      System.out.println(text.getTag());
      
    Here is the output of the tag:
      <font size="3"><b>IBM</b></font>
      

    Here is the output of calling getFOTag():

      <fo:block font-size='9pt' font-weight='bold'>IBM</fo:block>
      

    HTMLText objects generate the following events:

    • PropertyChangeEvent
    • VetoableChangeEvent
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      HTMLText()
      Constructs a default HTMLText object.
      HTMLText(java.lang.String text)
      Constructs an HTMLText object with the specified text.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
      Adds the VetoableChangeListener.
      java.lang.String getAlignment()
      Returns the horizontal alignment.
      java.awt.Color getColor()
      Returns the color used to paint the text.
      java.lang.String getDirection()
      Returns the direction of the text interpretation.
      java.lang.String getFOTag()
      Returns the XSL-FO text tag.
      java.lang.String getFOTag(boolean useAlignment)
      Returns the XSL-FO text tag.
      java.lang.String getFOTag(java.lang.String text)
      Returns the XSL-FO text tag with the specified text.
      java.lang.String getFOTag(java.lang.String text, boolean useAlignment)
      Returns the XSL-FO text tag with the specified text.
      java.lang.String getLanguage()
      Returns the language of the text element.
      int getSize()
      Returns the font text size.
      java.lang.String getTag()
      Returns the text tag.
      java.lang.String getTag(boolean useAlignment)
      Returns the text tag.
      java.lang.String getTag(java.lang.String text)
      Returns the text tag with the specified text.
      java.lang.String getTag(java.lang.String text, boolean useAlignment)
      Returns the text tag with the specified text.
      java.lang.String getText()
      Returns the text.
      boolean isBold()
      Indicates if bold is on.
      boolean isFixed()
      Indicates if fixed pitch font is on.
      boolean isItalic()
      Indicates if italic is on.
      boolean isUnderscore()
      Indicates if underline is on.
      boolean isUseFO()
      Returns if Formatting Object tags are outputted.
      void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
      Removes the VetoableChangeListener from the internal list.
      void setAlignment(java.lang.String alignment)
      Sets the horizontal alignment.
      void setBold(boolean bold)
      Sets bold on or off.
      void setColor(java.awt.Color color)
      Sets the color used to paint the text.
      void setDirection(java.lang.String dir)
      Sets the direction of the text interpretation.
      void setFixed(boolean fixed)
      Sets fixed pitch font on or off.
      void setItalic(boolean italic)
      Sets italic on or off.
      void setLanguage(java.lang.String lang)
      Sets the language of the text tag.
      void setSize(int size)
      Sets the text font size.
      void setText(java.lang.String text)
      Sets the text.
      void setUnderscore(boolean underscore)
      Sets underline on or off.
      void setUseFO(boolean useFO)
      Sets if Formatting Object tags should be used.
      java.lang.String toString()
      Returns the HTML text tag.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • HTMLText

        public HTMLText()
        Constructs a default HTMLText object.
      • HTMLText

        public HTMLText(java.lang.String text)
        Constructs an HTMLText object with the specified text.
        Parameters:
        text - The text.
    >
    • Method Detail

      • addVetoableChangeListener

        public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
        Adds the VetoableChangeListener. The specified VetoableChangeListener's vetoableChange method is called each time the value of any constrained property is changed.
        Parameters:
        listener - The VetoableChangeListener.
        See Also:
        removeVetoableChangeListener(java.beans.VetoableChangeListener)
      • getAlignment

        public java.lang.String getAlignment()
        Returns the horizontal alignment.
        Returns:
        The horizontal alignment. One of the following constants defined in HTMLConstants: LEFT, CENTER, RIGHT, or JUSTIFY.
        See Also:
        HTMLConstants
      • getColor

        public java.awt.Color getColor()
        Returns the color used to paint the text.
        Returns:
        The Color object representing the text color.
      • getDirection

        public java.lang.String getDirection()
        Returns the direction of the text interpretation.
        Returns:
        The direction of the text.
      • getLanguage

        public java.lang.String getLanguage()
        Returns the language of the text element.
        Returns:
        The language of the input element.
      • getSize

        public int getSize()
        Returns the font text size. The default value is 0 (browser default).
        Returns:
        The font size.
      • getTag

        public java.lang.String getTag()
        Returns the text tag. The alignment tag is not included.
        Specified by:
        getTag in interface HTMLTagElement
        Returns:
        The tag.
      • getFOTag

        public java.lang.String getFOTag()
        Returns the XSL-FO text tag. The alignment tag is not included.
        Specified by:
        getFOTag in interface HTMLTagElement
        Returns:
        The tag.
      • getTag

        public java.lang.String getTag(boolean useAlignment)
        Returns the text tag.
        Parameters:
        useAlignment - true if the alignment tag should be included; false otherwise.
        Returns:
        The tag.
      • getFOTag

        public java.lang.String getFOTag(boolean useAlignment)
        Returns the XSL-FO text tag.
        Parameters:
        useAlignment - true if the alignment tag should be included; false otherwise.
        Returns:
        The tag.
      • getTag

        public java.lang.String getTag(java.lang.String text)
        Returns the text tag with the specified text. The alignment tag is not included.
        Parameters:
        text - The text.
        Returns:
        The tag.
      • getFOTag

        public java.lang.String getFOTag(java.lang.String text)
        Returns the XSL-FO text tag with the specified text. The alignment tag is not included.
        Parameters:
        text - The text.
        Returns:
        The tag.
      • getTag

        public java.lang.String getTag(java.lang.String text,
                              boolean useAlignment)
        Returns the text tag with the specified text.
        Parameters:
        text - The text.
        useAlignment - true if the alignment tag should be included; false otherwise.
        Returns:
        The tag.
      • getFOTag

        public java.lang.String getFOTag(java.lang.String text,
                                boolean useAlignment)
        Returns the XSL-FO text tag with the specified text. The fixed pitch and language attributes are not supported by XSL-FO.
        Parameters:
        text - The text.
        useAlignment - true if the alignment tag should be included; false otherwise.
        Returns:
        The tag.
      • getText

        public java.lang.String getText()
        Returns the text.
        Returns:
        The text.
      • isBold

        public boolean isBold()
        Indicates if bold is on.
        Returns:
        true if bold, false otherwise.
      • isFixed

        public boolean isFixed()
        Indicates if fixed pitch font is on.
        Returns:
        true if fixed, false otherwise.
      • isItalic

        public boolean isItalic()
        Indicates if italic is on.
        Returns:
        true if italic, false otherwise.
      • isUnderscore

        public boolean isUnderscore()
        Indicates if underline is on.
        Returns:
        true if underline, false otherwise.
      • isUseFO

        public boolean isUseFO()
        Returns if Formatting Object tags are outputted. The default value is false.
        Returns:
        true if the output generated is an XSL formatting object, false if the output generated is HTML.
      • removeVetoableChangeListener

        public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
        Removes the VetoableChangeListener from the internal list. If the VetoableChangeListener is not on the list, nothing is done.
        Parameters:
        listener - The VetoableChangeListener.
        See Also:
        addVetoableChangeListener(java.beans.VetoableChangeListener)
      • setAlignment

        public void setAlignment(java.lang.String alignment)
                          throws java.beans.PropertyVetoException
        Sets the horizontal alignment.
        Parameters:
        alignment - The horizontal alignment. One of the following constants defined in HTMLConstants: LEFT, CENTER, RIGHT, or JUSTIFY.
        Throws:
        java.beans.PropertyVetoException - If the change is vetoed.
        See Also:
        HTMLConstants
      • setBold

        public void setBold(boolean bold)
                     throws java.beans.PropertyVetoException
        Sets bold on or off. The default is false.
        Parameters:
        bold - true if on, false if off.
        Throws:
        java.beans.PropertyVetoException - If the change is vetoed.
      • setColor

        public void setColor(java.awt.Color color)
                      throws java.beans.PropertyVetoException
        Sets the color used to paint the text. The default text color is determined by the browser's color settings. How the color is rendered is browser dependent.
        Parameters:
        color - The Color object.
        Throws:
        java.beans.PropertyVetoException - If the change is vetoed.
      • setDirection

        public void setDirection(java.lang.String dir)
                          throws java.beans.PropertyVetoException
        Sets the direction of the text interpretation.
        Parameters:
        dir - The direction. One of the following constants defined in HTMLConstants: LTR or RTL.
        Throws:
        java.beans.PropertyVetoException - If a change is vetoed.
        See Also:
        HTMLConstants
      • setFixed

        public void setFixed(boolean fixed)
                      throws java.beans.PropertyVetoException
        Sets fixed pitch font on or off. The default is false.
        Parameters:
        fixed - true if on, false if off.
        Throws:
        java.beans.PropertyVetoException - If the change is vetoed.
      • setItalic

        public void setItalic(boolean italic)
                       throws java.beans.PropertyVetoException
        Sets italic on or off. The default is false.
        Parameters:
        italic - true if on, false if off.
        Throws:
        java.beans.PropertyVetoException - If the change is vetoed.
      • setLanguage

        public void setLanguage(java.lang.String lang)
                         throws java.beans.PropertyVetoException
        Sets the language of the text tag.
        Parameters:
        lang - The language. Example language tags include: en and en-US.
        Throws:
        java.beans.PropertyVetoException - If a change is vetoed.
      • setSize

        public void setSize(int size)
                     throws java.beans.PropertyVetoException
        Sets the text font size. Valid values are: 0 to 7. The default value is 0 (use browser default).
        Parameters:
        size - The font size.
        Throws:
        java.beans.PropertyVetoException - If the change is vetoed.
      • setText

        public void setText(java.lang.String text)
                     throws java.beans.PropertyVetoException
        Sets the text.
        Parameters:
        text - The text.
        Throws:
        java.beans.PropertyVetoException - If the change is vetoed.
      • setUnderscore

        public void setUnderscore(boolean underscore)
                           throws java.beans.PropertyVetoException
        Sets underline on or off. The default is false.
        Parameters:
        underscore - true if on, false if off.
        Throws:
        java.beans.PropertyVetoException - If the change is vetoed.
      • setUseFO

        public void setUseFO(boolean useFO)
        Sets if Formatting Object tags should be used. The default value is false.
        Parameters:
        useFO - - true if output generated is an XSL formatting object, false if the output generated is HTML.
      • toString

        public java.lang.String toString()
        Returns the HTML text tag.
        Overrides:
        toString in class java.lang.Object
        Returns:
        The tag.