net.sf.ext.util
Class Utilities

java.lang.Object
  extended bynet.sf.ext.util.Utilities

public class Utilities
extends java.lang.Object

General utilities

Since:
1.3
Version:
0.50
Author:
Robert-Jan van der Waals

Constructor Summary
Utilities()
           
 
Method Summary
static java.net.URL createCachedImage(java.lang.String base64String)
          Saves an image to a cache directory and returns its URL
static java.net.URL createCachedImage(java.lang.String base64String, java.lang.String fileName)
          Saves an image to a cache directory and returns its URL
static java.lang.String fileToBase64String(java.net.URL url)
          Gets the content of a file and converts it to a base64 string
static java.lang.String getCacheDirectory()
          Returns the currently used case directory
static java.awt.Dimension getCenteredWindowLocation(java.awt.Dimension windowSize)
          Returns a centered location for a window / form / dialog
static java.lang.String getCompareStringForFile(java.net.URL url)
          Retrieves the content of the file (first 100 bytes) so it can be compared with the content of another file
static java.lang.String getExtension(java.io.File f)
          Retrieved the file extension of a file
static java.lang.String getUniqueID()
          Creates a unique ID.
static byte[] readFile(java.io.File file)
          Reads the content of a file (fully)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utilities

public Utilities()
Method Detail

getCenteredWindowLocation

public static java.awt.Dimension getCenteredWindowLocation(java.awt.Dimension windowSize)
Returns a centered location for a window / form / dialog

Parameters:
windowSize - size of the window
Returns:
centered location

getUniqueID

public static java.lang.String getUniqueID()
Creates a unique ID. Can be used for custom IDs in the database. Based on date / time + random number

Returns:
unique ID as String

getExtension

public static java.lang.String getExtension(java.io.File f)
Retrieved the file extension of a file

Parameters:
f - file to get the extension from
Returns:
extenstion or empty string

getCompareStringForFile

public static java.lang.String getCompareStringForFile(java.net.URL url)
                                                throws java.lang.Exception
Retrieves the content of the file (first 100 bytes) so it can be compared with the content of another file

Parameters:
url - url of the file to create the compare string for
Returns:
string (content of file)
Throws:
java.lang.Exception

readFile

public static byte[] readFile(java.io.File file)
                       throws java.lang.Exception
Reads the content of a file (fully)

Parameters:
file - file to retrieve the content from
Returns:
content of the file as a byte array
Throws:
java.lang.Exception

createCachedImage

public static java.net.URL createCachedImage(java.lang.String base64String)
Saves an image to a cache directory and returns its URL

Parameters:
base64String - image as base64 string
Returns:
Null or URL of cached image

createCachedImage

public static java.net.URL createCachedImage(java.lang.String base64String,
                                             java.lang.String fileName)
Saves an image to a cache directory and returns its URL

Parameters:
base64String - image as Base64 string
fileName - cache filename
Returns:
Null or URL of cached image

getCacheDirectory

public static java.lang.String getCacheDirectory()
Returns the currently used case directory

Returns:
fully qualified path

fileToBase64String

public static java.lang.String fileToBase64String(java.net.URL url)
Gets the content of a file and converts it to a base64 string

Parameters:
url - url of file
Returns:
base64 content of the file