de.saar.basic
Class XmlEntities

Object
  extended by XmlEntities

public class XmlEntities
extends Object

A collection of functions for dealing with XML entities.

Author:
Alexander Koller

Constructor Summary
XmlEntities()
           
 
Method Summary
static String decode(String s)
          Replaces XML entities (& etc.) by the corresponding characters.
static String encode(String s)
          Replaces special characters (<, >, quotes, and &) with the XML entities.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlEntities

public XmlEntities()
Method Detail

encode

public static String encode(String s)
Replaces special characters (<, >, quotes, and &) with the XML entities.

Parameters:
s - a string
Returns:
a string with the characters replaced by entities

decode

public static String decode(String s)
                     throws XmlDecodingException
Replaces XML entities (&amp; etc.) by the corresponding characters.

The implementation of this method was taken from Steven Brandt, "RegexRecipes", http://www.javaregex.com/RegexRecipesV1.pdf.

Parameters:
s - a string
Returns:
a string with the entities replaced by characters.
Throws:
XmlDecodingException - if the string contains an undefined character entity.