Skip navigation links


COM.FutureTense.Interfaces
Class Utilities

java.lang.Object
  extended by COM.FutureTense.Interfaces.Utilities


public class Utilities
extends java.lang.Object

Utility methods. These methods provide an easy to use interface to for some commonly needed functionality.


Field Summary
static java.lang.String msgbody
          Use this to locate the body portion of a returned getPOP3Messages() element
static java.lang.String product
          For finding out the IPS product name

 

Constructor Summary
protected Utilities()
           

 

Method Summary
static boolean appendFile(java.lang.String fname, byte[] bytes, int size)
          Appends to a file to disk.
static boolean appendFile(java.lang.String fname, java.lang.String str)
          Appends to a file to disk.
static java.util.Calendar calendarFromJDBCString(java.lang.String s)
          Returns a calendar object from JDBC date/time.
static java.io.File createTempFile(boolean bManageDelete)
          Method to create a temporary file
static boolean cryptoEnabled()
          Checks if encryption is enabled.
static java.lang.String deBabble(java.lang.String s)
          Replaces %20,%22,%12,%3c,%3e,%26 in input string with the characters they represent.
static java.lang.String decryptString(java.lang.String s)
          Decrypts a string with the default key.
static java.lang.String decryptString(java.lang.String s, byte[] key)
          Decrypts a string with the supplied key.
static boolean deleteFile(java.lang.String fname)
          Deletes a file from disk.
static java.util.Vector directoryList(java.lang.String path, java.lang.String filter, boolean recurse, int maxcount)
          Returns a vector of filenames given a path and a filter.
static java.util.Vector directoryList(java.lang.String path, java.lang.String filter, boolean recurse, int maxcount, COM.FutureTense.Interfaces.IDirectoryObserver ido)
          Returns a vector of filenames given a path and a filter.
static int emptyFolder(java.lang.String path, boolean bDelete)
          Delete a folder (optional) and all the contents within, recursively.
static int emptyfolder(java.lang.String path, java.lang.String pattern)
          Delete all the files which match the pattern from the specified directory tree, recursively.
static java.lang.String encryptPlatformString(java.lang.String s)
          Encrypts a string with the default key.
static java.lang.String encryptPlatformString(java.lang.String s, byte[] key)
          Encrypts a string with the supplied key.
static java.lang.String encryptString(java.lang.String s)
          Encrypts a string with the default key.
static java.lang.String encryptString(java.lang.String s, byte[] key)
          Encrypts a string with the supplied key.
static boolean ensureFolder(java.lang.String path)
          Make sure a path exists, creating subfolders as needed
static boolean fileExists(java.lang.String name)
          Does a verification of a file existing on disk
static java.lang.String fileFromSpec(java.lang.String spec)
          Returns a file from a file specification.
static boolean fileLockLoadOK()
          Check to see if the file lock native library loaded successfully.
static java.lang.String fileName(java.lang.String folder, java.lang.String fname)
          Creates a full path including file name, given a folder and file name.
static java.lang.String generateUUID()
          Returns a randomly-generated UUID.
static java.lang.String genID()
          Deprecated. use ICS.genID(boolean) instead
static java.lang.String genID(ICS icsThread)
          Deprecated. use ICS.genID(boolean) instead
static java.lang.String getBLOBDir(java.lang.String seed)
          Generate hash-based directory based on given seed.
static java.lang.String getNameNoTrailingNumber(java.lang.String name)
          Returns normalized name after removing the trailing comma number from name.
static FTValList getParams(java.lang.String in)
          Build a vallist of parameters given input in the form of "a=b&c=d..."
static void getParams(java.lang.String sInput, java.util.Map map, boolean bDecode)
          Build a map of parameters given input in the form of "a=b&c=d..."
static java.util.Vector getPOP3Messages(java.lang.String host, java.lang.String user, java.lang.String password, boolean bRemove)
          Retrieves a vector of messages from a POP3 server; default connection timeout is 120 seconds.
static java.util.Vector getPOP3Messages(java.lang.String host, java.lang.String user, java.lang.String password, boolean bRemove, int ctimeout)
          Retrieves a vector of messages from a POP3 server; specify the connection timeout on checking for new mail.
