ColdBox Platform Version 2.6.3

coldbox.system.plugins
Class Utilities

WEB-INF.cftags.component
        extended by coldbox.system.frameworkSupertype
            extended by coldbox.system.plugin
                extended by coldbox.system.plugins.Utilities

public class Utilities
extends plugin

This is a Utilities CFC


Constructor Summary
init(any controller)
 
Method Summary
 boolean FileCanRead(String Filename)
          Check wether you can read a file
 boolean FileCanWrite(String Filename)
          Check wether you can write to a file
 string FileLastModified(string filename)
          Get the last modified date of a file
 string FileSize(string filename, [string sizeFormat='bytes'])
          Get the filesize of a file.
 boolean IsEmail(any str, [string tlds=''])
          author Jeff Guillaume (jeff@kazoomis.com): Tests passed value to see if it is a valid e-mail address (supports subdomain nesting and new top-level domains)
 boolean IsURL(any str)
          author Nathan Dintenfass (nathan@changemedia.com): A quick way to test if a string is a URL
 Any _deserialize(string BinaryString)
          Deserialize a byte array
 Any _deserializeFromFile(string fileSource)
          Deserialize a byte array from a file
 string _serialize(any ComplexObject)
          Serialize complex objects that implement serializable. Returns a binary string.
 void _serializeToFile(any ComplexObject, string fileDestination)
          Serialize complex objects that implement serializable, into a file.
 void appendFile(any FileToSave, any FileContents, [string CharSet='utf-8'], [boolean CheckCharSetFlag='false'])
          Facade to append to a file's content
 string checkCharSet(string charset)
          Check a charset with valid CF char sets, if invalid, it returns the framework's default character set
 array createArray(string str)
          Create an Array from conventions [ elem, elem ]
 void createFile(String filename)
          Create a new empty fileusing java.io.File.
 struct createStruct(string str)
          Create a Structure from conventions { key: value, key2= value }
 string getAbsolutePath(string path)
          Turn any system path, either relative or absolute, into a fully qualified one
 string getFileMimeType(string extension)
          Get's the file mime type for a given file extension
 string getIPAddress()
          Get the ip address of the executing hostname machine.
 string getInetHost()
          Get the hostname of the executing machine.
 string getJVMTotalMemory()
          Get the JVM's total memory.
 string getJVMfreeMemory()
          Get the JVM's free memory.
 string getJavaRuntime()
          Get the java runtime version
 string getJavaVersion()
          Get the java version.
 string getOSFileSeparator()
          Get the operating system's file separator character
 string getOSName()
          Get the operating system's name
 string getOSPathSeparator()
          Get the operating system's path separator character.
 boolean isCFUUID(string inStr)
          Checks if a passed string is a valid UUID.
 boolean isDirectory(String Filename)
          Check wether the filename argument is a directory or not
 boolean isFile(String Filename)
          Checks whether the filename argument is a file or not.
 boolean isSSL()
          Tells you if you are in SSL mode or not.
 any marshallData(string type, any data)
          Marshall data according to type
 string parseISO8601(string datetime)
          Parse a UTC or iso8601 date to a normal CF datetime object
 string parseRFC822(string datetime)
          Parse RFC822 dates, returns empty string if not a valid date.
 any placeHolderReplacer(any str, any settings)
          PlaceHolder Replacer for strings containing ${} patterns
 Any readFile(String FileToRead, [boolean ReadInBinaryFlag='false'], [string CharSet=''], [boolean CheckCharSetFlag='false'])
          Facade to Read a file's content
 boolean removeFile(string filename)
          Remove a file using java.io.File
 string ripExtension(string filename)
          Rip the extension of a filename.
 void saveFile(any FileToSave, any FileContents, [string CharSet='utf-8'], [boolean CheckCharSetFlag='false'])
          Facade to save a file's content
 void sendFile([any file=''], [string name=''], [string mimeType=''], [string disposition='attachment'], [boolean abortAtEnd='false'], [string extension=''])
          Send a file to the browser
 void sleeper(numeric milliseconds)
          Make the main thread of execution sleep for X amount of seconds.
 any uploadFile(string FileField, string Destination, [string NameConflict='makeunique'], [string Accept=''], [string Attributes='Normal'], [string Mode='755'])
          Facade to upload to a file, returns the cffile variable.
 
