com.cri.xcat.api.helpers
Class XcatUtilities

java.lang.Object
  extended by com.cri.xcat.api.helpers.XcatUtilities

public class XcatUtilities
extends java.lang.Object

Contains various helper functions that are useful in dealing with xCAT communications.

Author:
Scott Brown

Constructor Summary
XcatUtilities()
           
 
Method Summary
static org.w3c.dom.Document createXmlDocument(java.util.Map<java.lang.String,java.lang.Object> map)
          Creates an XML document in the format that xcatd would expect from the input map.
static boolean isEmpty(java.lang.String str)
          Returns true if the string is null or an empty string.
static void xmlToOutputStream(org.w3c.dom.Document dom, java.io.OutputStream stream)
          Takes an XML document and sends it to the output stream in a way that xcatd would expect.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XcatUtilities

public XcatUtilities()
Method Detail

createXmlDocument

public static org.w3c.dom.Document createXmlDocument(java.util.Map<java.lang.String,java.lang.Object> map)
                                              throws javax.xml.parsers.ParserConfigurationException
Creates an XML document in the format that xcatd would expect from the input map. The key for each value is set to the XML tag name while the value is set to the text content inside the XML tag. If the value of the object is Iterable (a collection of some kind), then each value inside the collection gets a separate tag with the text content inside set to the String value of the item.

Parameters:
map - The map that will be used to create the XML
Returns:
an XML document that xcatd would expect
Throws:
javax.xml.parsers.ParserConfigurationException

xmlToOutputStream

public static void xmlToOutputStream(org.w3c.dom.Document dom,
                                     java.io.OutputStream stream)
                              throws javax.xml.transform.TransformerException
Takes an XML document and sends it to the output stream in a way that xcatd would expect. Specifically, xcatd requires the XML declaration to be omitted from the request.

Parameters:
dom - the XML document that will be sent to the output stream.
stream - the output stream from the socket that would be the connection to xcatd
Throws:
javax.xml.transform.TransformerException

isEmpty

public static boolean isEmpty(java.lang.String str)
Returns true if the string is null or an empty string.

Parameters:
str - the string to check.
Returns:
true if the string is null or an empty string; false, otherwise.