HATS 7.5.1 Web API Reference

Publicly accessible methods not documented here are for IBM internal use only and may change in a future release of the product.

com.ibm.hats.transform.widgets
Class HTMLWidgetUtilities

java.lang.Object
  extended by com.ibm.hats.transform.widgets.HTMLWidgetUtilities

public class HTMLWidgetUtilities
extends Object

HTMLWidgetUtilities is a class which represents a collection of static convenience methods to be used in the development of Widgets which implement the HTMLRenderer interface.


Field Summary
static String BIDI_ALREADY_REORDERED
           
static String CLASS_NAME
           
protected static String COPYRIGHT
          The HsrCopyright.COPYRIGHT field will be updated each release, thereby "magically" updating this class file.
static String PROPERTY_ESCAPETAGS
           
 
Constructor Summary
HTMLWidgetUtilities()
          Constructor for HTMLWidgetUtilities.
 
Method Summary
static String activeItemTrim(String val)
           
static String activeItemTrim(String val, boolean padIfZero)
           
static String activeItemTrim(String val, boolean padIfZero, boolean leaveExtra)
           
static void bidiTransformWidgetDescription(InputComponentElement ice, Properties settings, ContextAttributes contextAttributes)
           
static void completeHtmlEscape(String s, StringBuffer buffer, boolean escapeSpaces)
          HTML escapes a string (optionally escaping spaces), builds escaped string in the specified string bufffer
static String convertBidi_oneline(String in, ContextAttributes contextAttributes, boolean disableReordering, String dirMarker, Properties settings, String screenOrientation, int codepage)
           
static String convertBidi_oneline(String in, ContextAttributes contextAttributes, boolean disableReordering, String dirMarker, Properties settings, String screenOrientation, int codepage, boolean nobr)
           
static String convertBidi(String in, ContextAttributes contextAttributes)
           
static String convertBidi(String in, ContextAttributes contextAttributes, boolean disableReordering, String dirMarker, Properties settings, String screenOrientation, int codepage)
           
static String convertBidi(String in, ContextAttributes contextAttributes, boolean disableReordering, String dirMarker, Properties settings, String screenOrientation, int codepage, boolean nobr)
           
static String convertBidi(String in, Hashtable contextAttributes)
          Deprecated.  
static String convertBidi(String in, Hashtable contextAttributes, boolean disableReordering, String dirMarker, Properties settings, String screenOrientation, int codepage)
          Deprecated.  
static void doSymSwap(StringBuffer s)
           
static void exactCursorDefaultProperties(Properties defaults)
          creates default settings for widgets using the exact cursor positioning option
static String fixImageLink(String in)
           
static String fixReversedHTMLSegment(String buf, boolean SymSwap, boolean fixBrackets)
           
static StringBuffer fixReversedHTMLSegment(StringBuffer buf, boolean SymSwap, boolean fixBrackets)
           
static String getDefaultElementStyle(String element)
          Gets the default CSS class for a particular type of element, e.g., HTMLElementFactory.LINK_CLASS gets HATSLINK.
static String[] getForegroundColorStyleClasses()
          Gets a static array of CSS classes indexed by foreground colors (0-15), e.g., 4 gets HRED.
static String getReversedColor(String htmlColor)
          Deprecated. Does not work.
static String getReversedVideoClass(String foregroundColor)
           
static String getStyleClassPropertyName(String type)
          Convenience method for creating a formatted property name denoting a CSS class mapping.
static String HandleRTLReplacement(String buf, boolean useBDO)
           
static StringBuffer HandleRTLReplacement(StringBuffer buf, boolean useBDO)
           
static void hideElement(HTMLElement e)
          Hide a given HTML element
static String htmlEscape(boolean escapeHTMLtags, String s)
          HTML escapes a string (optionally escaping spaces), builds escaped string in the specified string buffer
static String htmlEscape(boolean escapeHTMLtags, String s, boolean escapeSpaces)
          HTML escapes a string (optionally escaping spaces), builds escaped string in the specified string buffer