static boolean goodString(java.lang.String s)
          Return if a string is empty or null
static boolean isAllowedHeader(java.lang.String headerStr)
          The method is used to check whether the passed header is valid or not.
static int isFile(java.lang.String p)
          Verify a file
static int isFolder(java.lang.String p)
          Verify a folder
static boolean itemIsInList(java.util.Vector l, java.lang.String s, boolean c)
          Determines if a given string is in a vector.
static java.lang.String jdbcDateFromCal(java.util.Calendar c)
          Returns a JDBC formatted date from a calendar object.
static java.lang.String jdbcTimeFrom(java.util.Calendar cal)
          Returns a JDBC formatted time from a calendar object.
static java.lang.String keysFromMap(java.util.Map map)
          Return a string of keys from the Map
static boolean lockFile(java.lang.String file)
          Lock a file name for exclusive use by this thread.
static boolean osIgnoreFileCase()
          Return if the server OS has case specific vs casepreserve filesystem naming.
static java.lang.String osSafeSpec(java.lang.String spec)
          Returns a filespec where the "/" or "\" characters have been replaced by the system specific paths.
static java.lang.String pathFromSpec(java.lang.String spec)
          Returns a path from a file specification.
static byte[] readByteFile(java.lang.String spec)
          Reads in the file indicated by the passed file path, and returns the bytes.
static byte[] readByteURL(java.lang.String spec)
          Reads the passed URL, and returns its bytes.
static java.lang.String readFile(java.lang.String spec)
          Reads in the file indicated by the passed file path, and returns its contents.
static boolean readFile(java.lang.String spec, java.io.OutputStream os)
          Reads in the file indicated by the passed file path, and writes the bytes to the stream.
static java.lang.String readFile(java.lang.String spec, java.lang.String sEncoding)
          Reads in the file indicated by the passed file path, and returns its contents.
static java.lang.String readURL(java.lang.String url)
          Reads the passed URL, and returns its contents.
static java.lang.String replaceAll(java.lang.String source, java.lang.String what, java.lang.String with)
          Replaces a strings contents (all occurrences) with specified values.
static boolean sendMail(java.lang.String from, java.lang.String[] to, java.lang.String sub, java.lang.String replyto, java.lang.String messagestr, java.lang.String server, java.lang.StringBuffer err)
          Sends an SMTP mail
static boolean sendMail(java.lang.String from, java.lang.String[] to, java.lang.String sub, java.lang.String replyto, java.lang.String messagestr, java.lang.String server, java.lang.String contenttype, java.lang.StringBuffer err)
          Deprecated. use sendMail which includes charset instead
static boolean sendMail(java.lang.String from, java.lang.String[] to, java.lang.String sub, java.lang.String replyto, java.lang.String messagestr, java.lang.String server, java.lang.String contenttype, java.lang.String charset, java.lang.StringBuffer err)
          Sends an SMTP mail
static boolean sendMail(java.lang.String from, java.lang.String to, java.lang.String sub, java.lang.String replyto, java.lang.String messagestr, java.lang.String server, java.lang.StringBuffer err)
          Sends an SMTP mail message.
static boolean sendMail(java.lang.String from, java.lang.String to, java.lang.String sub, java.lang.String replyto, java.lang.String messagestr, java.lang.String server, java.lang.String contenttype, java.lang.StringBuffer err)
          Deprecated. use sendMail which includes charset instead
static boolean sendMail(java.lang.String from, java.lang.String to, java.lang.String sub, java.lang.String replyto, java.lang.String messagestr, java.lang.String server, java.lang.String contenttype, java.lang.String charset, java.lang.StringBuffer err)
          Sends an SMTP mail message.
static java.util.Vector sortWords(java.util.Vector words)
          Sort a list of strings, longest to shortest
static java.util.Vector sortWordsAlpha(java.util.Vector words)
          Sort a list of strings alphanumerically
static java.lang.String sqlDate(java.util.Calendar cal)
          Returns a string formatted as JDBC date/time from a calendar object.
static java.lang.String stringFromList(java.util.List list)
          Method to convert a collection into a comma separated list
