com.ibm.as400.util.html
Class HTMLText

java.lang.Object
  extended by com.ibm.as400.util.html.HTMLTagAttributes
      extended by com.ibm.as400.util.html.HTMLText
All Implemented Interfaces:
HTMLConstants, HTMLTagElement, Serializable

public class HTMLText
extends HTMLTagAttributes
implements HTMLConstants, 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:

See Also:
Serialized Form

Field Summary
Modifier and Type Field and Description
 
Fields inherited from interface com.ibm.as400.util.html.HTMLConstants
ABSBOTTOM, ABSMIDDLE, BASELINE, BOTTOM, CAPITALS, CENTER, CIRCLE, DISC, JUSTIFY, LARGE_ROMAN, LEFT, LOWER_CASE, LTR, MIDDLE, NUMBERS, RIGHT, RTL, SMALL_ROMAN, SQUARE, TARGET_BLANK, TARGET_PARENT, TARGET_SELF, TARGET_TOP, TEXTTOP, TOP
 
Constructor Summary
Constructor and Description
HTMLText()
          Constructs a default HTMLText object.
HTMLText(String text)
          Constructs an HTMLText object with the specified text.
 
Method Summary
Modifier and Type Method and Description
 void addVetoableChangeListener(VetoableChangeListener listener)
          Adds the VetoableChangeListener.
 String getAlignment()
          Returns the horizontal alignment.
 Color getColor()
          Returns the color used to paint the text.
 String getDirection()
          Returns the direction of the text interpretation.
 String getFOTag()
          Returns the XSL-FO text tag.
 String getFOTag(boolean useAlignment)
          Returns the XSL-FO text tag.
 String getFOTag(String text)
          Returns the XSL-FO text tag with the specified text.
 String getFOTag(String text, boolean useAlignment)
          Returns the XSL-FO text tag with the specified text.
 String getLanguage()
          Returns the language of the text element.
 int getSize()
          Returns the font text size.
 String getTag()
          Returns the text tag.
 String getTag(boolean useAlignment)
          Returns the text tag.
 String getTag(String text)
          Returns the text tag with the specified text.
 String getTag(String text, boolean useAlignment)
          Returns the text tag with the specified text.
 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(VetoableChangeListener listener)
          Removes the VetoableChangeListener from the internal list.
 void setAlignment(String alignment)
          Sets the horizontal alignment.
 void setBold(boolean bold)
          Sets bold on or off.
 void setColor(Color color)
          Sets the color used to paint the text.
 void setDirection(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(String lang)
          Sets the language of the text tag.
 void setSize(int size)
          Sets the text font size.
 void setText(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.
 String toString()
          Returns the HTML text tag.
 
Methods inherited from class com.ibm.as400.util.html.HTMLTagAttributes
addPropertyChangeListener, getAttributes, getAttributeString, removePropertyChangeListener, setAttributes
 
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(String text)
Constructs an HTMLText object with the specified text.

Parameters:
text - The text.
Method Detail

addVetoableChangeListener

public void addVetoableChangeListener(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 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 Color getColor()
Returns the color used to paint the text.

Returns:
The Color object representing the text color.

getDirection

public String getDirection()
Returns the direction of the text interpretation.

Returns:
The direction of the text.

getLanguage

public 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 String getTag()
Returns the text tag. The alignment tag is not included.

Specified by:
getTag in interface HTMLTagElement
Returns:
The tag.

getFOTag

public 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 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 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 String getTag(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 String getFOTag(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 String getTag(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 String getFOTag(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 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(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(String alignment)
                  throws PropertyVetoException
Sets the horizontal alignment.

Parameters:
alignment - The horizontal alignment. One of the following constants defined in HTMLConstants: LEFT, CENTER, RIGHT, or JUSTIFY.
Throws:
PropertyVetoException - If the change is vetoed.
See Also:
HTMLConstants

setBold

public void setBold(boolean bold)
             throws PropertyVetoException
Sets bold on or off. The default is false.

Parameters:
bold - true if on, false if off.
Throws:
PropertyVetoException - If the change is vetoed.

setColor

public void setColor(Color color)
              throws 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:
PropertyVetoException - If the change is vetoed.

setDirection

public void setDirection(String dir)
                  throws PropertyVetoException
Sets the direction of the text interpretation.

Parameters:
dir - The direction. One of the following constants defined in HTMLConstants: LTR or RTL.
Throws:
PropertyVetoException - If a change is vetoed.
See Also:
HTMLConstants

setFixed

public void setFixed(boolean fixed)
              throws PropertyVetoException
Sets fixed pitch font on or off. The default is false.

Parameters:
fixed - true if on, false if off.
Throws:
PropertyVetoException - If the change is vetoed.

setItalic

public void setItalic(boolean italic)
               throws PropertyVetoException
Sets italic on or off. The default is false.

Parameters:
italic - true if on, false if off.
Throws:
PropertyVetoException - If the change is vetoed.

setLanguage

public void setLanguage(String lang)
                 throws PropertyVetoException
Sets the language of the text tag.

Parameters:
lang - The language. Example language tags include: en and en-US.
Throws:
PropertyVetoException - If a change is vetoed.

setSize

public void setSize(int size)
             throws 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:
PropertyVetoException - If the change is vetoed.

setText

public void setText(String text)
             throws PropertyVetoException
Sets the text.

Parameters:
text - The text.
Throws:
PropertyVetoException - If the change is vetoed.

setUnderscore

public void setUnderscore(boolean underscore)
                   throws PropertyVetoException
Sets underline on or off. The default is false.

Parameters:
underscore - true if on, false if off.
Throws:
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 String toString()
Returns the HTML text tag.

Overrides:
toString in class Object
Returns:
The tag.