static void htmlEscape(boolean escapeHTMLtags, String s, StringBuffer buffer)
          HTML escapes a string (optionally escaping spaces), builds escaped string in the specified string buffer
static void htmlEscape(boolean escapeHTMLtags, String s, StringBuffer buffer, boolean escapeSpaces)
          HTML escapes a string (optionally escaping spaces), builds escaped string in the specified string buffer
static String htmlEscape(String s)
          HTML escapes a string.
static String htmlEscape(String s, boolean escapeSpaces)
          HTML escapes a string, optionally escapes spaces
static void htmlEscape(String s, StringBuffer buffer)
          HTML escapes a string, builds escaped string in the specified string bufffer
static void htmlEscape(String s, StringBuffer buffer, boolean escapeSpaces)
          HTML escapes a string (optionally escaping spaces), builds escaped string in the specified string buffer.
static void main(String[] args)
           
static void makeAccessible(HTMLElement target, String description, HTMLElementFactory factory, ContextAttributes contextAttributes, StringBuffer buffer)
          Sticks an html id attribute on the targeted element, then creates an AccessibilityLabelElement pointing to it with the specified description, then renders it to the specified buffer.
static void makeAccessible(HTMLElement target, String description, HTMLElementFactory factory, Hashtable contextAttributes, StringBuffer buffer)
          Deprecated.  
static Map processCSSOverrides(Properties settings)
          Constructs a HashMap of CSS class keys to CSS classes from the Widget settings.
static void renderAccessibleAndExactCursor(HTMLElement target, HTMLElementFactory factory, ContextAttributes contextAttributes, StringBuffer buffer, boolean renderAccessible, boolean renderExactCursor, Properties defaults, Properties settings, String description)
          Adds an html id attribute on the targeted element.
static void renderAsAccessible(HTMLElement target, String description, HTMLElementFactory factory, ContextAttributes contextAttributes, StringBuffer buffer)
          Sticks an html id attribute on the targeted element, then creates an AccessibilityLabelElement pointing to it with the specified description, then renders both elements to the specified buffer.
static void renderCaption(String caption, HTMLElementFactory htmlFactory, StringBuffer buffer)
          Renders a caption for an html form control, given an HTMLElementFactory and a buffer to use for output.
static void renderCaption(String caption, HTMLElementFactory htmlFactory, StringBuffer buffer, String additionalCaptionClass)
          Renders a caption for an html form control, given an HTMLElementFactory and a buffer to use for output.
static StringBuffer replaceToken(StringBuffer str, String token, String sub)
           
static String replaceToken(String str, String token, String sub)
           
static String reverseImageLink(String in)
           
static String reverseImageLink(String in, boolean isRTLScreen, boolean isRTLWizard)
           
static StringBuffer reverseImageLink(StringBuffer str, boolean isRTLScreen, boolean isRTLWizard)
           
static String reverseImageLinkBack(String in)
           
static StringBuffer reverseWidget(String buf, boolean SymSwap)
           
static StringBuffer reverseWidget(StringBuffer result, boolean SymSwap)
           
static String saveStringBufferToFile(StringBuffer sb, String filename, com.ibm.hats.transform.IPathInfo pathInfo)
           
static String saveToFile(StringBuffer content, String filename, ContextAttributes contextAttributes)
           
static String trimAllSpace(String val)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT

protected static final String COPYRIGHT
The HsrCopyright.COPYRIGHT field will be updated each release, thereby "magically" updating this class file.

See Also:
Constant Field Values

CLASS_NAME

public static final String CLASS_NAME
See Also:
Constant Field Values

PROPERTY_ESCAPETAGS

public static final String PROPERTY_ESCAPETAGS
See Also:
Constant Field Values

BIDI_ALREADY_REORDERED

public static final String BIDI_ALREADY_REORDERED
See Also:
Constant Field Values
Constructor Detail

HTMLWidgetUtilities

public HTMLWidgetUtilities()
Constructor for HTMLWidgetUtilities. This class shouldn't be instantiated, every method and variable should be static.