static java.lang.String stringFromValList(java.util.Map map)
          Create a url-like set of name/values from a map ie x=y&a=b&c=d
static java.lang.String stringFromValList(java.util.Map map, boolean bEncode)
          Create a url-like set of name/values from a map ie x=y&a=b&c=d
static java.lang.String tempFolder()
           
static boolean unlockFile(java.lang.String file)
          Unlock a file name from exclusive use by this thread
static int unzip2(java.lang.String basedir, java.io.InputStream in)
           
static int unzipFile(java.lang.String zip, java.lang.String folder)
          Unzips a file into a folder.
static boolean validateZip(java.lang.String zip)
          Validates a zip file's zip integrity
static java.util.Vector words(java.lang.String str, int sep)
          Parses a string into a vector of words.
static java.util.Vector words(java.lang.String cmd, java.lang.String sep)
          Parses a string into a vector of words.
static boolean writeFile(java.lang.String fname, byte[] bytes, int len)
          Writes a file to disk, given an OS specific path and the contents of the file.
static boolean writeFile(java.lang.String fname, java.lang.String str)
          Writes a file to disk, given an OS specific path and the contents of the file.
static boolean writeFile2(java.lang.String fname, byte[] bytes, int len)
           
static boolean zip(java.util.Map map, java.lang.String file)
          Takes for each entry in the map makes a zip entry, and then creates the zip in a location specified by sOutputFile.
static boolean zip2(java.util.Map<java.lang.String,java.io.File> files, java.io.OutputStream out)
           
static boolean zipDirectory(java.lang.String zipfile, java.lang.String dirname, boolean recursive, java.lang.String files)
          Takes for each entry in the map makes a zip entry, and then creates the zip in a location specified by sOutputFile.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

product

public static java.lang.String product
For finding out the IPS product name

msgbody

public static java.lang.String msgbody
Use this to locate the body portion of a returned getPOP3Messages() element

Constructor Detail

Utilities

protected Utilities()

Method Detail

osSafeSpec

public static final java.lang.String osSafeSpec(java.lang.String spec)
Returns a filespec where the "/" or "\" characters have been replaced by the system specific paths.
Parameters:
spec - The input file specification.
Returns:
The converted, OS-specific string.

pathFromSpec

public static final java.lang.String pathFromSpec(java.lang.String spec)
Returns a path from a file specification. The specification does not have to be a complete or proper file path.
Parameters:
spec - file specification
Returns:
path to file
Since:
4.0
See Also:
Utilities.fileFromSpec(String)

fileFromSpec

public static final java.lang.String fileFromSpec(java.lang.String spec)
Returns a file from a file specification. The specification does not have to be a complete or proper file path.
Parameters:
spec - file specification
Returns:
file name
Since:
4.0
See Also:
Utilities.pathFromSpec(String)

createTempFile

public static final java.io.File createTempFile(boolean bManageDelete)
                                         throws java.io.IOException
Method to create a temporary file
Parameters:
bManageDelete - true to indicate that call will not delete the file
Returns:
file object of file or null on error
Throws:
java.io.IOException
Since:
5.0

readFile

public static final java.lang.String readFile(java.lang.String spec,
                                              java.lang.String sEncoding)
Reads in the file indicated by the passed file path, and returns its contents. The path is converted to the appropriate OS safe path.
Parameters:
spec - The path and file name of the file to read.
sEncoding - The character encoding of the file data
Returns:
The data in the file.

readFile

public static final java.lang.String readFile(java.lang.String spec)
Reads in the file indicated by the passed file path, and returns its contents. The path is converted to the appropriate OS safe path.

Will strip out characters returned by java.lang.Character.isIdentifierIgnorable().

Parameters:
spec - The path and file name of the file to read.
Returns:
The data in the file.

readByteFile

public static final byte[] readByteFile(java.lang.String spec)
Reads in the file indicated by the passed file path, and returns the bytes. The path is converted to the appropriate OS safe path.
Parameters:
spec - The path and file name of the file to read.
Returns:
An byte array of the files contents or null.

fileExists

public static final boolean fileExists(java.lang.String name)
Does a verification of a file existing on disk
Parameters:
name - The path and file name of the file to verify.
Returns:
file exists true or false

