com.cybersource.ws.client
Class Utility

java.lang.Object
  extended bycom.cybersource.ws.client.Utility

public class Utility
extends java.lang.Object

Class containing useful constants and methods.


Field Summary
static java.lang.String ENVIRONMENT
          Environment information.
static java.lang.String VERSION
          Version number of this release.
 
Method Summary
static org.w3c.dom.Element getElement(org.w3c.dom.Document owner, java.lang.String elementName, java.lang.String nsURI)
          Returns the Element object corresponding to the given element name.
static java.lang.String getElementText(org.w3c.dom.Document owner, java.lang.String elementName, java.lang.String nsURI)
          Returns the text value of the given element name in the CyberSource namespace.
static java.lang.String getStackTrace(java.lang.Exception e)
          Returns the stack trace of the supplied Exception object.
static javax.xml.parsers.DocumentBuilder newDocumentBuilder()
          Returns a DocumentBuilder object.
static java.lang.String nodeToString(org.w3c.dom.Node node)
          Returns the string representation of the given Node object.
static java.lang.String nodeToString(org.w3c.dom.Node node, int type)
          Returns the string representation of the given Node object.
static byte[] read(java.io.File file)
          Reads the content of the given file into a byte array.
static byte[] read(java.io.InputStream in)
          Reads the content of the given file into a byte array.
static byte[] read(java.lang.String filename)
          Reads the content of the given file into a byte array.
static java.util.Properties readProperties(java.lang.String[] commandLineArgs)
          Reads the properties from a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final java.lang.String VERSION
Version number of this release.

See Also:
Constant Field Values

ENVIRONMENT

public static final java.lang.String ENVIRONMENT
Environment information.

Method Detail

nodeToString

public static java.lang.String nodeToString(org.w3c.dom.Node node,
                                            int type)
Returns the string representation of the given Node object. Used for logging or demo purposes only. As it employs some formatting parameters, parsing the string it returns may not result to a Node object exactly similar to the one passed to it.

Parameters:
node - the Node object whose string representation is wanted.
type - either PCI.REQUEST or PCI.REPLY. Used for masking.
Returns:
the string representation of the given Node object.

nodeToString

public static java.lang.String nodeToString(org.w3c.dom.Node node)
Returns the string representation of the given Node object. Used for logging or demo purposes only. As it employs some formatting parameters, parsing the string it returns may not result to a Node object exactly similar to the one passed to it.

Parameters:
node - the Node object whose string representation is wanted.
Returns:
the string representation of the given Node object.

readProperties

public static java.util.Properties readProperties(java.lang.String[] commandLineArgs)
Reads the properties from a file. If no filename was specified in the command-line, it will look for "cybs.properties" in the current directory.

Parameters:
commandLineArgs - the command-line arguments.
Returns:
Properties object containing the run-time properties required by the clients.

read

public static byte[] read(java.lang.String filename)
                   throws java.io.IOException
Reads the content of the given file into a byte array.

Parameters:
filename - name of the file to read.
Returns:
content of the file.
Throws:
java.io.IOException - if there was an error reading the file.

read

public static byte[] read(java.io.File file)
                   throws java.io.IOException
Reads the content of the given file into a byte array.

Parameters:
file - File object to read.
Returns:
content of the file
Throws:
java.io.IOException - if there was an error reading the file.

read

public static byte[] read(java.io.InputStream in)
                   throws java.io.IOException
Reads the content of the given file into a byte array.

Parameters:
in - InputStream object to read.
Returns:
content of the file
Throws:
java.io.IOException - if there was an error reading the file.

newDocumentBuilder

public static javax.xml.parsers.DocumentBuilder newDocumentBuilder()
                                                            throws javax.xml.parsers.ParserConfigurationException
Returns a DocumentBuilder object.

Returns:
a DocumentBuilder object.
Throws:
javax.xml.parsers.ParserConfigurationException - if no suitable parser implementation is found.

getElement

public static org.w3c.dom.Element getElement(org.w3c.dom.Document owner,
                                             java.lang.String elementName,
                                             java.lang.String nsURI)
Returns the Element object corresponding to the given element name.

Parameters:
owner - Document object to search.
elementName - local name to search for.
nsURI - namespaceURI to used (may be null).
Returns:
the Element object corresponding to the given element name or null if none is found.

getElementText

public static java.lang.String getElementText(org.w3c.dom.Document owner,
                                              java.lang.String elementName,
                                              java.lang.String nsURI)
Returns the text value of the given element name in the CyberSource namespace.

Parameters:
owner - Document object to search.
elementName - local name to search for.
nsURI - namespaceURI to used (may be null).
Returns:
the text value of the given element name in the CyberSource namespace or null if none is found.

getStackTrace

public static java.lang.String getStackTrace(java.lang.Exception e)
Returns the stack trace of the supplied Exception object.

Parameters:
e - Exception object.
Returns:
the stack trace of the Exception object.


Copyright © 2003-2006 CyberSource Corporation. All Rights Reserved.