Methods inherited from class coldbox.system.plugin
getPluginDescription, getPluginName, getPluginVersion, getpluginPath, setPluginDescription, setPluginName, setPluginVersion
 
Methods inherited from class coldbox.system.frameworkSupertype
abort, announceInterception, dump, getColdboxOCM, getDatasource, getDebugMode, getHash, getInstance, getInterceptor, getMailSettings, getModel, getMyPlugin, getPlugin, getResource, getSetting, getSettingStructure, getSettingsBean, getcontroller, getfwLocale, htmlhead, include, includeUDF, locateDirectoryPath, locateFilePath, persistVariables, populateModel, relocate, renderExternalView, renderView, rethrowit, runEvent, setDebugMode, setNextEvent, setNextRoute, setSetting, setcontroller, settingExists, throw
 
Methods inherited from class WEB-INF.cftags.component
 

Constructor Detail

init

public init(any controller)

Method Detail

FileCanRead

public boolean FileCanRead(String Filename)
Check wether you can read a file

Parameters:
Filename - The absolute path of the file to check.

FileCanWrite

public boolean FileCanWrite(String Filename)
Check wether you can write to a file

Parameters:
Filename - The absolute path of the file to check.

FileLastModified

public string FileLastModified(string filename)
Get the last modified date of a file

Parameters:
filename

FileSize

public string FileSize(string filename, [string sizeFormat='bytes'])
Get the filesize of a file.

Parameters:
filename
sizeFormat - Available formats: [bytes][kbytes][mbytes][gbytes]

IsEmail

public boolean IsEmail(any str, [string tlds=''])
author Jeff Guillaume (jeff@kazoomis.com): Tests passed value to see if it is a valid e-mail address (supports subdomain nesting and new top-level domains)

Parameters:
str
tlds - Additional top level domains to add to the evaluation. Use a | to separate them

IsURL

public boolean IsURL(any str)
author Nathan Dintenfass (nathan@changemedia.com): A quick way to test if a string is a URL

Parameters:
str

_deserialize

public Any _deserialize(string BinaryString)
Deserialize a byte array

Parameters:
BinaryString - The byte array string to deserialize

_deserializeFromFile

public Any _deserializeFromFile(string fileSource)
Deserialize a byte array from a file

Parameters:
fileSource - The absolute path to the source file to deserialize

_serialize

public string _serialize(any ComplexObject)
Serialize complex objects that implement serializable. Returns a binary string.

Parameters:
ComplexObject - Any coldfusion primative data type and if cf8 componetns.

_serializeToFile

public void _serializeToFile(any ComplexObject, string fileDestination)
Serialize complex objects that implement serializable, into a file.

Parameters:
ComplexObject - Any coldfusion primative data type and if cf8 componetns.
fileDestination - The absolute path to the destination file to write to

appendFile

public void appendFile(any FileToSave, any FileContents, [string CharSet='utf-8'], [boolean CheckCharSetFlag='false'])
Facade to append to a file's content

Parameters:
FileToSave - The absolute path to the file.
FileContents - The file contents
CharSet - CF File CharSet Encoding to use.
CheckCharSetFlag - Check the charset.

checkCharSet

public string checkCharSet(string charset)
Check a charset with valid CF char sets, if invalid, it returns the framework's default character set

Parameters:
charset - Charset to check

createArray

public array createArray(string str)
Create an Array from conventions [ elem, elem ]

Parameters:
str - The convention string to create an array from. This is basic JSON syntax

createFile

public void createFile(String filename)
Create a new empty fileusing java.io.File.

Parameters:
filename - The absolute path of the file to create.

createStruct

public struct createStruct(string str)
Create a Structure from conventions { key: value, key2= value }

Parameters:
str - The convention string to create a struct from. This is basic JSON syntax

getAbsolutePath

public string getAbsolutePath(string path)
Turn any system path, either relative or absolute, into a fully qualified one

Parameters:
path - Abstract pathname

getFileMimeType

public string getFileMimeType(string extension)
Get's the file mime type for a given file extension

Parameters:
extension - e.g. jpg or gif

getIPAddress

public string getIPAddress()
Get the ip address of the executing hostname machine.