readFile

public static final boolean readFile(java.lang.String spec,
                                     java.io.OutputStream os)
                              throws java.io.IOException
Reads in the file indicated by the passed file path, and writes the bytes to the stream. The path is converted to the appropriate OS safe path.
Parameters:
spec - The path and file name of the file to read. Stream may throw an exception
os - An OutputStream
Returns:
success/failure
Throws:
java.io.IOException

readURL

public static final java.lang.String readURL(java.lang.String url)
Reads the passed URL, and returns its contents.
Parameters:
url - The URL to read, i.e. "http://www.futuretense.com/".
Returns:
The contents of the URL in a string.

readByteURL

public static final byte[] readByteURL(java.lang.String spec)
Reads the passed URL, and returns its bytes.
Parameters:
spec - The URL to read, i.e. "http://www.futuretense.com/".
Returns:
The contents of the URL in a byte array.

fileName

public static final java.lang.String fileName(java.lang.String folder,
                                              java.lang.String fname)
Creates a full path including file name, given a folder and file name. If fname is full path of the file then folder is ignored.
Parameters:
folder - The folder for the file.
fname - The name of the file.
Returns:
The full name and path of the file.

writeFile

public static final boolean writeFile(java.lang.String fname,
                                      java.lang.String str)
Writes a file to disk, given an OS specific path and the contents of the file.
Parameters:
fname - The path and name of the file.
str - The data to write to the file.
Returns:
Returns true on success, false on failure.

unzipFile

public static final int unzipFile(java.lang.String zip,
                                  java.lang.String folder)
Unzips a file into a folder.
Parameters:
zip - The path and name of the file to unzip.
folder - The folder to unzip the file into.
Returns:
Returns 0 on success, or error code on error.

zip2

public static boolean zip2(java.util.Map<java.lang.String,java.io.File> files,
                           java.io.OutputStream out)
                    throws java.lang.Exception
Throws:
java.lang.Exception

unzip2

public static int unzip2(java.lang.String basedir,
                         java.io.InputStream in)
                  throws java.io.IOException
Throws:
java.io.IOException

zip

public static final boolean zip(java.util.Map map,
                                java.lang.String file)
                         throws java.lang.Exception
Takes for each entry in the map makes a zip entry, and then creates the zip in a location specified by sOutputFile.
Parameters:
map - Entries to zip up in the form String, blob
file - The full path to target zip file.
Returns:
Returns true on success.
Throws:
java.lang.Exception

zipDirectory

public static final boolean zipDirectory(java.lang.String zipfile,
                                         java.lang.String dirname,
                                         boolean recursive,
                                         java.lang.String files)
                                  throws java.lang.Exception
Takes for each entry in the map makes a zip entry, and then creates the zip in a location specified by sOutputFile.
Parameters:
zipfile - Target file
dirname - Directory to zip
recursive - Whether to recurse into subdirectories
files - File selector such as (*.*, *.class, etc)
Returns:
Returns true on success.
Throws:
java.lang.Exception

validateZip

public static final boolean validateZip(java.lang.String zip)
Validates a zip file's zip integrity
Parameters:
zip - The path/name of the file to unzip.
Returns:
Returns boolean if zip is good

writeFile

public static final boolean writeFile(java.lang.String fname,
                                      byte[] bytes,
                                      int len)
Writes a file to disk, given an OS specific path and the contents of the file. The contents are a byte array.
Parameters:
fname - The path and name of the file.
bytes - The byte array to write to the file.
len - The number of bytes to write.
Returns:
Returns true on success, false on failure.

writeFile2

public static final boolean writeFile2(java.lang.String fname,
                                       byte[] bytes,
                                       int len)

isFolder

public static final int isFolder(java.lang.String p)
Verify a folder
Parameters:
p - folder path
Returns:
int 0 or error

isFile

public static final int isFile(java.lang.String p)
Verify a file
Parameters:
p - file name
Returns:
int 0 or error

deleteFile

public static final boolean deleteFile(java.lang.String fname)
Deletes a file from disk.
Parameters:
fname - The path and file name of the file to delete.
Returns:
Returns true on success, false on failure.

emptyFolder

