org.apache.xml.security.utils
Class JavaUtils

java.lang.Object
  |
  +--org.apache.xml.security.utils.JavaUtils

public class JavaUtils
extends java.lang.Object

A collection of different, general-purpose methods for JAVA-specific things

Author:
Christian Geuer-Pollmann

Method Summary
static boolean binaryCompare(byte[] refBytes, byte[] c14nBytes)
          Returns true if both byte arrays are bytewise equal, false if the differ.
static byte[] getBytesFromFile(java.lang.String fileName)
          Method getBytesFromFile
static byte[] getBytesFromStream(java.io.InputStream inputStream)
          This method reads all bytes from the given InputStream till EOF and returns them as a byte array.
static boolean implementsInterface(java.lang.Object object, java.lang.String interfaceName)
          Checks whether an object implements a specific interface.
static boolean instanceOf(java.lang.Object object, java.lang.String className)
           
static void runGC()
          Method runGC
static void writeBytesToFilename(java.lang.String filename, byte[] bytes)
          Method writeBytesToFilename
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

implementsInterface

public static boolean implementsInterface(java.lang.Object object,
                                          java.lang.String interfaceName)
Checks whether an object implements a specific interface.
 org.w3c.dom.Document doc = ...; // some init

 boolean this_is_true =
    JavaUtils.implementsInterface(doc.getDocumentElement(),
                                  "org.w3c.dom.Element");

 boolean this_is_true_too =
    JavaUtils.implementsInterface(doc.getDocumentElement(),
                                  "org.w3c.dom.Node");

 

Parameters:
object - which is to be checked
interfaceName - is the String of the Interface
Returns:
true if the object implements the specified interface

instanceOf

public static boolean instanceOf(java.lang.Object object,
                                 java.lang.String className)
Parameters:
object -
className -

binaryCompare

public static boolean binaryCompare(byte[] refBytes,
                                    byte[] c14nBytes)
Returns true if both byte arrays are bytewise equal, false if the differ.

Parameters:
refBytes -
c14nBytes -
Returns:
true if both byte arrays are bytewise equal, false if the differ.
See Also:
MessageDigest.isEqual(byte[], byte[])

getBytesFromFile

public static byte[] getBytesFromFile(java.lang.String fileName)
                               throws java.io.FileNotFoundException,
                                      java.io.IOException
Method getBytesFromFile

Parameters:
fileName -
Throws:
java.io.FileNotFoundException
java.io.IOException

writeBytesToFilename

public static void writeBytesToFilename(java.lang.String filename,
                                        byte[] bytes)
Method writeBytesToFilename

Parameters:
filename -
bytes -

getBytesFromStream

public static byte[] getBytesFromStream(java.io.InputStream inputStream)
                                 throws java.io.IOException
This method reads all bytes from the given InputStream till EOF and returns them as a byte array.

Parameters:
inputStream -
Throws:
java.io.FileNotFoundException
java.io.IOException

runGC

public static void runGC()
Method runGC