org.barracudamvc.plankton.xml
Class XMLUtil

java.lang.Object
  extended by org.barracudamvc.plankton.xml.XMLUtil

public class XMLUtil
extends Object

Utility functions for XML related text conversion. The functions we have in place at this time are used to convert xml based unicode text into Java based unicode and vica versa.


Constructor Summary
XMLUtil()
           
 
Method Summary
static String fromXMLUnicodeString(String s)
          Convert a String from XML unicode string.
static void main(String[] args)
          Main method.
static String toXMLUnicodeString(String s)
          Convert a String to legal XML unicode string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLUtil

public XMLUtil()
Method Detail

fromXMLUnicodeString

public static String fromXMLUnicodeString(String s)
Convert a String from XML unicode string. Basically, we look for anything starting with &# followed by a semicolon and convert it to the actual Java character representation

Parameters:
s - the String to be converted
Returns:
the converted string

toXMLUnicodeString

public static String toXMLUnicodeString(String s)
Convert a String to legal XML unicode string. Basically, we look for special chars (&,<,>,',") and replace them with their XML equivalents. In addition, replace anything higher than ~ with the XML unicode version (&#nnn;). Note that this method is smart enough to keep track of the number of characters which need to get converted to Unicode, and if that number exceeds about 15 percent of the size of the String it'll just return the whole String blocked within a CDATA section.

Parameters:
s - the String to be converted
Returns:
the converted string

main

public static void main(String[] args)
Main method. Run this to perform a simple little test of the class conversion methods.



Copyright © 2006 BarracudaMVC.org All Rights Reserved.