public static final int emptyFolder(java.lang.String path,
                                    boolean bDelete)
Delete a folder (optional) and all the contents within, recursively.
Parameters:
path - name
bDelete - boolean - delete folder too
Returns:
0 if success, else error code

ensureFolder

public static final boolean ensureFolder(java.lang.String path)
Make sure a path exists, creating subfolders as needed
Parameters:
path - name
Returns:
if folder exists

emptyfolder

public static final int emptyfolder(java.lang.String path,
                                    java.lang.String pattern)
Delete all the files which match the pattern from the specified directory tree, recursively.
Parameters:
path - name
pattern - file wildcard pattern to match
Returns:
0 if success, else error code

appendFile

public static final boolean appendFile(java.lang.String fname,
                                       java.lang.String str)
Appends to a file to disk.
Parameters:
fname - The path and file name of the file to delete.
str - The file data to append, in string form.
Returns:
Returns true on success, false on failure.

appendFile

public static final boolean appendFile(java.lang.String fname,
                                       byte[] bytes,
                                       int size)
Appends to a file to disk.
Parameters:
fname - The path and file name of the file to delete.
bytes - The file data to append, in a byte array.
size - The number of bits to append.
Returns:
Returns true on success, false on failure.

deBabble

public static final java.lang.String deBabble(java.lang.String s)
Replaces %20,%22,%12,%3c,%3e,%26 in input string with the characters they represent.
Parameters:
s - string to convert
Returns:
Returns the new, converted string, or the same string if no conversion was done.

replaceAll

public static final java.lang.String replaceAll(java.lang.String source,
                                                java.lang.String what,
                                                java.lang.String with)
Replaces a strings contents (all occurrences) with specified values.
Parameters:
source - The source string. NULL or empty returns same
what - What to replace. NULL or empty returns source.
with - The replacement values (may be null to erase).
Returns:
Returns the new string.

genID

public static final java.lang.String genID(ICS icsThread)
Deprecated. use ICS.genID(boolean) instead
Generate a unique number based on the current time.
Parameters:
icsThread - An interface object used to synchronize this number across VM's and/or the cluster.
Returns:
Returns the string containing the number, or null on error.
See Also:
Utilities.genID(), ICS.genID(boolean)

genID

public static final java.lang.String genID()
Deprecated. use ICS.genID(boolean) instead
Generates a unique number based on the current time. Not safe outside the VM.
Returns:
Returns the string containing the number, or null on error.
See Also:
Utilities.genID(ICS), ICS.genID(boolean)

words

public static final java.util.Vector words(java.lang.String str,
                                           int sep)
Parses a string into a vector of words.
Parameters:
str - String of words to parse.
sep - The seperator character.
Returns:
Returns a vector of words, may be empty.

sortWords

public static final java.util.Vector sortWords(java.util.Vector words)
Sort a list of strings, longest to shortest
Parameters:
words - Vector of strings
Returns:
new vector of strings, original untouched

sortWordsAlpha

public static final java.util.Vector sortWordsAlpha(java.util.Vector words)
Sort a list of strings alphanumerically
Parameters:
words - Vector of strings
Returns:
new vector of strings, original untouched

words

public static final java.util.Vector words(java.lang.String cmd,
                                           java.lang.String sep)
Parses a string into a vector of words.
Parameters:
cmd - String of words to parse.
sep - String of seperating characters.
Returns:
Returns a vector of words, may be empty.

goodString

public static final boolean goodString(java.lang.String s)
Return if a string is empty or null
Parameters:
s - input string
Returns:
boolean true if not null, length > 0

stringFromList

public static final java.lang.String stringFromList(java.util.List list)
Method to convert a collection into a comma separated list

getParams

public static FTValList getParams(java.lang.String in)
Build a vallist of parameters given input in the form of "a=b&c=d..."
Parameters:
in - The input string containing the parameters.
Returns:
Returns an FTValList of parameters.

getParams

public static void getParams(java.lang.String sInput,
                             java.util.Map map,
                             boolean bDecode)
Build a map of parameters given input in the form of "a=b&c=d..."
Parameters:
sInput - The input string containing the parameters.
map - The output map of key/value pairs
bDecode - true to indicate that decoding is desired
Since:
4.0

