PAJES 2.3.9

org.pajes.html
Class Text

java.lang.Object
  extended byorg.pajes.html.PlainText
      extended byorg.pajes.html.Text
All Implemented Interfaces:
java.lang.Cloneable, HTML, java.io.Serializable, TextContainer

public class Text
extends PlainText

This class emits the text that is to be displayed in the browser. Text converts the text into a WritePermission object, but does NOT apply any formatting. It does, however, replace special HTML characters with HTML Named Character Entities.

Use FormattedText or Span to format a block of text.

See Also:
FormattedText, Span, PlainText, Serialized Form

Constructor Summary
protected Text()
          Default constructor.
protected Text(boolean encode)
          Creates an emtpty text string.
  Text(java.lang.String text)
          Creates a line of unformatted text.
  Text(java.lang.String text, boolean suppressNewLine)
          Creates a line of unformatted text.
 
Method Summary
 PlainText add(java.lang.String text)
          Adds more text to the existing text.
static java.lang.String decodeCharacterEntities(java.lang.String toDecode)
          Converts any HTML named character entities (", &, < and >) found in the specified String are to be converted to the actual character.
static java.lang.String encodeCharacterEntities(java.lang.String toEncode)
          Converts any ", &, < or > characters found in the specified String to the equivalent HTML named character entity (&quot;, &amp;, &lt; or &gt;).
static java.lang.String encodeDBCSText(java.lang.String toEncode, java.lang.String enc)
          Converts a String of DBCS text to a correctly encoded Unicode String of valid HTML, where characters with a values greater than 127 are encoded using &#...; notation.
 java.lang.String getDocument()
          Gets the the unique name of the document containing this tag.
 java.lang.String getId()
          Gets the unique ID of the current tag.
 WritePermission getWritePermission()
          Returns the object which will be used to determine whether this piece of HTML will be returned to the requesting browser.
 HTML setId(java.lang.String id)
          Sets the ID of the current tag.
 PlainText setText(java.lang.String text)
          Replaces the current text, rather than appending.
 HTML setWritePermission(WritePermission control, java.lang.String document, java.lang.String id)
          Sets the object which will be used to determine whether this piece of HTML will be returned to the requesting browser.
 
Methods inherited from class org.pajes.html.PlainText
addContent, clone, destroy, getContainedText, getContainer, getText, isNewLineSuppressed, isWritable, setContainer, setContent, setWritable, toString, write
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Text

public Text(java.lang.String text)
Creates a line of unformatted text.

Parameters:
text - the line of text.

Text

public Text(java.lang.String text,
            boolean suppressNewLine)
Creates a line of unformatted text.

Parameters:
text - the line of text.
suppressNewLine - suppresses a new line after the text.

Text

protected Text()
Default constructor.


Text

protected Text(boolean encode)
Creates an emtpty text string.

Parameters:
encode - true if any special HTML characters in the text are to be converted to their equivalent HTML named character entity, or false if no changes are to be made to the text.
Method Detail

add

public PlainText add(java.lang.String text)
Adds more text to the existing text. No new lines are automatically inserted.

Overrides:
add in class PlainText
Parameters:
text - the line of text.
Returns:
the modified Text instance

decodeCharacterEntities

public static java.lang.String decodeCharacterEntities(java.lang.String toDecode)
Converts any HTML named character entities (&quot;, &amp;, &lt; and &gt;) found in the specified String are to be converted to the actual character.

Parameters:
toDecode - the string that may contain named entities to be converted to characters.
Returns:
the String with the named entities replaced with characters.

encodeCharacterEntities

public static java.lang.String encodeCharacterEntities(java.lang.String toEncode)
Converts any ", &, < or > characters found in the specified String to the equivalent HTML named character entity (&quot;, &amp;, &lt; or &gt;).

Parameters:
toEncode - the string that may contain characters to be converted to named entities.
Returns:
the String with the characters replaced with named entities.

encodeDBCSText

public static java.lang.String encodeDBCSText(java.lang.String toEncode,
                                              java.lang.String enc)
                                       throws java.io.UnsupportedEncodingException
Converts a String of DBCS text to a correctly encoded Unicode String of valid HTML, where characters with a values greater than 127 are encoded using &#...; notation.

Parameters:
toEncode - the string of DBCS text.
enc - The name of a supported character encoding.
Returns:
the String of valid HTML.
Throws:
java.io.UnsupportedEncodingException - if the named encoding is not supported.

getDocument

public java.lang.String getDocument()
Gets the the unique name of the document containing this tag.

Specified by:
getDocument in interface HTML
Overrides:
getDocument in class PlainText
Returns:
the name of the document.
See Also:
setWritePermission(org.pajes.security.WritePermission, java.lang.String, java.lang.String)

setId

public HTML setId(java.lang.String id)
Sets the ID of the current tag. An ID uniquely indentifies an element within a document.

Parameters:
id - the unique ID of the tag
Returns:
the modified Tag object
See Also:
setWritePermission(org.pajes.security.WritePermission, java.lang.String, java.lang.String)

getId

public java.lang.String getId()
Gets the unique ID of the current tag.

Specified by:
getId in interface HTML
Overrides:
getId in class PlainText
Returns:
the unique ID of the current tag.

setText

public PlainText setText(java.lang.String text)
Replaces the current text, rather than appending.

Overrides:
setText in class PlainText
Parameters:
text - the line of text.
Returns:
the modified Text instance

setWritePermission

public HTML setWritePermission(WritePermission control,
                               java.lang.String document,
                               java.lang.String id)
Sets the object which will be used to determine whether this piece of HTML will be returned to the requesting browser.

Specified by:
setWritePermission in interface HTML
Overrides:
setWritePermission in class PlainText
Parameters:
control - the instance of the WritePermission interface which can be used in the write() method to determine if this object should be returned to the browser.
document - the unique name of the page containing this tag.
id - the unique ID of the tag.
Returns:
the modified Tag object

getWritePermission

public WritePermission getWritePermission()
Returns the object which will be used to determine whether this piece of HTML will be returned to the requesting browser.

Specified by:
getWritePermission in interface HTML
Overrides:
getWritePermission in class PlainText
Returns:
the implementation of the WritePermission interface which can be used in the write() method to determine if this object should be returned to the browser.

PAJES 2.3.9

Copyright © 2002-2003 Viridian Pty Limited. All Rights Reserved.