org.quattor.pan.output
Class XMLFormatterUtils

java.lang.Object
  extended by org.quattor.pan.output.XMLFormatterUtils

public class XMLFormatterUtils
extends java.lang.Object


Constructor Summary
XMLFormatterUtils()
           
 
Method Summary
static java.lang.String encodeAsXMLName(java.lang.String s)
          This will encode the given string as a valid XML name.
static boolean isValidXMLCharacter(int codepoint)
          Determine if a given UNICODE character can appear in a valid XML file.
static boolean isValidXMLName(java.lang.String s)
          Determine if the given string is a valid XML name.
static boolean isValidXMLString(java.lang.String s)
          Determine if the given string can be written to an XML file without encoding.
static boolean isXMLNamePart(int codepoint)
          Determine if the given character is a legal non-starting character for an XML name.
static boolean isXMLNameStart(int codepoint)
          Determine if the given character is a legal starting character for an XML name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLFormatterUtils

public XMLFormatterUtils()
Method Detail

isXMLNameStart

public static boolean isXMLNameStart(int codepoint)
Determine if the given character is a legal starting character for an XML name. Note that although a colon is a legal value its use is strongly discouraged and this method will return false for a colon. The list of valid characters can be found in the Common Syntactic Constructs section of the XML specification.

Parameters:
codepoint -
Returns:
true if the character may appear as the first letter of an XML name; false otherwise

isXMLNamePart

public static boolean isXMLNamePart(int codepoint)
Determine if the given character is a legal non-starting character for an XML name. Note that although a colon is a legal value its use is strongly discouraged and this method will return false for a colon. The list of valid characters can be found in the Common Syntactic Constructs section of the XML specification.

Parameters:
codepoint -
Returns:
true if the character may appear as a non-starting letter of an XML name; false otherwise

isValidXMLCharacter

public static boolean isValidXMLCharacter(int codepoint)
Determine if a given UNICODE character can appear in a valid XML file. The allowed characters are 0x9, 0xA, 0xD, 0x20-0xD7FF, 0xE000-0xFFFD, and 0x100000-0x10FFFF; all other characters may not appear in an XML file.

Parameters:
codepoint -
Returns:
true if the character may appear in a valid XML file; false otherwise

isValidXMLName

public static boolean isValidXMLName(java.lang.String s)
Determine if the given string is a valid XML name.

Parameters:
s - String to examine for illegal XML characters
Returns:
true if the String can be written to an XML file without encoding; false otherwise

isValidXMLString

public static boolean isValidXMLString(java.lang.String s)
Determine if the given string can be written to an XML file without encoding. This will be the case so long as the string does not contain illegal XML characters.

Parameters:
s - String to examine for illegal XML characters
Returns:
true if the String can be written to an XML file without encoding; false otherwise

encodeAsXMLName

public static java.lang.String encodeAsXMLName(java.lang.String s)
This will encode the given string as a valid XML name. The format will be an initial underscore followed by the hexadecimal representation of the string. The method will throw an exception if the argument is null.

Parameters:
s - String to encode as an XML name
Returns:
valid XML name from String
Throws:
java.lang.NullPointerException


Copyright © 2011 Quattor. All Rights Reserved.