jdbcDateFromCal

public static final java.lang.String jdbcDateFromCal(java.util.Calendar c)
Returns a JDBC formatted date from a calendar object.
Parameters:
c - Calendar with date.
Returns:
Returns the JDBC formatted date string .
See Also:
Util

jdbcTimeFrom

public static final java.lang.String jdbcTimeFrom(java.util.Calendar cal)
Returns a JDBC formatted time from a calendar object.
Parameters:
cal - Calendar with date.
Returns:
Returns the JDBC formatted time string.
See Also:
Util

sqlDate

public static final java.lang.String sqlDate(java.util.Calendar cal)
Returns a string formatted as JDBC date/time from a calendar object.
Parameters:
cal - Calendar with date and time.
Returns:
Returns the date and time in form YYYY-MM-DD HH24:MI:SS
See Also:
Util

calendarFromJDBCString

public static java.util.Calendar calendarFromJDBCString(java.lang.String s)
Returns a calendar object from JDBC date/time.
Parameters:
s - String in the form of YYYY-MM-DD HH24:MI:SS
Returns:
Returns the appropriate Calendar object.
See Also:
Util

itemIsInList

public static final boolean itemIsInList(java.util.Vector l,
                                         java.lang.String s,
                                         boolean c)
Determines if a given string is in a vector.
Parameters:
l - The Vector list of strings.
s - The String item to find.
c - boolean True for caseless check, false otherwise.
Returns:
Returns true if the string is in the vector, false if it is not.

directoryList

public static java.util.Vector directoryList(java.lang.String path,
                                             java.lang.String filter,
                                             boolean recurse,
                                             int maxcount)
Returns a vector of filenames given a path and a filter.
Parameters:
path - OS specific path.
filter - File filter, as in *.bat, *.*. Not all OS specific filter characters are supported.
recurse - A "true" value specifies to look for matching files (based on filter) in subdirectories of the supplied path.
maxcount - Specifies the maximum number of files that will be returned in the vector. Note that it is possible to generate outofmemory exceptions by specifing a very large number.
Returns:
Returns the vector of filenames in the path that meet the filter.

directoryList

public static java.util.Vector directoryList(java.lang.String path,
                                             java.lang.String filter,
                                             boolean recurse,
                                             int maxcount,
                                             COM.FutureTense.Interfaces.IDirectoryObserver ido)
Returns a vector of filenames given a path and a filter.
Parameters:
path - OS specific path.
filter - File filter, as in *.bat, *.*. Not all OS specific filter characters are supported.
recurse - A "true" value specifies to look for matching files (based on filter) in subdirectories of the supplied path.
maxcount - Specifies the maximum number of files that will be returned in the vector. Note that it is possible to generate outofmemory exceptions by specifing a very large number.
Returns:
Returns the vector of filenames in the path that meet the filter.
Since:
4.0

sendMail

public static final boolean sendMail(java.lang.String from,
                                     java.lang.String to,
                                     java.lang.String sub,
                                     java.lang.String replyto,
                                     java.lang.String messagestr,
                                     java.lang.String server,
                                     java.lang.StringBuffer err)
Sends an SMTP mail message.
Parameters:
from - The FROM field.
to - One or more email addresses, comma seperated.
sub - The SUBJECT field.
replyto - The REPLY TO field.
messagestr - The message BODY.
server - The name of the mail server.
err - Error string, set on failure.
Returns:
Returns true on success, false on failure.

sendMail

public static final boolean sendMail(java.lang.String from,
                                     java.lang.String to,
                                     java.lang.String sub,
                                     java.lang.String replyto,
                                     java.lang.String messagestr,
                                     java.lang.String server,
                                     java.lang.String contenttype,
                                     java.lang.StringBuffer err)
Deprecated. use sendMail which includes charset instead
Sends an SMTP mail message.
Parameters:
from - The FROM field.
to - One or more email addresses, comma seperated.
sub - The SUBJECT field.
replyto - The REPLY TO field.
messagestr - The message BODY.
server - The name of the mail server.
contenttype - The content-type of the message body
err - Error string, set on failure.
Returns:
Returns true on success, false on failure.

