uPortal 2.4.1
API Documentation

org.jasig.portal.utils
Class XMLEscaper

java.lang.Object
  extended byorg.jasig.portal.utils.XMLEscaper

public class XMLEscaper
extends java.lang.Object

This utility provides a simple way of escaping the special or reserved characters in XML that serve as delimiters so that a string of characters can be left untouched by an XML parser. See http://www.w3.org/TR/2000/REC-xml-20001006#syntax and http://www.w3.org/TR/2000/REC-xml-20001006#sec-predefined-ent and http://www.w3.org/TR/2000/REC-xml-20001006#sec-entexpand Most of the code was borrowed from Xerces serializer classes. If anyone finds a useable method in a standard XML API that escapes XML strings, we should use it in place of this class.

Version:
$Revision: 1.5 $
Author:
Ken Weiner, kweiner@unicon.net

Constructor Summary
XMLEscaper()
           
 
Method Summary
static java.lang.String escape(char ch)
          Escapes an XML character
static java.lang.String escape(java.lang.String source)
          Escapes an XML string
static void main(java.lang.String[] args)
          This method is provided to test out the escape method.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLEscaper

public XMLEscaper()
Method Detail

escape

public static java.lang.String escape(java.lang.String source)
Escapes an XML string

Parameters:
source - a String to be escaped
Returns:
an escaped String

escape

public static java.lang.String escape(char ch)
Escapes an XML character

Parameters:
ch - a char to be escaped
Returns:
an escaped char

main

public static void main(java.lang.String[] args)
This method is provided to test out the escape method.

Parameters:
args - the command line arguments

uPortal 2.4.1
API Documentation