com.swfit.core.xhtml
Class XHTMLCharEncoder

java.lang.Object
  |
  +--com.swfit.core.xhtml.XHTMLCharEncoder

public final class XHTMLCharEncoder
extends java.lang.Object

The XHTMLCharEncoder is sort of patterned on the java.net.URLEncoder. The reason for this is that all the Strings are filtered through the java.net.URLEncoder when they are stored on disk - since they need to be stored in a format that can be digested by Macromedia's Flash 4 and Flash 5. This limits the character set - as many Unicode characters disappear - but amending that will have to wait until Flash 6 has reached 98% of the web users.

Some adjustments have been made to the code after reading Peter K. Sheerin's article on Microsoft Word Characters and HTML character encoding at

     http://alistapart.com/stories/emen/
 

The XHTMLCharEncoder includes a small test that generates a XHTML document that can been uploaded to

     http://validator.w3.org/
 
for verification.

The XHTMLCharEncoder takes a String as input, and can either return a new String, or append values to a given StringBuffer.

Since:
SWFIT1.0
Version:
$Revision: 1.4 $ $Date: 2003/02/26 20:20:08 $
Author:
Olaf Havnes

Field Summary
static java.lang.String BREAK
          The XHTML break tag: <br />.
static java.lang.String SPACE
          The XHTML break tag: <br />.
 
Method Summary
static java.lang.StringBuffer charTest(java.lang.StringBuffer str_b)
          A test running through all the chars from 0 - 255.
static java.lang.String decodeMixed(java.lang.String str)
          Reverses the encoding method above.
static java.lang.StringBuffer encodeMixed(java.lang.StringBuffer str_b, java.lang.String str)
          Escapes a string into numeric XHTML entities.
static java.lang.String encodeSemi(java.lang.String str)
          Escapes a string into numeric XHTML entities, leaving out XHTML characters - if these characters are used for non XHTML purposes, the document will not validate
static java.lang.StringBuffer encodeSemi(java.lang.StringBuffer str_b, java.lang.String str)
          Escapes a string into numeric XHTML entities, leaving out XHTML characters - if these characters are used for non XHTML purposes, the document will not validate
static java.lang.String encodeStrict(java.lang.String str)
          Escapes a string into numeric XHTML entities
static java.lang.StringBuffer encodeStrict(java.lang.StringBuffer str_b, java.lang.String str)
          Escapes a string into numeric XHTML entities
static java.lang.String encodeStrictWithSpaces(java.lang.String str)
          Escapes a string into numeric XHTML entities
static java.lang.StringBuffer encodeStrictWithSpaces(java.lang.StringBuffer str_b, java.lang.String str)
          Escapes a string into numeric XHTML entities
static java.lang.String stripComments(java.lang.String data)
          Utility for stripping comments out of a XHTML String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BREAK

public static final java.lang.String BREAK
The XHTML break tag: <br />.

SPACE

public static final java.lang.String SPACE
The XHTML break tag: <br />.
Method Detail

encodeMixed

public static final java.lang.StringBuffer encodeMixed(java.lang.StringBuffer str_b,
                                                       java.lang.String str)
Escapes a string into numeric XHTML entities. This method is for use in generating RSS feeds that might contain html in the description fields.
Parameters:
str - String to be escaped.
str_b - StringBuffer to append the escaped String to.
Returns:
the given StringBuffer.

decodeMixed

public static final java.lang.String decodeMixed(java.lang.String str)
Reverses the encoding method above. NB! Bear in mind that this decoding method only works properly for the method above (and that it propably is not very efficient, since it should have taken an InputStream, not a String, as argument). Also bear in mind that this method will treat any uncoded '\n' and '\r' and '\t' as whitespace.
Parameters:
str - String to be un-escaped.
Returns:
the given String.

stripComments

public static final java.lang.String stripComments(java.lang.String data)
Utility for stripping comments out of a XHTML String.

encodeStrict

public static final java.lang.String encodeStrict(java.lang.String str)
Escapes a string into numeric XHTML entities
Parameters:
str - String to be escaped.
Returns:
the escaped String.

encodeStrict

public static final java.lang.StringBuffer encodeStrict(java.lang.StringBuffer str_b,
                                                        java.lang.String str)
Escapes a string into numeric XHTML entities
Parameters:
str - String to be escaped.
str_b - StringBuffer to append the escaped String to.
Returns:
the given StringBuffer.

encodeStrictWithSpaces

public static final java.lang.String encodeStrictWithSpaces(java.lang.String str)
Escapes a string into numeric XHTML entities
Parameters:
str - String to be escaped.
Returns:
the escaped String.

encodeStrictWithSpaces

public static final java.lang.StringBuffer encodeStrictWithSpaces(java.lang.StringBuffer str_b,
                                                                  java.lang.String str)
Escapes a string into numeric XHTML entities
Parameters:
str - String to be escaped.
str_b - StringBuffer to append the escaped String to.
Returns:
the given StringBuffer.

encodeSemi

public static final java.lang.String encodeSemi(java.lang.String str)
Escapes a string into numeric XHTML entities, leaving out XHTML characters - if these characters are used for non XHTML purposes, the document will not validate
Parameters:
str - String to be escaped.
Returns:
the escaped String.

encodeSemi

public static final java.lang.StringBuffer encodeSemi(java.lang.StringBuffer str_b,
                                                      java.lang.String str)
Escapes a string into numeric XHTML entities, leaving out XHTML characters - if these characters are used for non XHTML purposes, the document will not validate
Parameters:
str - String to be escaped.
str_b - StringBuffer to append the escaped String to.
Returns:
the given StringBuffer.

charTest

public static final java.lang.StringBuffer charTest(java.lang.StringBuffer str_b)
A test running through all the chars from 0 - 255.
Returns:
a StringBuffer that can be sent to a browser.


Swfit developer homepage
Copyright © 2003 Orgdot AS. All Rights Reserved.