sendMail

public static final boolean sendMail(java.lang.String from,
                                     java.lang.String to,
                                     java.lang.String sub,
                                     java.lang.String replyto,
                                     java.lang.String messagestr,
                                     java.lang.String server,
                                     java.lang.String contenttype,
                                     java.lang.String charset,
                                     java.lang.StringBuffer err)
Sends an SMTP mail message.
Parameters:
from - The FROM field.
to - One or more email addresses, comma seperated.
sub - The SUBJECT field.
replyto - The REPLY TO field.
messagestr - The message BODY.
server - The name of the mail server.
contenttype - The content-type of the message body
charset - The character set of the message subject
err - Error string, set on failure.
Returns:
Returns true on success, false on failure.

sendMail

public static final boolean sendMail(java.lang.String from,
                                     java.lang.String[] to,
                                     java.lang.String sub,
                                     java.lang.String replyto,
                                     java.lang.String messagestr,
                                     java.lang.String server,
                                     java.lang.StringBuffer err)
Sends an SMTP mail
Parameters:
from - The FROM field.
to - An array of email addresses.
sub - The SUBJECT field.
replyto - The REPLY TO field.
messagestr - The message BODY.
server - The name of the mail server.
err - Error string, set on failure.
Returns:
Returns true on success, false on failure.

sendMail

public static final boolean sendMail(java.lang.String from,
                                     java.lang.String[] to,
                                     java.lang.String sub,
                                     java.lang.String replyto,
                                     java.lang.String messagestr,
                                     java.lang.String server,
                                     java.lang.String contenttype,
                                     java.lang.StringBuffer err)
Deprecated. use sendMail which includes charset instead
Sends an SMTP mail
Parameters:
from - The FROM field.
to - An array of email addresses.
sub - The SUBJECT field.
replyto - The REPLY TO field.
messagestr - The message BODY.
server - The name of the mail server.
contenttype - The content-type of the message body
err - Error string, set on failure.
Returns:
Returns true on success, false on failure.

sendMail

public static final boolean sendMail(java.lang.String from,
                                     java.lang.String[] to,
                                     java.lang.String sub,
                                     java.lang.String replyto,
                                     java.lang.String messagestr,
                                     java.lang.String server,
                                     java.lang.String contenttype,
                                     java.lang.String charset,
                                     java.lang.StringBuffer err)
Sends an SMTP mail
Parameters:
from - The FROM field.
to - An array of email addresses.
sub - The SUBJECT field.
replyto - The REPLY TO field.
messagestr - The message BODY.
server - The name of the mail server.
contenttype - The content-type of the message body
charset - The character set of the message subject
err - Error string, set on failure.
Returns:
Returns true on success, false on failure.

getPOP3Messages

public static java.util.Vector getPOP3Messages(java.lang.String host,
                                               java.lang.String user,
                                               java.lang.String password,
                                               boolean bRemove)
Retrieves a vector of messages from a POP3 server; default connection timeout is 120 seconds.
Parameters:
host - Host server.
user - User account.
password - User password.
bRemove - Set to "true" to remove the messages from the server after get.
Returns:
Returns a vector of message bodies or null. The vector contains a hashtable of header fields and body (as Utilities.msgbody, etc) where the header field text is downcased.

getPOP3Messages

public static java.util.Vector getPOP3Messages(java.lang.String host,
                                               java.lang.String user,
                                               java.lang.String password,
                                               boolean bRemove,
                                               int ctimeout)
Retrieves a vector of messages from a POP3 server; specify the connection timeout on checking for new mail.
Parameters:
host - Host server.
user - User account.
password - User password.
bRemove - Set to "true" to remove the messages from the server after get.
ctimeout - timeout (seconds) to fail during first connect
Returns:
Returns a vector of message bodies or null. The vector contains a hashtable of header fields and body (as Utilities.msgbody, etc) where the header field text is downcased.

cryptoEnabled

public static final boolean cryptoEnabled()
Checks if encryption is enabled.
Returns:
Returns true if encryption is enabled, false otherwise.

encryptPlatformString