Method Detail

processCSSOverrides

public static Map processCSSOverrides(Properties settings)
Constructs a HashMap of CSS class keys to CSS classes from the Widget settings. CSS class keys all share the "StyleClass" suffix in the Widget settings Properties. Each one of these keys has its suffix stripped, then the key and its value are stored in the Map. This is useful for automatically building a CSS class mapping without having to manually pull every CSS related property out of the Widget settings. This is probably inefficient since it looks through the entire set of properties for ones that match the pattern.

Returns:
CSS class Map
See Also:
HTMLElementFactory

htmlEscape

public static String htmlEscape(String s)
HTML escapes a string.

Parameters:
s - String to escape
Returns:
modified String

htmlEscape

public static String htmlEscape(String s,
                                boolean escapeSpaces)
HTML escapes a string, optionally escapes spaces

Parameters:
s - String to escape
escapeSpaces - true to escape spaces, false to not
Returns:
modified String

htmlEscape

public static void htmlEscape(String s,
                              StringBuffer buffer)
HTML escapes a string, builds escaped string in the specified string bufffer

Parameters:
s - string to escape
buffer - buffer to put escaped content in

htmlEscape

public static void htmlEscape(boolean escapeHTMLtags,
                              String s,
                              StringBuffer buffer)
HTML escapes a string (optionally escaping spaces), builds escaped string in the specified string buffer

Parameters:
escapeHTMLtags - false to permit HTML tags in text, true to not
s - string to escape
buffer - buffer to put escaped content in

htmlEscape

public static void htmlEscape(boolean escapeHTMLtags,
                              String s,
                              StringBuffer buffer,
                              boolean escapeSpaces)
HTML escapes a string (optionally escaping spaces), builds escaped string in the specified string buffer

Parameters:
escapeHTMLtags - false to permit HTML tags in text, true to not
s - string to escape
buffer - buffer to put escaped content in
escapeSpaces - true to escape spaces, false to not

htmlEscape

public static String htmlEscape(boolean escapeHTMLtags,
                                String s,
                                boolean escapeSpaces)
HTML escapes a string (optionally escaping spaces), builds escaped string in the specified string buffer

Parameters:
escapeHTMLtags - false to permit HTML tags in text, true to not
s - string to escape
escapeSpaces - true to escape spaces, false to not
Returns:
modified String

htmlEscape

public static String htmlEscape(boolean escapeHTMLtags,
                                String s)
HTML escapes a string (optionally escaping spaces), builds escaped string in the specified string buffer

Parameters:
escapeHTMLtags - false to permit HTML tags in text, true to not
s - string to escape
Returns:
modified String

htmlEscape

public static void htmlEscape(String s,
                              StringBuffer buffer,
                              boolean escapeSpaces)
HTML escapes a string (optionally escaping spaces), builds escaped string in the specified string buffer. Will avoid escaping any actual HTML tags in the content

Parameters:
s - string to escape
buffer - buffer to put escaped content in
escapeSpaces - true to escape spaces, false to not

completeHtmlEscape

public static void completeHtmlEscape(String s,
                                      StringBuffer buffer,
                                      boolean escapeSpaces)
HTML escapes a string (optionally escaping spaces), builds escaped string in the specified string bufffer

Parameters:
s - string to escape
buffer - buffer to put escaped content in
escapeSpaces - true to escape spaces, false to not

getReversedVideoClass

public static String getReversedVideoClass(String foregroundColor)

getReversedColor

public static String getReversedColor(String htmlColor)
Deprecated. Does not work.


renderCaption

public static void renderCaption(String caption,
                                 HTMLElementFactory htmlFactory,
                                 StringBuffer buffer)
Renders a caption for an html form control, given an HTMLElementFactory and a buffer to use for output. Will use class and style mappings from the factory, and determine if wrapping the caption in a SPAN is necessary.

Parameters:
caption - caption to render
htmlFactory - factory to use in rendering
buffer - output buffer

renderCaption

