|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjunit.extensions.xml.XMLUtil
Interface layer to w3c dom.
Field Summary |
Fields inherited from interface junit.extensions.xml.XMLConstants |
ACTION, ACTUALOBJ, ACTUALREFID, ADD, ASSERTENABLED, ASSERTEQUALS, ASSERTNOTEQUALS, ASSERTNOTNULL, ASSERTNOTSAME, ASSERTNULL, ASSERTSAME, CALL, CASE, CHOOSE, CLASSNAME, COLUMN, CONFIRM, DEBUG, DEFAULT, DELIMITER, DIALOG, DUMP, ECHO, ENABLED, ENCODING, EVALUATE, EXPECTEDOBJ, EXPECTEDREFID, FAIL, FILE, FOCUS, FOREACH, ID, INDEX, JFCFILELOC, LESSTHAN, LISTITEM, LOG, MARK, MESSAGE, METHOD, MODE, NAME, OTHERWISE, PATHREFID, PROCEDURE, PROPERTY, RECURSIVE, REFID, RELATIVE, REMOVE, ROW, SAVE, STDERR, STDOUT, STOPWATCH, SUITE, SWITCH, TABLECELL, TAGHANDLERS, TAGNAME, TEST, TYPE, USERE, VALUE, WHEN, WHILE |
Constructor Summary | |
private |
XMLUtil()
Private constructor: so that this class is not instantiated. |
Method Summary | |
static java.lang.String |
getAttribute(org.w3c.dom.Element element,
java.lang.String name)
A utility method that will get the attribute value, and if not found, will return null. |
static boolean |
getBooleanAttributeValue(org.w3c.dom.Element element,
java.lang.String name)
A utility method that will get the attribute value, and if not found, will return false. |
static java.lang.String |
getName(org.w3c.dom.Node node)
The name of the Node. |
static java.lang.String |
getPath(org.w3c.dom.Node node)
A utility method to build the path of the Node (with '.' are the separators). |
static java.lang.String |
getURLFromClassPath(java.lang.String file)
Resolve the path to the file. |
static boolean |
hasAttribute(org.w3c.dom.Element element,
java.lang.String name)
Checks the element for an attribute with the given name. |
static org.w3c.dom.Document |
parse(java.io.InputStream stream)
This method is used to parse the xml file with the specified name. |
static java.io.InputStream |
readFileFromClassContext(java.lang.Class clz,
java.lang.String fileName)
A utility method to find a file from the context of the specified class and read its contents. |
static java.io.InputStream |
readFileFromClasspath(java.lang.String fileName)
A utility method to find a file from the classpath and read its contents. |
static void |
writeFile(java.lang.String encoding,
java.io.OutputStream strm,
org.w3c.dom.Document doc)
Write the XML Document with the given encoding to a file. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
private XMLUtil()
Method Detail |
public static java.lang.String getAttribute(org.w3c.dom.Element element, java.lang.String name)
element
- The element to be searchedname
- The name of the attribute to be searched for
public static boolean getBooleanAttributeValue(org.w3c.dom.Element element, java.lang.String name)
element
- The element to be searchedname
- The name of the attribute to be searched for
public static java.lang.String getName(org.w3c.dom.Node node)
getNodeName()
method on the Node interface.
node
- The Node whose name is to be found.
public static java.lang.String getPath(org.w3c.dom.Node node)
node
- The Node whose path is to be found.
public static java.lang.String getURLFromClassPath(java.lang.String file)
file
- File path to resolve.
public static boolean hasAttribute(org.w3c.dom.Element element, java.lang.String name)
element
- element to be checked.name
- Name of the attribute.
public static org.w3c.dom.Document parse(java.io.InputStream stream)
stream
- The input stream of the xml file to be parsed.
public static java.io.InputStream readFileFromClassContext(java.lang.Class clz, java.lang.String fileName)
readFileFromClasspath(String)
method is that this one uses the classpath, and then appends the package information of the
specified class and then looks for the specified file.
clz
- Class whos resource loader should be used.fileName
- The name of the file to be read.
public static java.io.InputStream readFileFromClasspath(java.lang.String fileName)
fileName
- The name of the file to be read.
public static void writeFile(java.lang.String encoding, java.io.OutputStream strm, org.w3c.dom.Document doc) throws java.io.UnsupportedEncodingException
encoding
- Encoding to use when writing the file.strm
- Stream to write the document.doc
- XML Document to be written.
java.io.UnsupportedEncodingException
- thrown if the implementation
of the encoding cannot be found.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |