org.displaytag.util
Class HtmlTagUtil

java.lang.Object
  extended by org.displaytag.util.HtmlTagUtil

public final class HtmlTagUtil
extends java.lang.Object

Utility methods for dealing with html tags.

Version:
$Revision: 1081 $ ($Author: fgiust $)
Author:
Fabrizio Giustina

Method Summary
static java.lang.String abbreviateHtmlString(java.lang.String str, int maxLength, boolean byNumberOfWords)
          Abbreviates a String which can contain html tags.
static java.lang.String createOpenTagString(java.lang.String tagName, HtmlAttributeMap attributes)
          costruct a tag from a name and a collection of attributes.
static java.lang.String stripHTMLTags(java.lang.String str)
          Strips html tags from a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createOpenTagString

public static java.lang.String createOpenTagString(java.lang.String tagName,
                                                   HtmlAttributeMap attributes)
costruct a tag from a name and a collection of attributes.

Parameters:
tagName - String tag name
attributes - HtmlAttributeMap containing all the tag attributes
Returns:
String open tag with attributes

stripHTMLTags

public static java.lang.String stripHTMLTags(java.lang.String str)
Strips html tags from a String.

Parameters:
str - input string containing html tags (null is not handled)
Returns:
input message without tags

abbreviateHtmlString

public static java.lang.String abbreviateHtmlString(java.lang.String str,
                                                    int maxLength,
                                                    boolean byNumberOfWords)
Abbreviates a String which can contain html tags. Html tags are not counted in String length. It also try to handle open tags and html entities.

Parameters:
str - full String. null is handled by returning null
maxLength - maximum number of characters (excluding tags)
byNumberOfWords - if true maxLength will be the number of words returned, elsewhere will represent the number of characters.
Returns:
abbreviated String


Copyright © 2002-2007 the Displaytag team. All Rights Reserved.