public static void renderCaption(String caption,
                                 HTMLElementFactory htmlFactory,
                                 StringBuffer buffer,
                                 String additionalCaptionClass)
Renders a caption for an html form control, given an HTMLElementFactory and a buffer to use for output. Will use class and style mappings from the factory, and determine if wrapping the caption in a SPAN is necessary.

Parameters:
caption - Caption to render.
htmlFactory - Factory to use in rendering.
buffer - The output buffer.
additionalCaptionClass - The caption class.

exactCursorDefaultProperties

public static void exactCursorDefaultProperties(Properties defaults)
creates default settings for widgets using the exact cursor positioning option

Parameters:
defaults - the default properties object of the widget

renderAccessibleAndExactCursor

public static void renderAccessibleAndExactCursor(HTMLElement target,
                                                  HTMLElementFactory factory,
                                                  ContextAttributes contextAttributes,
                                                  StringBuffer buffer,
                                                  boolean renderAccessible,
                                                  boolean renderExactCursor,
                                                  Properties defaults,
                                                  Properties settings,
                                                  String description)
Adds an html id attribute on the targeted element. Optionally then creates an AccessibilityLabelElement pointing to it with the specified description, then renders both elements to the specified buffer. Optionally also adds exact cursor positioning elements, using the settings and default settings provided. Finally, it renders all elements to the specified buffer.

Parameters:
target - targeted HTML element
factory - HTMLElementFactory to use to construct the label
contextAttributes - use these to analyze state
buffer - buffer to output to for display
renderAccessible - whether or not to render the area with an accessibility label
renderExactCursor - whether or not to render the input field with the exact cursor positioning option
defaults - settings from the calling widget
settings - from the calling widget
description - label content

renderAsAccessible

public static void renderAsAccessible(HTMLElement target,
                                      String description,
                                      HTMLElementFactory factory,
                                      ContextAttributes contextAttributes,
                                      StringBuffer buffer)
Sticks an html id attribute on the targeted element, then creates an AccessibilityLabelElement pointing to it with the specified description, then renders both elements to the specified buffer.

Parameters:
target - targeted HTML element
description - label content
factory - HTMLElementFacory to use to construct the label
contextAttributes - use these to analyze state
buffer - buffer to output to

makeAccessible

public static void makeAccessible(HTMLElement target,
                                  String description,
                                  HTMLElementFactory factory,
                                  Hashtable contextAttributes,
                                  StringBuffer buffer)
Deprecated. 

Sticks an html id attribute on the targeted element, then creates an AccessibilityLabelElement pointing to it with the specified description, then renders it to the specified buffer.

Parameters:
target - targeted HTML element
description - label content
factory - HTMLElementFacory to use to construct the label
contextAttributes - use these to analyze state
buffer - buffer to output to

makeAccessible

public static void makeAccessible(HTMLElement target,
                                  String description,
                                  HTMLElementFactory factory,
                                  ContextAttributes contextAttributes,
                                  StringBuffer buffer)
Sticks an html id attribute on the targeted element, then creates an AccessibilityLabelElement pointing to it with the specified description, then renders it to the specified buffer.

Parameters:
target - targeted HTML element
description - label content
factory - HTMLElementFacory to use to construct the label
contextAttributes - use these to analyze state
buffer - buffer to output to

getStyleClassPropertyName

public static String getStyleClassPropertyName(String type)
Convenience method for creating a formatted property name denoting a CSS class mapping.

Parameters:
type - type of element, such as HTMLElementFactory.TABLE_CLASS
Returns:
formatted String
See Also:
HTMLElementFactory

doSymSwap

public static void doSymSwap(StringBuffer s)

getDefaultElementStyle

public static final String getDefaultElementStyle(String element)
Gets the default CSS class for a particular type of element, e.g., HTMLElementFactory.LINK_CLASS gets HATSLINK.

Parameters:
element - CSS class mapping key
Returns:
default CSS class

getForegroundColorStyleClasses

public static String[] getForegroundColorStyleClasses()
Gets a static array of CSS classes indexed by foreground colors (0-15), e.g., 4 gets HRED.

