|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
COM.FutureTense.Interfaces.Utilities
public class Utilities
Utility methods. These methods provide an easy to use interface to for some commonly needed functionality.
| Field Summary | |
|---|---|
static java.lang.String |
msgbodyUse this to locate the body portion of a returned getPOP3Messages() element |
static java.lang.String |
productFor 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 |
|---|
public static java.lang.String product
public static java.lang.String msgbody
| Constructor Detail |
|---|
protected Utilities()
| Method Detail |
|---|
public static final java.lang.String osSafeSpec(java.lang.String spec)
spec - The input file specification.public static final java.lang.String pathFromSpec(java.lang.String spec)
spec - file specificationUtilities.fileFromSpec(String)public static final java.lang.String fileFromSpec(java.lang.String spec)
spec - file specificationUtilities.pathFromSpec(String)
public static final java.io.File createTempFile(boolean bManageDelete)
throws java.io.IOException
bManageDelete - true to indicate that call will not delete the filejava.io.IOException
public static final java.lang.String readFile(java.lang.String spec,
java.lang.String sEncoding)
spec - The path and file name of the file to read.sEncoding - The character encoding of the file datapublic static final java.lang.String readFile(java.lang.String spec)
Will strip out characters returned by java.lang.Character.isIdentifierIgnorable().
spec - The path and file name of the file to read.public static final byte[] readByteFile(java.lang.String spec)
spec - The path and file name of the file to read.public static final boolean fileExists(java.lang.String name)
name - The path and file name of the file to verify.
public static final boolean readFile(java.lang.String spec,
java.io.OutputStream os)
throws java.io.IOException
spec - The path and file name of the file to read. Stream may throw an exceptionos - An OutputStreamjava.io.IOExceptionpublic static final java.lang.String readURL(java.lang.String url)
url - The URL to read, i.e. "http://www.futuretense.com/".public static final byte[] readByteURL(java.lang.String spec)
spec - The URL to read, i.e. "http://www.futuretense.com/".
public static final java.lang.String fileName(java.lang.String folder,
java.lang.String fname)
folder - The folder for the file.fname - The name of the file.
public static final boolean writeFile(java.lang.String fname,
java.lang.String str)
fname - The path and name of the file.str - The data to write to the file.
public static final int unzipFile(java.lang.String zip,
java.lang.String folder)
zip - The path and name of the file to unzip.folder - The folder to unzip the file into.
public static boolean zip2(java.util.Map<java.lang.String,java.io.File> files,
java.io.OutputStream out)
throws java.lang.Exception
java.lang.Exception
public static int unzip2(java.lang.String basedir,
java.io.InputStream in)
throws java.io.IOException
java.io.IOException
public static final boolean zip(java.util.Map map,
java.lang.String file)
throws java.lang.Exception
map - Entries to zip up in the form String, blobfile - The full path to target zip file.java.lang.Exception
public static final boolean zipDirectory(java.lang.String zipfile,
java.lang.String dirname,
boolean recursive,
java.lang.String files)
throws java.lang.Exception
zipfile - Target filedirname - Directory to ziprecursive - Whether to recurse into subdirectoriesfiles - File selector such as (*.*, *.class, etc)java.lang.Exceptionpublic static final boolean validateZip(java.lang.String zip)
zip - The path/name of the file to unzip.
public static final boolean writeFile(java.lang.String fname,
byte[] bytes,
int len)
fname - The path and name of the file.bytes - The byte array to write to the file.len - The number of bytes to write.
public static final boolean writeFile2(java.lang.String fname,
byte[] bytes,
int len)
public static final int isFolder(java.lang.String p)
p - folder pathpublic static final int isFile(java.lang.String p)
p - file namepublic static final boolean deleteFile(java.lang.String fname)
fname - The path and file name of the file to delete.
public static final int emptyFolder(java.lang.String path,
boolean bDelete)
path - namebDelete - boolean - delete folder toopublic static final boolean ensureFolder(java.lang.String path)
path - name
public static final int emptyfolder(java.lang.String path,
java.lang.String pattern)
path - namepattern - file wildcard pattern to match
public static final boolean appendFile(java.lang.String fname,
java.lang.String str)
fname - The path and file name of the file to delete.str - The file data to append, in string form.
public static final boolean appendFile(java.lang.String fname,
byte[] bytes,
int size)
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.public static final java.lang.String deBabble(java.lang.String s)
s - string to convert
public static final java.lang.String replaceAll(java.lang.String source,
java.lang.String what,
java.lang.String with)
source - The source string. NULL or empty returns samewhat - What to replace. NULL or empty returns source.with - The replacement values (may be null to erase).public static final java.lang.String genID(ICS icsThread)
icsThread - An interface object used to synchronize this number across VM's and/or the cluster.Utilities.genID(), ICS.genID(boolean)public static final java.lang.String genID()
Utilities.genID(ICS), ICS.genID(boolean)
public static final java.util.Vector words(java.lang.String str,
int sep)
str - String of words to parse.sep - The seperator character.public static final java.util.Vector sortWords(java.util.Vector words)
words - Vector of stringspublic static final java.util.Vector sortWordsAlpha(java.util.Vector words)
words - Vector of strings
public static final java.util.Vector words(java.lang.String cmd,
java.lang.String sep)
cmd - String of words to parse.sep - String of seperating characters.public static final boolean goodString(java.lang.String s)
s - input stringpublic static final java.lang.String stringFromList(java.util.List list)
public static FTValList getParams(java.lang.String in)
in - The input string containing the parameters.
public static void getParams(java.lang.String sInput,
java.util.Map map,
boolean bDecode)
sInput - The input string containing the parameters.map - The output map of key/value pairsbDecode - true to indicate that decoding is desiredpublic static final java.lang.String jdbcDateFromCal(java.util.Calendar c)
c - Calendar with date.Utilpublic static final java.lang.String jdbcTimeFrom(java.util.Calendar cal)
cal - Calendar with date.Utilpublic static final java.lang.String sqlDate(java.util.Calendar cal)
cal - Calendar with date and time.Utilpublic static java.util.Calendar calendarFromJDBCString(java.lang.String s)
s - String in the form of YYYY-MM-DD HH24:MI:SSUtil
public static final boolean itemIsInList(java.util.Vector l,
java.lang.String s,
boolean c)
l - The Vector list of strings.s - The String item to find.c - boolean True for caseless check, false otherwise.
public static java.util.Vector directoryList(java.lang.String path,
java.lang.String filter,
boolean recurse,
int maxcount)
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.
public static java.util.Vector directoryList(java.lang.String path,
java.lang.String filter,
boolean recurse,
int maxcount,
COM.FutureTense.Interfaces.IDirectoryObserver ido)
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.
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)
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.
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)
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 bodyerr - Error string, set on failure.
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)
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 bodycharset - The character set of the message subjecterr - Error string, set on failure.
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)
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.
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)
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 bodyerr - Error string, set on failure.
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)
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 bodycharset - The character set of the message subjecterr - Error string, set on failure.
public static java.util.Vector getPOP3Messages(java.lang.String host,
java.lang.String user,
java.lang.String password,
boolean bRemove)
host - Host server.user - User account.password - User password.bRemove - Set to "true" to remove the messages from the server after get.
public static java.util.Vector getPOP3Messages(java.lang.String host,
java.lang.String user,
java.lang.String password,
boolean bRemove,
int ctimeout)
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 connectpublic static final boolean cryptoEnabled()
public static final java.lang.String encryptPlatformString(java.lang.String s)
s - The string to encrypt. String is converted to bytes using default platform encoding before encrypting it.
public static final java.lang.String encryptPlatformString(java.lang.String s,
byte[] key)
s - The string to encrypt. String is converted to bytes using default platform encoding before encrypting it.public static final java.lang.String encryptString(java.lang.String s)
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.
public static final java.lang.String encryptString(java.lang.String s,
byte[] key)
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.public static java.lang.String decryptString(java.lang.String s)
s - The string to decrypt.
public static java.lang.String decryptString(java.lang.String s,
byte[] key)
s - The string to decrypt.public static boolean lockFile(java.lang.String file)
Don't forget to release the lock otherwise it is held until the vm shuts down.
file - filename to lockpublic static boolean unlockFile(java.lang.String file)
file - filename to unlockpublic static boolean osIgnoreFileCase()
public static java.lang.String stringFromValList(java.util.Map map)
map - Map to compress to stringUtilities.stringFromValList(Map, boolean)
public static java.lang.String stringFromValList(java.util.Map map,
boolean bEncode)
map - Map to compress to stringbEncode - true to encode keys and valuesUtilities.stringFromValList(Map)public static java.lang.String keysFromMap(java.util.Map map)
map - input Mappublic static boolean fileLockLoadOK()
public static java.lang.String getBLOBDir(java.lang.String seed)
seed - Value based on which the folder structure will be generated. It is suggested to use the filename as seed, but not necessary.public static java.lang.String getNameNoTrailingNumber(java.lang.String name)
name -public static java.lang.String generateUUID()
public static final boolean isAllowedHeader(java.lang.String headerStr)
headerStr -public static final java.lang.String tempFolder()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.