Poseidon for UMLTM
  UMLdoc
 PREV  CLASSIFIER    NEXT  CLASSIFIER     FRAMES    NO FRAMES      
SUMMARY:   INNER | ATTR | ASSOC | CONSTR | METHOD     DETAIL:   INNER | ATTR | ASSOC | CONSTR | METHOD     DIAGRAMS:   COLLAB | SEQ | STATE | ACTIV

com.gentleware.services.util

Class Utils

com.gentleware.services.util.Utils

public class Utils


Authors:
JvV


 Attribute Summary
private static double  DEFAULT_COMPARISON_TOLERANCE
 
public static int  HOURS_PER_DAY
 
public static int  MILLISECONDS_PER_DAY
 
public static int  MILLISECONDS_PER_HOUR
 
public static int  MILLISECONDS_PER_MINUTE
 
public static int  MILLISECONDS_PER_SECOND
 
public static int  MINUTES_PER_HOUR
 
public static int  SECONDS_PER_MINUTE
 
arrow_up
 

 Method Summary
public static void   addAtIndex(Collection collection, int index, Object element)
 
public static void   addDaysToDate(Date date, int daysToAdd)
 
public static boolean   canWriteImage(String format)
Check if imageio package is present and can be used to write an image of the given format (e.g. 
private static boolean   checkCountryCode(String countryCode)
 
public static boolean   checkEmail(String email)
Checks an email address for correct syntax: user@host.tld Unknown top-level domains are rejected. 
private static boolean   checkLanguageCode(String languageCode)
 
public static int   compare(int a, int b)
 
public static int   compare(long a, long b)
 
public static int   compare(double a, double b)
 
public static int   compare(double a, double b, double epsilon)
 
public static URL   convertFileToUrl(File file)
Converts abstract path name into a file:URL by escaping characters that are illegal in urls. 
public static Locale   createLocale(String localeSpec)
localeSpec must be in format [language[_country[_variant]]] with language two char lower case, country two char upper case, variant any string  
public static String   createUniqueId()
Creates a new unique id (e.g. 
public static boolean   equals(double a, double b)
 
public static boolean   equals(double a, double b, double epsilon)
 
public static boolean   equals(Object a, Object b)
 
public static URL   exchangeUrlExtension(URL url, String desiredExtension)
 
public static URL   fileToUrl(File file)
 
public static String   filenameToUri(String str)
Fixes a platform dependent filename to standard URI form. 
public static Object   findFirstCommonObject(Collection objects1, Collection objects2)

Returns the first object which both lists have in common at the same index-position. 

public static URL   fixUrlExtension(URL url, String desiredExtension)
 
public static List   getAllFilenames(File startDir, String extension)
Produces a list of Strings with all filenames that have the specified extension under the startDir. 
public static Object   getAtIndex(Collection collection, int index)
 
public static float   getColorSimilarity(Color a, Color b)
 
public static String   getConfigDir(String productName, String edition)
 
public static String   getConfigDir(String edition)
 
public static int   getDateDifferenceInDays(Date pastDate, Date futureDate)
 
public static String   getExceptionFullDescription(Exception e)
 
public static int   getFileCount(File file)
 
public static float   getFileIncrementor(File file)
 
public static String   getFilenameFromUrl(URL url, int maxFilenameLength, boolean includePath, String defaultFilename)
Returns a displayable name generated from the given URL. 
public static File   getInstallationDirectory(Class fromClass)
 
public static List   getJavaFilenames(File startDir)
Produces a vector of all .java files (Strings) under the startDir, recursively. 
public static String   getLocaleSpec(Locale locale, boolean includeLeadingUnderscore)
 
public static String   getPathToContainingJar(Class containedClass)
 
public static int   getSign(double x)
 
public static byte   getSignedByte(short positiveValue)
 
public static short   getUnsignedByte(byte b)
 
private static void   hsb2Xyz(float[] hsb)
converts a color's hsb components to xyz coordinates in the normalized HSB color cone (height == 1, radius = 0.5)  
public static int   indexOf(Collection collection, Object element)
 
public static Date   installationDate(int plusNDays, Class ofClass)
returns the date of installation of the provided class  
public static void   intersect(Collection a, Collection b)
Removes all elements from a that aren't also in b  
public static boolean   isLinuxOs()
Check if the operationg system is Linux  
public static boolean   isMacOs()
Check if the operationg system is Mac OS  
public static boolean   isValidLocaleSpec(String localeSpec)
Checks if localeSpec has the form "[nl[_cc[_vv]]]" where nl is two lower case characters, cc is two upper case characters and vv is any string (that may itself also contain '_' characters). 
public static boolean   isWindowsOs()
Checks if the operating system is Windows. 
public static String   makeDateString(Date date)
 
public static String   makeDateString(Date date, int dateFormat, int timeFormat)
 
public static BufferedImage   readImage(URL url)
Reads an image from an URL. 
private static void   recursiveGetFilenames(File dir, List names, String extension)
Produces a list of all files (Strings) with the given extension under the startDir, recursively. 
public static Object   removeAtIndex(Collection collection, int oldIndex)
 
public static String   removeDots(String value)
 
public static String   stripJunk(String s)
 
public static URL   stripUrlExtension(URL url)
 
public static File   urlToFile(URL url)
Converts a file: URL to a file object. 
public static boolean   validPathnameForOperatingSystem(String sourcepathName)
 
public static void   writeImage(RenderedImage image, String format, OutputStream stream)
Writes a rendered image to an output stream using imageio. 
arrow_up
 

Tagged Values
static false
 

 Attribute Detail

DEFAULT_COMPARISON_TOLERANCE

private static double DEFAULT_COMPARISON_TOLERANCE

arrow_up


HOURS_PER_DAY

public static int HOURS_PER_DAY

arrow_up


MILLISECONDS_PER_DAY

public static int MILLISECONDS_PER_DAY

arrow_up


MILLISECONDS_PER_HOUR

public static int MILLISECONDS_PER_HOUR

arrow_up


MILLISECONDS_PER_MINUTE

public static int MILLISECONDS_PER_MINUTE

arrow_up


MILLISECONDS_PER_SECOND

public static int MILLISECONDS_PER_SECOND

arrow_up


MINUTES_PER_HOUR

public static int MINUTES_PER_HOUR

arrow_up


SECONDS_PER_MINUTE

public static int SECONDS_PER_MINUTE

arrow_up
 Method Detail

addAtIndex

public static void addAtIndex(Collection collection, int index, Object element)

Parameters:
collection -
index -
element -
arrow_up


addDaysToDate

public static void addDaysToDate(Date date, int daysToAdd)

Parameters:
date -
daysToAdd -
arrow_up


canWriteImage

public static boolean canWriteImage(String format)


Check if imageio package is present and can be used to write an image of the given format (e.g. "png")  
Parameters:
format -
Returns:
arrow_up


checkCountryCode

private static boolean checkCountryCode(String countryCode)

Parameters:
countryCode -
Returns:
arrow_up


checkEmail

public static boolean checkEmail(String email)


Checks an email address for correct syntax: user@host.tld Unknown top-level domains are rejected.  
Parameters:
email -
Returns:
true if email is syntactically correct
arrow_up


checkLanguageCode

private static boolean checkLanguageCode(String languageCode)

Parameters:
languageCode -
Returns:
arrow_up


compare

public static int compare(int a, int b)

Parameters:
a -
b -
Returns:
arrow_up


compare

public static int compare(long a, long b)

Parameters:
a -
b -
Returns:
arrow_up


compare

public static int compare(double a, double b)

Parameters:
a -
b -
Returns:
arrow_up


compare

public static int compare(double a, double b, double epsilon)

Parameters:
a -
b -
epsilon -
Returns:
arrow_up


convertFileToUrl

public static URL convertFileToUrl(File file)


Converts abstract path name into a file:URL by escaping characters that are illegal in urls. JDK1.4 java.io.File.toURL() doesn't escape illegal characters.  
Parameters:
file -
Returns:
arrow_up


createLocale

public static Locale createLocale(String localeSpec)


localeSpec must be in format [language[_country[_variant]]] with language two char lower case, country two char upper case, variant any string  
Parameters:
localeSpec -
Returns:
null if localeSpec is empty (i.e. representing the default locale), else the locale
Exceptions:
NullPointerException if localeSpec is null
arrow_up


createUniqueId

public static String createUniqueId()


Creates a new unique id (e.g. to be used as xmi id).  
Returns:
A string containing the new unique id.
arrow_up


equals

public static boolean equals(double a, double b)

Parameters:
a -
b -
Returns:
arrow_up


equals

public static boolean equals(double a, double b, double epsilon)

Parameters:
a -
b -
epsilon -
Returns:
arrow_up


equals

public static boolean equals(Object a, Object b)

Parameters:
a -
b -
Returns:
arrow_up


exchangeUrlExtension

public static URL exchangeUrlExtension(URL url, String desiredExtension)

Parameters:
url -
desiredExtension -
Returns:
arrow_up


fileToUrl

public static URL fileToUrl(File file)

Parameters:
file -
Returns:
arrow_up


filenameToUri

public static String filenameToUri(String str)


Fixes a platform dependent filename to standard URI form.  
Parameters:
str - The string to fix.
Returns:
Returns the fixed URI string.
arrow_up


findFirstCommonObject

public static Object findFirstCommonObject(Collection objects1, Collection objects2)


Returns the first object which both lists have in common at the same index-position. {a, b, c} and {c, b, a} will return b as result while {a, b, c} and {c, a, b} will return null.

 
Parameters:
objects1 - first collection of objects to compare
objects2 - second collection of objects to compare
Returns:
first common object or null
Exceptions:
IllegalArgumentException if both collections differ in size
arrow_up


fixUrlExtension

public static URL fixUrlExtension(URL url, String desiredExtension)

Parameters:
url -
desiredExtension -
Returns:
arrow_up


getAllFilenames

public static List getAllFilenames(File startDir, String extension)


Produces a list of Strings with all filenames that have the specified extension under the startDir. Recurses into each subdirectory. The Strings are fully qualified, ie, they all have the prefix "path of StartDir".  
Parameters:
startDir -
extension -
Returns:
a list of Strings, or an empty List.
arrow_up


getAtIndex

public static Object getAtIndex(Collection collection, int index)

Parameters:
collection -
index -
Returns:
arrow_up


getColorSimilarity

public static float getColorSimilarity(Color a, Color b)

Parameters:
a -
b -
Returns:
the normalized distance of the colors in the HSB color cone, i.e. 0 for equals colors, 1 for maximum difference
arrow_up


getConfigDir

public static String getConfigDir(String productName, String edition)

Parameters:
productName -
edition -
Returns:
the configuration directory of the given poseidon edition
arrow_up


getConfigDir

public static String getConfigDir(String edition)

Parameters:
edition -
Returns:
arrow_up


getDateDifferenceInDays

public static int getDateDifferenceInDays(Date pastDate, Date futureDate)

Parameters:
pastDate -
futureDate -
Returns:
arrow_up


getExceptionFullDescription

public static String getExceptionFullDescription(Exception e)

Parameters:
e -
Returns:
arrow_up


getFileCount

public static int getFileCount(File file)

Parameters:
file -
Returns:
arrow_up


getFileIncrementor

public static float getFileIncrementor(File file)

Parameters:
file -
Returns:
arrow_up


getFilenameFromUrl

public static String getFilenameFromUrl(URL url, int maxFilenameLength, boolean includePath, String defaultFilename)


Returns a displayable name generated from the given URL. For the file-protocol the preceding protocol is stripped. For other protocols the protocol is kept.  
Parameters:
url - the URL to generate the name for. If null the defaultFilename will be used as result
maxFilenameLength - the maximum size the returned filename might have. If the name is longer than allowed the path will be shortened and replaced with an ellipsis. The filename itself will never be touched therefore if the name itself exceeds the maxFilenameLength the returned value will have the length of the name (unshortened) plus the length of the ellipsis plus the length of one path-separator. A value less than 1 for the maxFilenameLength will disable truncation.
includePath - if the path should be added to the result or not. If false only the name, unshortened, with no ellipsis anywhere will be returned. This might be useful to clean url-escape-sequences from the name.
defaultFilename - used as return-value if url is null
Returns:
the calculated name or defaultFilename
arrow_up


getInstallationDirectory

public static File getInstallationDirectory(Class fromClass)

Parameters:
fromClass -
Returns:
arrow_up


getJavaFilenames

public static List getJavaFilenames(File startDir)


Produces a vector of all .java files (Strings) under the startDir, recursively.  
Parameters:
startDir -
Returns:
arrow_up


getLocaleSpec

public static String getLocaleSpec(Locale locale, boolean includeLeadingUnderscore)

Parameters:
locale -
includeLeadingUnderscore -
Returns:
arrow_up


getPathToContainingJar

public static String getPathToContainingJar(Class containedClass)

Parameters:
containedClass -
Returns:
arrow_up


getSign

public static int getSign(double x)

Parameters:
x -
Returns:
arrow_up


getSignedByte

public static byte getSignedByte(short positiveValue)

Parameters:
positiveValue -
Returns:
arrow_up


getUnsignedByte

public static short getUnsignedByte(byte b)

Parameters:
b -
Returns:
the short representing the unsigned interpretation of b's bit pattern, i.e. a value 0...255
arrow_up


hsb2Xyz

private static void hsb2Xyz(float[] hsb)


converts a color's hsb components to xyz coordinates in the normalized HSB color cone (height == 1, radius = 0.5)  
Parameters:
hsb -
arrow_up


indexOf

public static int indexOf(Collection collection, Object element)

Parameters:
collection -
element -
Returns:
arrow_up


installationDate

public static Date installationDate(int plusNDays, Class ofClass)


returns the date of installation of the provided class  
Parameters:
plusNDays - you may speficy an offset - for example if you want an evaluation to end 3 days after the installation, then pass 3 here to know the end date
ofClass - Specifies the Class of which the installation date should be evaluated
Returns:
arrow_up


intersect

public static void intersect(Collection a, Collection b)


Removes all elements from a that aren't also in b  
Parameters:
a -
b -
arrow_up


isLinuxOs

public static boolean isLinuxOs()


Check if the operationg system is Linux  
Returns:
arrow_up


isMacOs

public static boolean isMacOs()


Check if the operationg system is Mac OS  
Returns:
arrow_up


isValidLocaleSpec

public static boolean isValidLocaleSpec(String localeSpec)


Checks if localeSpec has the form "[nl[_cc[_vv]]]" where nl is two lower case characters, cc is two upper case characters and vv is any string (that may itself also contain '_' characters). Valid codes are not checked, i.e. nl supposedly contains an iso language codes and cc contains an iso country code, but may in fact be any two characters of correct case. Returns true if localeSpec is empty (valid specification for current default locale).  
Parameters:
localeSpec -
Returns:
arrow_up


isWindowsOs

public static boolean isWindowsOs()


Checks if the operating system is Windows.  
Returns:
arrow_up


makeDateString

public static String makeDateString(Date date)

Parameters:
date -
Returns:
arrow_up


makeDateString

public static String makeDateString(Date date, int dateFormat, int timeFormat)

Parameters:
date -
dateFormat -
timeFormat -
Returns:
arrow_up


readImage

public static BufferedImage readImage(URL url)


Reads an image from an URL. The URL must have a suffix supported by an ImageIO reader (e.g. ".gif").  
Parameters:
url -
Returns:
arrow_up


recursiveGetFilenames

private static void recursiveGetFilenames(File dir, List names, String extension)


Produces a list of all files (Strings) with the given extension under the startDir, recursively.  
Parameters:
dir -
names -
extension -
arrow_up


removeAtIndex

public static Object removeAtIndex(Collection collection, int oldIndex)

Parameters:
collection -
oldIndex -
Returns:
arrow_up


removeDots

public static String removeDots(String value)

Parameters:
value -
Returns:
arrow_up


stripJunk

public static String stripJunk(String s)

Parameters:
s -
Returns:
arrow_up


stripUrlExtension

public static URL stripUrlExtension(URL url)

Parameters:
url -
Returns:
arrow_up


urlToFile

public static File urlToFile(URL url)


Converts a file: URL to a file object. Is necessary because spaces may be encoded differently depending on the current JDK/WebStart version. Will return null if the url uses a different protocol (e.g. http:) or the url was null. Will return the jar file if the url specified an entry in the jar file.  
Parameters:
url -
Returns:
arrow_up


validPathnameForOperatingSystem

public static boolean validPathnameForOperatingSystem(String sourcepathName)

Parameters:
sourcepathName -
Returns:
arrow_up


writeImage

public static void writeImage(RenderedImage image, String format, OutputStream stream)


Writes a rendered image to an output stream using imageio. The stream is left open.  
Parameters:
image -
format - e.g. "png"
stream -
Exceptions:
IllegalArgumentException if the desired format is not supported by imageio an
arrow_up
Created  2004 - 10 - 21

    Poseidon for UMLTM
  UMLdoc
 PREV  CLASSIFIER    NEXT  CLASSIFIER     FRAMES    NO FRAMES      
SUMMARY:   INNER | ATTR | ASSOC | CONSTR | METHOD     DETAIL:   INNER | ATTR | ASSOC | CONSTR | METHOD     DIAGRAMS:   COLLAB | SEQ | STATE | ACTIV

Generated with Poseidon for UMLTM.
Poseidon is a registered trademark of Gentleware AG in Germany, USA and other countries. Copyright 2003-2004 Gentleware AG, Schanzenstr. 70, 20357 Hamburg, Germany. All Rights Reserved.

UML is a trademark or registered trademark of Object Management Group, Inc. in the U.S. and other countries.