Returns:
array of CSS classes

convertBidi

public static String convertBidi(String in,
                                 Hashtable contextAttributes)
Deprecated. 


convertBidi

public static String convertBidi(String in,
                                 ContextAttributes contextAttributes)

convertBidi

public static String convertBidi(String in,
                                 Hashtable contextAttributes,
                                 boolean disableReordering,
                                 String dirMarker,
                                 Properties settings,
                                 String screenOrientation,
                                 int codepage)
Deprecated. 


convertBidi

public static String convertBidi(String in,
                                 ContextAttributes contextAttributes,
                                 boolean disableReordering,
                                 String dirMarker,
                                 Properties settings,
                                 String screenOrientation,
                                 int codepage)

convertBidi

public static String convertBidi(String in,
                                 ContextAttributes contextAttributes,
                                 boolean disableReordering,
                                 String dirMarker,
                                 Properties settings,
                                 String screenOrientation,
                                 int codepage,
                                 boolean nobr)

convertBidi_oneline

public static String convertBidi_oneline(String in,
                                         ContextAttributes contextAttributes,
                                         boolean disableReordering,
                                         String dirMarker,
                                         Properties settings,
                                         String screenOrientation,
                                         int codepage)

convertBidi_oneline

public static String convertBidi_oneline(String in,
                                         ContextAttributes contextAttributes,
                                         boolean disableReordering,
                                         String dirMarker,
                                         Properties settings,
                                         String screenOrientation,
                                         int codepage,
                                         boolean nobr)

bidiTransformWidgetDescription

public static void bidiTransformWidgetDescription(InputComponentElement ice,
                                                  Properties settings,
                                                  ContextAttributes contextAttributes)

fixReversedHTMLSegment

public static StringBuffer fixReversedHTMLSegment(StringBuffer buf,
                                                  boolean SymSwap,
                                                  boolean fixBrackets)

fixReversedHTMLSegment

public static String fixReversedHTMLSegment(String buf,
                                            boolean SymSwap,
                                            boolean fixBrackets)

HandleRTLReplacement

public static StringBuffer HandleRTLReplacement(StringBuffer buf,
                                                boolean useBDO)

HandleRTLReplacement

public static String HandleRTLReplacement(String buf,
                                          boolean useBDO)

replaceToken

public static StringBuffer replaceToken(StringBuffer str,
                                        String token,
                                        String sub)

replaceToken

public static String replaceToken(String str,
                                  String token,
                                  String sub)

trimAllSpace

public static String trimAllSpace(String val)

activeItemTrim

public static String activeItemTrim(String val)

activeItemTrim

public static String activeItemTrim(String val,
                                    boolean padIfZero)

activeItemTrim

public static String activeItemTrim(String val,
                                    boolean padIfZero,
                                    boolean leaveExtra)

reverseWidget

public static StringBuffer reverseWidget(String buf,
                                         boolean SymSwap)

reverseWidget

public static StringBuffer reverseWidget(StringBuffer result,
                                         boolean SymSwap)

fixImageLink

public static String fixImageLink(String in)

reverseImageLink

public static String reverseImageLink(String in,
                                      boolean isRTLScreen,
                                      boolean isRTLWizard)

reverseImageLink

public static StringBuffer reverseImageLink(StringBuffer str,
                                            boolean isRTLScreen,
                                            boolean isRTLWizard)

reverseImageLink

public static String reverseImageLink(String in)

reverseImageLinkBack

public static String reverseImageLinkBack(String in)

saveToFile

public static String saveToFile(StringBuffer content,
                                String filename,
                                ContextAttributes contextAttributes)

saveStringBufferToFile

public static String saveStringBufferToFile(StringBuffer sb,
                                            String filename,
                                            com.ibm.hats.transform.IPathInfo pathInfo)

main

public static void main(String[] args)

hideElement

public static void hideElement(HTMLElement e)
Hide a given HTML element

Parameters:
e - HTMLElement to be hidden.

HATS 7.5.1 (201005110649)