org.fcrepo.test.fesl.util
Class DataUtils

java.lang.Object
  extended by org.fcrepo.test.fesl.util.DataUtils

public class DataUtils
extends Object

Utility class for managing documents.

Author:
nishen@melcoe.mq.edu.au

Constructor Summary
DataUtils()
           
 
Method Summary
static Document getDocumentFromBytes(byte[] data)
          Creates an XML document object from a byte array.
static Document getDocumentFromFile(File file)
          Creates an XML document object from a file.
static Document getDocumentFromFile(String filename)
          Creates an XML document object from a file.
static String getHash(byte[] data)
          Generates an MD5 checksum of a series of bytes.
static byte[] loadFile(File file)
          Loads a file into a byte array.
static byte[] loadFile(String filename)
          Loads a file into a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataUtils

public DataUtils()
Method Detail

getDocumentFromFile

public static Document getDocumentFromFile(String filename)
                                    throws Exception
Creates an XML document object from a file.

Parameters:
file - the filename of the file to load.
Returns:
the XML document object.
Throws:
Exception

getDocumentFromFile

public static Document getDocumentFromFile(File file)
                                    throws Exception
Creates an XML document object from a file.

Parameters:
file - the file to load.
Returns:
the XML document object.
Throws:
Exception

getDocumentFromBytes

public static Document getDocumentFromBytes(byte[] data)
                                     throws Exception
Creates an XML document object from a byte array.

Parameters:
file - the file to load.
Returns:
the XML document object.
Throws:
Exception

loadFile

public static byte[] loadFile(String filename)
                       throws Exception
Loads a file into a byte array.

Parameters:
filename - name of file to load.
Returns:
byte array containing the data file.
Throws:
Exception

loadFile

public static byte[] loadFile(File file)
                       throws Exception
Loads a file into a byte array.

Parameters:
File - to load.
Returns:
byte array containing the data file.
Throws:
Exception

getHash

public static String getHash(byte[] data)
                      throws NoSuchAlgorithmException
Generates an MD5 checksum of a series of bytes.

Parameters:
data - the byte array on which to compute the hash.
Returns:
the MD5 hash.
Throws:
NoSuchAlgorithmException


Copyright © 2012 DuraSpace. All Rights Reserved.