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 javax.swing.ImageIcon base64ToImage(java.lang.String base64)
           
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 fillSubtitles(java.lang.String filePath, java.lang.String subtitles)
           
static java.lang.String getCacheDirectory()
          Returns the currently used cache 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 getCurrentDirectory()
           
static java.lang.String getExtension(java.io.File f)
          Retrieved the file extension of a file
static java.lang.String getHexColor(java.awt.Color color)
           
static int getIntegerValue(java.lang.String s)
           
static javax.swing.ImageIcon getRatingIcon(java.lang.Object value)
           
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

fillSubtitles

public static java.lang.String fillSubtitles(java.lang.String filePath,
                                             java.lang.String subtitles)

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

getIntegerValue

public static int getIntegerValue(java.lang.String s)

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

base64ToImage

public static javax.swing.ImageIcon base64ToImage(java.lang.String base64)

getHexColor

public static java.lang.String getHexColor(java.awt.Color color)

getRatingIcon

public static javax.swing.ImageIcon getRatingIcon(java.lang.Object value)

getCacheDirectory

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

Returns:
fully qualified path

getCurrentDirectory

public static java.lang.String getCurrentDirectory()
                                            throws java.lang.Exception
Throws:
java.lang.Exception

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