public static final java.lang.String encryptPlatformString(java.lang.String s)
Encrypts a string with the default key.
Parameters:
s - The string to encrypt. String is converted to bytes using default platform encoding before encrypting it.
Returns:
Returns the encrypted string.

encryptPlatformString

public static final java.lang.String encryptPlatformString(java.lang.String s,
                                                           byte[] key)
Encrypts a string with the supplied key.
Parameters:
s - The string to encrypt. String is converted to bytes using default platform encoding before encrypting it.
Returns:
Returns the encrypted string.

encryptString

public static final java.lang.String encryptString(java.lang.String s)
Encrypts a string with the default key.
Parameters:
s - The string to encrypt. This method limits the input string to ascii characters. If non-ascii characters are used in the input, the decrypt() utility will not return original value.
Returns:
Returns the encrypted string.

encryptString

public static final java.lang.String encryptString(java.lang.String s,
                                                   byte[] key)
Encrypts a string with the supplied key.
Parameters:
s - The string to encrypt. This method limits the input string to ascii characters. If non-ascii characters are used in the input, the decrypt() utility will not return original value.
Returns:
Returns the encrypted string.

decryptString

public static java.lang.String decryptString(java.lang.String s)
Decrypts a string with the default key.
Parameters:
s - The string to decrypt.
Returns:
Returns the decrypted string.

decryptString

public static java.lang.String decryptString(java.lang.String s,
                                             byte[] key)
Decrypts a string with the supplied key.
Parameters:
s - The string to decrypt.
Returns:
Returns the decrypted string.

lockFile

public static boolean lockFile(java.lang.String file)
Lock a file name for exclusive use by this thread. No other threads can create a file with this name if it has been locked using this mechanism (and the other threads bother to check).

Don't forget to release the lock otherwise it is held until the vm shuts down.

Parameters:
file - filename to lock
Returns:
success or failure

unlockFile

public static boolean unlockFile(java.lang.String file)
Unlock a file name from exclusive use by this thread
Parameters:
file - filename to unlock
Returns:
success or failure

osIgnoreFileCase

public static boolean osIgnoreFileCase()
Return if the server OS has case specific vs casepreserve filesystem naming.
Returns:
true if case does not matter or false if it can not be determined that it does not matter.

stringFromValList

public static java.lang.String stringFromValList(java.util.Map map)
Create a url-like set of name/values from a map ie x=y&a=b&c=d
Parameters:
map - Map to compress to string
Returns:
String but needs encoding to be url safe. Note empty strings are not preserved.
See Also:
Utilities.stringFromValList(Map, boolean)

stringFromValList

public static java.lang.String stringFromValList(java.util.Map map,
                                                 boolean bEncode)
Create a url-like set of name/values from a map ie x=y&a=b&c=d
Parameters:
map - Map to compress to string
bEncode - true to encode keys and values
Returns:
String output. Note empty strings are not preserved.
Since:
4.0
See Also:
Utilities.stringFromValList(Map)

keysFromMap

public static java.lang.String keysFromMap(java.util.Map map)
Return a string of keys from the Map
Parameters:
map - input Map
Returns:
string in form "key1,key2,key3"
Since:
4.0

fileLockLoadOK

public static boolean fileLockLoadOK()
Check to see if the file lock native library loaded successfully.
Returns:
boolean true on success
Since:
4.0

getBLOBDir

public static java.lang.String getBLOBDir(java.lang.String seed)
Generate hash-based directory based on given seed. This can be used to spread out files across multiple directories and avoid stressing the filesystem.
Parameters:
seed - Value based on which the folder structure will be generated. It is suggested to use the filename as seed, but not necessary.
Returns:
Relative directory path.

getNameNoTrailingNumber

public static java.lang.String getNameNoTrailingNumber(java.lang.String name)
Returns normalized name after removing the trailing comma number from name.
Parameters:
name -
Returns:
'normalized' name

generateUUID

public static java.lang.String generateUUID()
Returns a randomly-generated UUID.

isAllowedHeader

public static final boolean isAllowedHeader(java.lang.String headerStr)
The method is used to check whether the passed header is valid or not.
Parameters:
headerStr -
Returns:
boolean return true if the header name or value is valid.

tempFolder

public static final java.lang.String tempFolder()

Skip navigation links


Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.