getInetHost

public string getInetHost()
Get the hostname of the executing machine.


getJVMTotalMemory

public string getJVMTotalMemory()
Get the JVM's total memory.


getJVMfreeMemory

public string getJVMfreeMemory()
Get the JVM's free memory.


getJavaRuntime

public string getJavaRuntime()
Get the java runtime version


getJavaVersion

public string getJavaVersion()
Get the java version.


getOSFileSeparator

public string getOSFileSeparator()
Get the operating system's file separator character


getOSName

public string getOSName()
Get the operating system's name


getOSPathSeparator

public string getOSPathSeparator()
Get the operating system's path separator character.


isCFUUID

public boolean isCFUUID(string inStr)
Checks if a passed string is a valid UUID.

Parameters:
inStr

isDirectory

public boolean isDirectory(String Filename)
Check wether the filename argument is a directory or not

Parameters:
Filename - The absolute path of the file to check.

isFile

public boolean isFile(String Filename)
Checks whether the filename argument is a file or not.

Parameters:
Filename - The absolute path of the file to check.

isSSL

public boolean isSSL()
Tells you if you are in SSL mode or not.


marshallData

public any marshallData(string type, any data)
Marshall data according to type

Parameters:
type - The type to marshal to. Valid values are JSON, WDDX, PLAIN
data - The data to marshal

parseISO8601

public string parseISO8601(string datetime)
Parse a UTC or iso8601 date to a normal CF datetime object

Parameters:
datetime - The datetime string to convert

parseRFC822

public string parseRFC822(string datetime)
Parse RFC822 dates, returns empty string if not a valid date.

Parameters:
datetime - The datetime string to convert

placeHolderReplacer

public any placeHolderReplacer(any str, any settings)
PlaceHolder Replacer for strings containing ${} patterns

Parameters:
str - The string variable to look for replacements
settings - The structure of settings to use in replacing

readFile

public Any readFile(String FileToRead, [boolean ReadInBinaryFlag='false'], [string CharSet=''], [boolean CheckCharSetFlag='false'])
Facade to Read a file's content

Parameters:
FileToRead - The absolute path to the file.
ReadInBinaryFlag - Read in binary flag.
CharSet - CF File CharSet Encoding to use.
CheckCharSetFlag - Check the charset.

removeFile

public boolean removeFile(string filename)
Remove a file using java.io.File

Parameters:
filename - The absolute path to the file.

ripExtension

public string ripExtension(string filename)
Rip the extension of a filename.

Parameters:
filename

saveFile

public void saveFile(any FileToSave, any FileContents, [string CharSet='utf-8'], [boolean CheckCharSetFlag='false'])
Facade to save a file's content

Parameters:
FileToSave - The absolute path to the file.
FileContents - The file contents
CharSet - CF File CharSet Encoding to use.
CheckCharSetFlag - Check the charset.

sendFile

public void sendFile([any file=''], [string name=''], [string mimeType=''], [string disposition='attachment'], [boolean abortAtEnd='false'], [string extension=''])
Send a file to the browser

Parameters:
file - The absolute path to the file or a binary file
name - The name to send the file to the browser. If not sent in, it will use the name of the file or a UUID for a binary file
mimeType - A valid mime type to use. If not sent in, we will try to use a default one according to file extension
disposition - The browser content disposition (attachment/inline)
abortAtEnd - Do an abort after content sending
extension - Only used if file is binary. e.g. jpg or gif

sleeper

public void sleeper(numeric milliseconds)
Make the main thread of execution sleep for X amount of seconds.

Parameters:
milliseconds - Milliseconds to sleep

uploadFile

public any uploadFile(string FileField, string Destination, [string NameConflict='makeunique'], [string Accept=''], [string Attributes='Normal'], [string Mode='755'])
Facade to upload to a file, returns the cffile variable.

Parameters:
FileField - The name of the form field used to select the file
Destination - The absolute path to the destination.
NameConflict - Action to take if filename is the same as that of a file in the directory.
Accept - Limits the MIME types to accept. Comma-delimited list.
Attributes - Comma-delimitted list of window file attributes
Mode - The mode of the file for Unix systems, the default is 755

ColdBox Platform Version 2.6.3