com.starteam.util
Class XMLUtils

java.lang.Object
  extended by com.starteam.util.XMLUtils

public final class XMLUtils
extends java.lang.Object

A class with XML related utility methods.


Method Summary
static java.lang.String escape(java.lang.String rawText)
          Returns the specified arbitrary text reformated in a form suitable for the contents of an XML element.
static boolean isXML(java.io.File file)
          Test to see if a file could be an XML file.
static void writeEscaped(java.lang.String rawText, java.lang.StringBuffer out)
          Writes the specified arbitrary text to the specified StringBuffer in a form suitable for the contents of an XML element.
static void writeEscaped(java.lang.String rawText, java.io.Writer out)
          Writes the specified arbitrary text to the specified output in a form suitable for the contents of an XML element.
static void writeEscapedAttributeValue(java.lang.String rawText, java.io.Writer out)
          Properly escape a text string for use as an XML attribute value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

writeEscaped

public static void writeEscaped(java.lang.String rawText,
                                java.lang.StringBuffer out)
Writes the specified arbitrary text to the specified StringBuffer in a form suitable for the contents of an XML element. In particular the following characters will be escaped: ", ', >, <, &

Parameters:
rawText - the raw text to be encoded for XML output
out - the StringBuffer to which the encoded text will be written

writeEscaped

public static void writeEscaped(java.lang.String rawText,
                                java.io.Writer out)
                         throws java.io.IOException
Writes the specified arbitrary text to the specified output in a form suitable for the contents of an XML element. In particular the following characters will be escaped: ", ', >, <, &

Parameters:
rawText - the raw text to be encoded for XML output
out - the output to which the encoded text will be written
Throws:
java.io.IOException

escape

public static java.lang.String escape(java.lang.String rawText)
Returns the specified arbitrary text reformated in a form suitable for the contents of an XML element. In particular the following characters will be escaped: ", ', >, <, &

Parameters:
rawText - the raw text to be encoded for XML output

writeEscapedAttributeValue

public static void writeEscapedAttributeValue(java.lang.String rawText,
                                              java.io.Writer out)
                                       throws java.io.IOException
Properly escape a text string for use as an XML attribute value. The characters that need to be escaped are CR, LF, TAB, <, >, & ' (single quote), " (double quote). In addition all control characters (those chars < 0x20) are escaped.

Parameters:
rawText - the text string to be written
out - the output destination of the text
Throws:
java.io.IOException

isXML

public static boolean isXML(java.io.File file)
Test to see if a file could be an XML file. Not that the file might have a byte order mark. Supported byte order marks include UTF8, UTF16LE, and UTF16BE. Following the byte order mark the file must start with "
Parameters:
file - the file to test
Returns:
true if the file could be an XML file


StarTeam SDK 14.0, Build 21
Copyright © 2003-2012 Borland Software Corporation. All rights reserved.