SimpleServlets v5.5.0

com.simpleservlets.htmlobjects
Class HTMLString

java.lang.Object
  extended by com.simpleservlets.htmlobjects.GenericHTMLElement
      extended by com.simpleservlets.htmlobjects.HTMLString
All Implemented Interfaces:
DoNotMinimizeEmpty, HTMLElement, NoAttributesAllowed, NoChildrenAllowed, NoTag

public class HTMLString
extends GenericHTMLElement
implements HTMLElement, NoTag, NoChildrenAllowed

Represents a String as an HTMLElement.

Strings passed to the constructors are parsed by HTMLUtil.processMarkupEntities(String) so that any special markup characters (like <, >, etc.) are substituted with the entity references. In some rarer cases, you can avoid this substitution by creating an instance with the createUnparsed(String, HTMLElement) or createUnparsed(String) methods.

Does not have a start or end tag (NoTag) and does not support the addition of any children (NoChildrenAllowed).

Author:
Paul Hyde

Field Summary
static String NEWLINE
           
 
Fields inherited from interface com.simpleservlets.htmlobjects.HTMLElement
ZERO_LEN_ARRAY
 
Constructor Summary
HTMLString(String text)
          Does: this(text, null, false);.
HTMLString(String text, boolean safeToWrapWithWhitespace)
          Does: this(text, null, safeToWrapWithWhitespace);.
HTMLString(String text, HTMLElement parent)
          Does: this(text, parent, false);.
HTMLString(String text, HTMLElement parent, boolean safeToWrapWithWhitespace)
           
 
Method Summary
static HTMLString createUnparsed(String text)
          Creates an HTMLString for the specified text without substituting special markup characters with their entities.
static HTMLString createUnparsed(String text, HTMLElement parent)
          Creates an HTMLString for the specified text without substituting special markup characters with their entities.
 String getText()
          Returns the text—potentially parsed with entity substitution during construction.
 void setSafeToWrapWithWhitespace(boolean extraWhitespaceIsHarmless)
          Overrides protected method to make it public.
 
Methods inherited from class com.simpleservlets.htmlobjects.GenericHTMLElement
add, add, addSibling, addSibling, getAttributes, getChildren, getName, getParent, hasAttributes, hasChildren, isSafeToWrapWithWhitespace, removeAllAttributes, removeAllChildren, removeAttribute, removeChild, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributeGroup, setParent, setStyle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.simpleservlets.htmlobjects.HTMLElement
add, add, addSibling, addSibling, getAttributes, getChildren, getName, getParent, hasAttributes, hasChildren, isSafeToWrapWithWhitespace, removeAllAttributes, removeAllChildren, removeAttribute, removeChild, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributeGroup, setParent, setStyle
 

Field Detail

NEWLINE

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

HTMLString

public HTMLString(String text,
                  HTMLElement parent,
                  boolean safeToWrapWithWhitespace)

HTMLString

public HTMLString(String text,
                  HTMLElement parent)
Does: this(text, parent, false);.


HTMLString

public HTMLString(String text,
                  boolean safeToWrapWithWhitespace)
Does: this(text, null, safeToWrapWithWhitespace);.


HTMLString

public HTMLString(String text)
Does: this(text, null, false);.

Method Detail

createUnparsed

public static HTMLString createUnparsed(String text,
                                        HTMLElement parent)
Creates an HTMLString for the specified text without substituting special markup characters with their entities.


createUnparsed

public static HTMLString createUnparsed(String text)
Creates an HTMLString for the specified text without substituting special markup characters with their entities.


getText

public String getText()
Returns the text—potentially parsed with entity substitution during construction.


setSafeToWrapWithWhitespace

public void setSafeToWrapWithWhitespace(boolean extraWhitespaceIsHarmless)
Overrides protected method to make it public. If user knows that an particular string can be prefixed and suffixed with whitespace without harm, they can set this to true.

Overrides:
setSafeToWrapWithWhitespace in class GenericHTMLElement

SimpleServlets v5.5.0

Copyright © 2001-2007 Programix Incorporated. All rights reserved. SimpleServlets is free and is OSI Certified Open Source Software under the BSD license.