net.liftweb.util.Helpers

object Helpers

object Helpers

 extends TimeHelpers with StringHelpers with ListHelpers with SecurityHelpers with BindHelpers with HttpHelpers with IoHelpers with BasicTypesHelpers with ControlHelpers


The Helpers object provides a lot of utility functions:


Source: Helpers.scala(34)

 Constructors

def this

 Fields

currentYear.. def currentYear
[details]
return
- the current year
Int TimeHelpers
dateFormatter.. def dateFormatter
[details]
return
- a standard format for the date yyyy/MM/dd
SimpleDateFormat TimeHelpers
dayNow.. def dayNow
[details]
deprecated
- use today instead
return
- the current Day as a Date object
Date TimeHelpers
daysSinceEpoch.. def daysSinceEpoch
[details]
return
- the number of days since epoch
Long TimeHelpers
formattedDateNow.. def formattedDateNow
[details]
return
- today's date formatted as yyyy/MM/dd
String TimeHelpers
formattedTimeNow.. def formattedTimeNow
[details]
return
- now's time formatted as HH:mm zzz
String TimeHelpers
hourFormat.. val hourFormat
[details]
return
- a standard format HH:mm:ss
SimpleDateFormat TimeHelpers
internetDateFormatter.. def internetDateFormatter
[details]
return
- a formatter for internet dates including: the day of week, the month, day of month, time and time zone
SimpleDateFormat TimeHelpers
knownSuffixes.. val knownSuffixes
The list of known suffixes used to split the URI into path parts and suffixes
Set[String] HttpHelpers
makeBlowfishKey.. def makeBlowfishKey
create a Blowfish key as an array of bytes
Array[Byte] SecurityHelpers
makeTripleDESKey.. def makeTripleDESKey
create a 3DES key as an array of bytes
Array[Byte] SecurityHelpers
millis.. def millis
[details]
return
- the current number of millis: System.currentTimeMillis
Long TimeHelpers
nextFuncName.. def nextFuncName
Get a guaranteed unique field name (16 or 17 letters and numbers, starting with a letter)
String HttpHelpers
nextNum.. def nextNum
Get a monotonically increasing number that's guaranteed to be unique for the current session
Long HttpHelpers
now.. def now
[details]
return
- the date object for now
Date TimeHelpers
nowAsInternetDate.. def nowAsInternetDate
[details]
return
- the current time as an internet date
String TimeHelpers
timeFormatter.. def timeFormatter
[details]
return
- a format for the time which includes the TimeZone: HH:mm zzz
SimpleDateFormat TimeHelpers
timeNow.. def timeNow
[details]
deprecated
- use now instead
return
- the current time as a Date object
Date TimeHelpers
today.. def today
[details]
return
- the Calendar object for today (the TimeZone is the local TimeZone). Its time is 00:00:00.000
Calendar TimeHelpers
utc.. val utc
The UTC TimeZone
TimeZone TimeHelpers

 Methods

!=.. final def !=(arg0 : Object) Boolean AnyRef
!=.. final def !=(arg0 : Any) Boolean Any
==.. final def ==(arg0 : Any) Boolean Any
==.. final def ==(arg0 : Object) Boolean AnyRef
^.. def ^[T](i : T*)
This operator transforms its arguments into a List [details]
return
- the list of arguments passed as varargs
List[T] ClassHelpers
appendParams.. def appendParams(url : String, params : Seq[(String, String)])
Append parameters to a URL [details]
param
params - the parameters (name/value) to append to the URL
url - the url to append the params to
return
- the url with the parameters appended
String HttpHelpers
asInstanceOf.. final def asInstanceOf[T0] T0 Any
asInt.. def asInt(in : String)
Safely convert the specified String to an Int
Box[Int] BasicTypesHelpers
asLong.. def asLong(in : Any)
Convert any object to an "equivalent" Long depending on its value
Box[Long] BasicTypesHelpers
asLong.. def asLong(in : String)
Safely convert the specified String to a Long
Box[Long] BasicTypesHelpers
base64Decode.. def base64Decode(in : String)
decode a String in Base 64
Array[Byte] SecurityHelpers
base64Encode.. def base64Encode(in : Array[Byte])
encode a Byte array in Base 64
String SecurityHelpers
bind.. def bind(namespace : String, nodeFailureXform : Box[(NodeSeq) => NodeSeq], paramFailureXform : Box[(PrefixedAttribute) => MetaData], preserveScope : Boolean, xml : NodeSeq, params : BindParam*)
Bind a set of values to parameters and attributes in a block of XML with defined transforms for unbound elements within the specified namespace [details]

For example:

     bind("user",
          Full(xhtml: NodeSeq => Text("Default Value")),
          Empty,
          replace thisreplace with default,
          "hello" -> 

)

will return

Default Value
param
preserveScope: - true if the scope should be preserved, false is the normal setting
params - the list of BindParam bindings to be applied
nodeFailureXform - a box containing the function to use as the default transform for tags in the specified namespace that do not have bindings specified.
paramFailureXform - a box containing the function to use as the default transform for unrecognized attributes in bound elements.
xml - the NodeSeq in which to find elements to be bound.
namespace - the namespace of tags to bind
return
- the NodeSeq that results from the specified transforms
NodeSeq BindHelpers
bind.. def bind(namespace : String, xml : NodeSeq, params : BindParam*)
Bind a set of values to parameters and attributes in a block of XML [details]

For example:

     bind("user", replace this, "hello" -> 

)

will return

param
xml - the NodeSeq in which to find elements to be bound.
params - the list of BindParam bindings to be applied
namespace - the namespace of tags to bind
return
- the NodeSeq that results from the specified transforms
NodeSeq BindHelpers
bind.. def bind(namespace : String, nodeFailureXform : Box[(NodeSeq) => NodeSeq], paramFailureXform : Box[(PrefixedAttribute) => MetaData], xml : NodeSeq, params : BindParam*)
Bind a set of values to parameters and attributes in a block of XML with defined transforms for unbound elements within the specified namespace [details]

For example:

     bind("user",
          Full(xhtml: NodeSeq => Text("Default Value")),
          Empty,
          replace thisreplace with default,
          "hello" -> 

)

will return

Default Value
param
xml - the NodeSeq in which to find elements to be bound.
nodeFailureXform - a box containing the function to use as the default transform for tags in the specified namespace that do not have bindings specified.
paramFailureXform - a box containing the function to use as the default transform for unrecognized attributes in bound elements.
params - the list of BindParam bindings to be applied
namespace - the namespace of tags to bind
return
- the NodeSeq that results from the specified transforms
NodeSeq BindHelpers
bind.. def bind(vals : Map[String, NodeSeq], xml : NodeSeq)
Replace the content of lift:bind nodes with the corresponding nodes found in a map, according to the value of the "name" attribute [details]

Usage:

     bind(Map("a" -> 

), change this) must ==/(

)

param
xml - nodes containing lift:bind nodes
vals - map of name/nodes to replace
return
- the NodeSeq that results from the specified transforms
NodeSeq BindHelpers
bindlist.. def bindlist(listvals : List[Map[String, NodeSeq]], xml : NodeSeq)
Bind a list of name/xml maps to a block of XML containing lift:bind nodes (see the bind(Map, NodeSeq) function) [details]
return
- the NodeSeq that results from the specified transforms
Box[NodeSeq] BindHelpers
blowfishDecrypt.. def blowfishDecrypt(enc : String, key : Array[Byte])
decrypt a Byte array with a Blowfish key (as a SecretKey object)
String SecurityHelpers
blowfishDecrypt.. def blowfishDecrypt(enc : Array[Byte], key : Array[Byte])
decrypt a Byte array with a Blowfish key (as a Byte array)
Array[Byte] SecurityHelpers
blowfishDecrypt.. def blowfishDecrypt(enc : Array[Byte], key : SecretKey)
decrypt a Byte array with a Blowfish key (as a SecretKey object)
Array[Byte] SecurityHelpers
blowfishDecrypt.. def blowfishDecrypt(enc : String, key : SecretKey)
decrypt a Byte array with a Blowfish key (as a SecretKey object)
String SecurityHelpers
blowfishEncrypt.. def blowfishEncrypt(plain : String, key : Array[Byte])
encrypt a String with a Blowfish key (as a Byte array)
String SecurityHelpers
blowfishEncrypt.. def blowfishEncrypt(plain : Array[Byte], key : Array[Byte])
encrypt a Byte array with a Blowfish key (as a Byte array)
Array[Byte] SecurityHelpers
blowfishEncrypt.. def blowfishEncrypt(plain : Array[Byte], key : SecretKey)
encrypt a Byte array with a Blowfish key (as a SecretKey object)
Array[Byte] SecurityHelpers
blowfishEncrypt.. def blowfishEncrypt(plain : String, key : SecretKey)
encrypt a String with a Blowfish key (as a SecretKey object)
String SecurityHelpers
blowfishKeyFromBytes.. def blowfishKeyFromBytes(key : Array[Byte])
create a Blowfish key from an array of bytes
SecretKey SecurityHelpers
boolean2.. implicit def boolean2(b : => Boolean)
Allows an implicit transform from a Boolean to a Boolean2, allowing expressions such as: (1 == 2) ? "a" | "b" (This expression will return "b") [details]
param
b - the predicate to be tested by the ternary operator.
Boolean2 BasicTypesHelpers
boxParseInternetDate.. def boxParseInternetDate(dateString : String)
[details]
return
- a date from a string using the internet format. Return the Epoch date if the parse is unsuccesfull
Box[Date] TimeHelpers
calcTime.. def calcTime[T](f : => T)
[details]
return
- the time taken to evaluate f in millis and the result
(Long, T) TimeHelpers
callableMethod_?.. def callableMethod_?(meth : Method)
[details]
return
- true if the method is public and has no parameters
Boolean ClassHelpers
camelCase.. def camelCase(name : String) String ClassHelpers
camelCaseMethod.. def camelCaseMethod(name : String) String ClassHelpers
camelify.. def camelify(name : String)
Turns a string of format "foo_bar" into camel case "FooBar" Functional code courtesy of Jamie Webb (j@jmawebb [details]
cjb.net) 2006/11/28
param
name - the String to CamelCase
return
- the CamelCased string
String StringHelpers
camelifyMethod.. def camelifyMethod(name : String)
Turn a string of format "foo_bar" into camel case with the first letter in lower case: "fooBar" This function is especially used to camelCase method names [details]
param
name - the String to CamelCase
return
- the CamelCased string
String StringHelpers
capify.. def capify(in : String)
Capitalize every "word" in the string [details]
A word is either separated by spaces or underscores.
param
in - string to capify
return
- the capified string
String StringHelpers
chooseTemplate.. def chooseTemplate(prefix : String, tag : String, xhtml : NodeSeq)
Finds and returns one of many templates from the children based upon the namespace and tag name: for example, for prefix "choose" and tag name "stuff" this would return the contents of the first tag <choose:stuff> [details]
.. </choose:stuff> in the specified NodeSeq.
param
tag - the tag to choose (e.g., "stuff")
xhtml - the node sequence to search for the specified element
prefix - the prefix (e.g., "choose")
return
- the first matching node sequence
NodeSeq BindHelpers
classHasControllerMethod.. def classHasControllerMethod(clz : Class[Any], name : String)
Check that the method 'name' is callable for class 'clz' [details]
param
name - name of the method to test
clz - the class supposed to own the method
return
- true if the method exists on the class and is callable
Boolean ClassHelpers
classHierarchy.. def classHierarchy(in : Class[Any]) List[Class[Any]] ClassHelpers
clean.. def clean(in : String)
Remove all the characters from a string exception a-z, A-Z, 0-9, and '_' [details]
return
- the cleaned string and an empty string if the input is null
String StringHelpers
clone.. protected def clone Object AnyRef
containsClass.. def containsClass[C](clz : Class[C], toMatch : List[Class[Any]])
Is the clz an instance of (assignable from) any of the classes in the list [details]
param
toMatch - the list of classes to match against
clz - the class to test
return
- true if clz is assignable from any of the matching classes
Boolean ClassHelpers
couldBeHtml.. def couldBeHtml(in : Map[String, String])
Given a map of HTTP properties, return true if the "Content-type" value in the map is either "text/html" or "application/xhtml+xml" [details]
param
in - Map which may contain a key named Content-Type
return
- true if there is a pair ("Content-Type", "text/html") or ("Content-Type", "application/xhtml+xml")
Boolean HttpHelpers
createInvoker.. def createInvoker[C <: Object](name : String, on : C)
Create a function (the 'invoker') which will trigger any public, parameterless method That function will throw the cause exception if the method can't be invoked [details]
param
on - instance whose method must be invoked
clz - class whose method should be invoked
return
- Empty if instance is null or Full(invoker)
Box[() => Box[Any]] ClassHelpers
day.. def day(in : Date)
[details]
return
- the day of month corresponding to the input date (1 based)
Int TimeHelpers
days.. def days(in : Long)
[details]
return
- the number of millis corresponding to 'in' days
Long TimeHelpers
decryptStream.. def decryptStream(in : InputStream, key : SecretKey)
decrypt an InputStream with a Blowfish key (as a SecretKey object)
InputStream SecurityHelpers
decryptStream.. def decryptStream(in : InputStream, key : Array[Byte])
decrypt an InputStream with a Blowfish key (as a Byte array)
InputStream SecurityHelpers
decryptXML.. def decryptXML(in : String, key : SecretKey) Box[Node] SecurityHelpers
decryptXML.. def decryptXML(in : String, key : Array[Byte]) Box[Node] SecurityHelpers
deepFindKids.. def deepFindKids(in : NodeSeq, prefix : String, label : String) NodeSeq HttpHelpers
doClose.. def doClose[T](is : Closeable*)(f : => T)
Executes by-name function f and then closes the Cloaseables parameters
T IoHelpers
emptyForNull.. def emptyForNull(s : String)
Test for null and return either the given String if not null or the empty String
String StringHelpers
encryptStream.. def encryptStream(in : InputStream, key : SecretKey)
encrypt an InputStream with a Blowfish key (as a SecretKey object)
InputStream SecurityHelpers
encryptStream.. def encryptStream(in : InputStream, key : Array[Byte])
encrypt an InputStream with a Blowfish key (as a Byte array)
InputStream SecurityHelpers
encryptXML.. def encryptXML(in : Node, key : SecretKey) String SecurityHelpers
encryptXML.. def encryptXML(in : Node, key : Array[Byte]) String SecurityHelpers
enumToList.. def enumToList[T](enum : Enumeration[T])
Convert a java [details]
util.Enumeration to a List[T]
List[T] ListHelpers
enumToStringList.. def enumToStringList[C](enum : Enumeration[C])
Convert a java [details]
util.Enumeration to a List[String] using the toString method on each element
List[String] ListHelpers
eq.. final def eq(arg0 : Object) Boolean AnyRef
equals.. def equals(arg0 : Any) Boolean AnyRef
escChar.. def escChar(in : Char)
Create the unicode value of a character [details]
param
in - character
return
- the unicode value as a string starting by \\u
String StringHelpers
exec.. def exec(cmds : String*)
Execute the specified OS command and return the output of that command in a Full Box if the command succeeds, or a Failure if an error occurs
Box[String] IoHelpers
finalize.. protected def finalize Unit AnyRef
findClass.. def findClass[C <: Object](name : String, where : List[String], modifiers : List[(String) => String], targetType : Class[C])
General method to in find a class according to its name, a list of possible packages, a list of functions modifying the given name create a target name to look for (e [details]
g: 'name' is hello_world and the target name may be 'HelloWorld'). @parameter name name of the class to find @parameter where list of package names which may contain the class @parameter modifiers list of functions that modify the 'name' of the class (e.g., leave it alone, make it camel case, etc.) @parameter targetType optional expected type which the retrieved class should conform to
return
- a Box, either containing the found class or an Empty can.
Box[Class[C]] ClassHelpers
findClass.. def findClass(name : String, where : List[String], modifiers : List[(String) => String])
General method to in find a class according to its name, a list of possible packages and a list of functions modifying the given name create a target name to look for (e [details]
g: 'name' is hello_world and the target name may be 'HelloWorld'). @parameter name name of the class to find @parameter where list of package names which may contain the class @parameter modifiers list of functions that modify the 'name' of the class (e.g., leave it alone, make it camel case, etc.)
return
- a Box, either containing the found class or an Empty can.
Box[Class[Object]] ClassHelpers
findClass.. def findClass(where : List[(String, List[String])])
Find a class given a list of possible names and corresponding packages, turning underscored names to CamelCase if necessary @parameter where list of pairs (name, package names) which may contain the class [details]
return
- a Box, either containing the found class or an Empty can.
Box[Class[Object]] ClassHelpers
findClass.. def findClass[C <: Object](name : String, where : List[String], targetType : Class[C])
Find a class given its name and a list of packages, turning underscored names to CamelCase if necessary [details]
@parameter name name of the class to find @parameter where list of package names which may contain the class @parameter targetType optional expected type which the retrieved class should conform to
return
- a Box, either containing the found class or an Empty can.
Box[Class[C]] ClassHelpers
findClass.. def findClass(name : String, where : List[String])
Find a class given its name and a list of packages, turning underscored names to CamelCase if necessary [details]
@parameter name name of the class to find @parameter where list of package names which may contain the class
return
- a Box, either containing the found class or an Empty can.
Box[Class[Object]] ClassHelpers
findElems.. def findElems(nodes : NodeSeq)(f : (Elem) => Boolean)
Find the elements of the specified NodeSeq that match the specified predicate and concatenate them into a resulting NodeSeq [details]
param
f - - the predicate to match elements with
nodes - - the NodeSeq to search for elements matching the predicate
return
- the NodeSeq resulting from concatenation of the matched elements.
NodeSeq HttpHelpers
findInElems.. def findInElems[T](nodes : NodeSeq)(f : (Elem) => Iterable[T])
Map the specified function over the elements of the specified NodeSeq and return the concatenated result [details]
This is essentially a container-type-transforming flatMap operation.
List[T] HttpHelpers
findKids.. def findKids(in : NodeSeq, prefix : String, label : String) NodeSeq HttpHelpers
findNode.. def findNode(in : Elem, nodes : NodeSeq)
Finds and returns the first node in the specified NodeSeq and its children with the same label and prefix as the specified element
Box[Elem] BindHelpers
findOrAddId.. def findOrAddId(in : Elem)
If the specified Elem has an attribute named 'id', return it, otherwise construct a new Elem with a randomly generated id attribute and return the pair [details]
param
in - the element to test & add 'id' to
return
- the new element and the id
(Elem, String) HttpHelpers
findType.. def findType[C <: Object](name : String, where : List[String])(implicit m : Manifest[C])
Find a class given its type, its name and a list of packages, turning underscored names to CamelCase if necessary [details]
@parameter C type of the class to find @parameter name name of the class to find @parameter where list of package names which may contain the class
return
- a Box, either containing the found class or an Empty can.
Box[Class[C]] ClassHelpers
findType.. def findType[C <: Object](where : List[(String, List[String])])(implicit m : Manifest[C])
Find a class given its type, a list of possible names and corresponding packages, turning underscored names to CamelCase if necessary @parameter C type of the class to find @parameter where list of pairs (name, package names) which may contain the class [details]
return
- a Box, either containing the found class or an Empty can.
Box[Class[C]] ClassHelpers
findType.. def findType[C <: Object](name : String, where : List[String], modifiers : List[(String) => String])(implicit m : Manifest[C])
General method to in find a class according to its type, its name, a list of possible packages and a list of functions modifying the given name create a target name to look for (e [details]
g: 'name' is hello_world and the target name may be 'HelloWorld'). @parameter C type of the class to find @parameter name name of the class to find @parameter where list of package names which may contain the class @parameter modifiers list of functions that modify the 'name' of the class (e.g., leave it alone, make it camel case, etc.)
return
- a Box, either containing the found class or an Empty can.
Box[Class[C]] ClassHelpers
first.. def first[B, C](in : Seq[B])(_f : (B) => Box[C])
Returns the first application of f to an element of in that results in a Full can [details]
If f applied to an element of in results in an Empty can, then f will be applied to the rest of the elements of in until a Full can results. If the list runs out then an Empty can is returned.
param
f - a function that can be applied to elements of in
in - a list of elements to which f can be applied
return
- a Box containing the first Full can or Empty if f never returns a Full can
Box[C] ListHelpers
first_?.. def first_?[B](in : Seq[B])(f : => (B) => Boolean)
Returns a Full can with the first element x of the list in for which f(x) evaluates to true [details]
If f(x) evaluates to false for every x, then an Empty can is returned.
param
f - a function that can be applied to elements of in
in - a list of elements to which f can be applied
return
- a Box containing the found element (or Empty if not found)
Box[B] ListHelpers
getClass.. final def getClass Class[Any] AnyRef
hash.. def hash(in : String)
create a SHA hash from a String
String SecurityHelpers
hash.. def hash(in : Array[Byte])
create a SHA hash from a Byte array
Array[Byte] SecurityHelpers
hash256.. def hash256(in : Array[Byte])
create a SHA-256 hash from a Byte array
Array[Byte] SecurityHelpers
hash256.. def hash256(in : String)
create a SHA-256 hash from a String
String SecurityHelpers
hashCode.. def hashCode Int AnyRef
hashHex.. def hashHex(in : String)
create a SHA hash from a String
String SecurityHelpers
head.. def head[T](l : Seq[T], deft : => T)
Return the first element of a List or a default value if the list is empty
T ListHelpers
hexDecode.. def hexDecode(str : String) Array[Byte] SecurityHelpers
hexDigest.. def hexDigest(in : Array[Byte])
create an hex encoded SHA hash from a Byte array
String SecurityHelpers
hexDigest256.. def hexDigest256(in : Array[Byte])
create an hex encoded SHA-256 hash from a Byte array
String SecurityHelpers
hexEncode.. def hexEncode(in : Array[Byte])
encode a Byte array as hexadecimal characters
String SecurityHelpers
hourFormat.. def hourFormat(in : Date)
[details]
return
- the formatted time for a given Date
String TimeHelpers
hours.. def hours(in : Long)
[details]
return
- the number of millis corresponding to 'in' hours
Long TimeHelpers
instantiate.. def instantiate[C](clz : Class[C])
Create a new instance of a class [details]
return
- a Full can with the instance or a Failure if the instance can't be created
Box[C] ClassHelpers
insureField.. def insureField(toInsure : List[(String, String)], headers : List[(String, String)])
Ensure that all the appropriate fields are in the header
List[(String, String)] HttpHelpers
intToTimeSpan.. implicit def intToTimeSpan(in : Int)
transforms an int to a TimeSpan object [details]
Usage: 3000 returns a TimeSpan of 3000L millis
TimeSpan TimeHelpers
intToTimeSpanBuilder.. implicit def intToTimeSpanBuilder(in : Int)
transforms an int to a TimeSpanBuilder object [details]
Usage: 3.seconds returns a TimeSpan of 3000L millis
TimeSpanBuilder TimeHelpers
invokeControllerMethod.. def invokeControllerMethod(clz : Class[Any], meth : String)
Invoke a controller method (parameterless, public) on a class [details]
param
name - name of the method to invoke
clz - the class owning the method
return
- the result of the method invocation or throws the root exception causing an error
Any ClassHelpers
invokeMethod.. def invokeMethod[C](clz : Class[C], inst : Object, meth : String, params : Array[Object])
Invoke the given method for the given class, with some parameters [details]
Tries the method name, then the method as a CamelCased name and the method as a camelCased name The class is not instanciated if the method is static, otherwise the passed instance is used
param
params - parameters to pass to the method
inst - instance of the class who method should be invoked, if the method is not static
meth - method to invoke
clz - class whose method should be invoked
return
- a Box containing the value returned by the method
Box[Any] ClassHelpers
invokeMethod.. def invokeMethod[C](clz : Class[C], inst : Object, meth : String)
Invoke the given method for the given class, with no params [details]
The class is not instanciated if the method is static, otherwise the passed instance is used
param
inst - instance of the class who method should be invoked, if the method is not static
meth - method to invoke
clz - class whose method should be invoked
return
- a Box containing the value returned by the method
Box[Any] ClassHelpers
invokeMethod.. def invokeMethod[C](clz : Class[C], inst : Object, meth : String, params : Array[Object], ptypes : Array[Class[Any]])
Invoke the given method for the given class, with some parameters and their types Tries the method name, then the method as a CamelCased name and the method as a camelCased name The class is not instanciated if the method is static, otherwise the passed instance is used [details]
param
params - parameters to pass to the method
inst - instance of the class who method should be invoked, if the method is not static
meth - method to invoke
ptypes - list of types of the parameters
clz - class whose method should be invoked
return
- a Box containing the value returned by the method
Box[Any] ClassHelpers
isEq.. def isEq(a : Array[Byte], b : Array[Byte])
Compare two arrays of Byte for byte equality [details]
return
- true if two Byte arrays contain the same bytes
Boolean BasicTypesHelpers
isInstanceOf.. final def isInstanceOf[T0] Boolean Any
listIf.. def listIf[T](expr : Boolean)(f : => T)
Return a list containing the element f if the expression is true
List[T] ListHelpers
listToListMapish.. implicit def listToListMapish(in : Seq[(String, String)])
adds the ciGet method to a List of Pairs of Strings
ListMapish ListHelpers
logTime.. def logTime[T](msg : String)(f : => T)
Log a message with the time taken in millis to do something and retrun the result [details]
return
- the result
T TimeHelpers
longToTimeSpan.. implicit def longToTimeSpan(in : Long)
transforms a long to a TimeSpan object [details]
Usage: 3000L returns a TimeSpan of 3000L millis
TimeSpan TimeHelpers
longToTimeSpanBuilder.. implicit def longToTimeSpanBuilder(in : Long)
transforms a long to a TimeSpanBuilder object [details]
Usage: 3L.seconds returns a TimeSpan of 3000L millis
TimeSpanBuilder TimeHelpers
md5.. def md5(in : String)
create a MD5 digest from a String
String SecurityHelpers
md5.. def md5(in : Array[Byte])
create a MD5 digest from a Byte array
Array[Byte] SecurityHelpers
millisToDays.. def millisToDays(millis : Long)
[details]
return
- the number of days since epoch converted from millis
Long TimeHelpers
minutes.. def minutes(in : Long)
[details]
return
- the number of millis corresponding to 'in' minutes
Long TimeHelpers
mixinAttributes.. def mixinAttributes(out : Elem)(in : NodeSeq)
Takes attributes from the first node of 'in' (if any) and mixes them into 'out' [details]
Curried form can be used to produce a NodeSeq => NodeSeq for bind.
param
out - where to put the attributes
in - where to take the attributes from
return
- 'out' element with attributes from 'in'
NodeSeq BindHelpers
month.. def month(in : Date)
[details]
return
- the month corresponding to today (0 based, relative to UTC)
Int TimeHelpers
ne.. final def ne(arg0 : Object) Boolean AnyRef
nextFuncName.. def nextFuncName(seed : Long)
Get a guaranteed unique field name (16 or 17 letters and numbers, starting with a letter)
String HttpHelpers
noHtmlTag.. def noHtmlTag(in : NodeSeq)
Return true if the xml doesn't contain an <html> tag
Boolean HttpHelpers
nodeSeqToOptionString.. implicit def nodeSeqToOptionString(in : NodeSeq)
[details]
return
- an Empty can if the node seq is empty and a full can with the NodeSeq text otherwise
Box[String] StringHelpers
notEq.. def notEq(a : Array[Byte], b : Array[Byte])
Compare two arrays of Byte for byte equality [details]
return
- true if two Byte arrays don't contain the same bytes
Boolean BasicTypesHelpers
notify.. final def notify Unit AnyRef
notifyAll.. final def notifyAll Unit AnyRef
pairToUnprefixed.. implicit def pairToUnprefixed(in : (String, Any))
Transform a pair (name: String, value: Any) to an unprefixed XML attribute name="value"
MetaData HttpHelpers
paramsToUrlParams.. def paramsToUrlParams(params : List[(String, String)])
Take a list of name/value parse and turn them into a URL query string [details]
param
params - the name/value pairs
return
- a valid query string
String HttpHelpers
parseInternetDate.. def parseInternetDate(dateString : String)
[details]
return
- a date from a string using the internet format. Return the Epoch date if the parse is unsuccesfull
Date TimeHelpers
parseNumber.. def parseNumber(tin : String)
Parse a string and return the Long value of that string [details]

The string can start with '-' if it is a negative number or '+' for a positive number

return
- the Long value of the input String
Long StringHelpers
permuteList.. def permuteList[T](in : Seq[T])
Given a list, return all the permutations of the list [details]
param
in - -- the list
return
- all the permutations of the list
List[List[T]] ListHelpers
permuteWithSublists.. def permuteWithSublists[T](in : Seq[T])
Given a list, return all the permutations including the removal of items (does not return a Nil list unless in is Nil) [details]
param
in - the list to permute
return
- all the permutations of the list including sublists, sorted in longest to shortest
List[List[T]] ListHelpers
processBind.. def processBind(around : NodeSeq, atWhat : Map[String, NodeSeq])
Bind parameters to XML [details]
deprecated
- use the bind function instead
param
atWhat - data to bind
around - XML with lift:bind elements
NodeSeq BindHelpers
processString.. def processString(msg : String, subst : Map[String, String])
Replaces the value found in a string surrounded by <%= [details]
.. %> by a replacement according to the value found in the subst Map.

Throws an exception if no correspondance can be found.

param
subst - map of [regular expression with groups, replacement]
msg - string where replacements should be done
String StringHelpers
randomInt.. def randomInt(mod : Int)
return a random int modulo a number
Int SecurityHelpers
randomLong.. def randomLong(mod : Long)
return a random Long modulo a number
Long SecurityHelpers
randomString.. def randomString(size : Int)
Create a random string of a given size [details]
param
size - size of the string to create. Must be a positive or nul integer
return
- the generated string
String StringHelpers
readWholeFile.. def readWholeFile(file : File)
Read an entire file into an Array[Byte]
Array[Byte] IoHelpers
readWholeStream.. def readWholeStream(in : InputStream)
Read all data from a stream into an Array[Byte]
Array[Byte] IoHelpers
readWholeThing.. def readWholeThing(in : Reader)
Read all data to the end of the specified Reader and concatenate the resulting data into a string
String IoHelpers
rotateList.. def rotateList[T](in : Seq[T])
Given an incoming list, return a set of lists that is the original list rotated through all its positions [details]
param
in - the list to rotate
return
- all the rotations of the list
List[List[T]] ListHelpers
seconds.. def seconds(in : Long)
[details]
return
- the number of millis corresponding to 'in' seconds
Long TimeHelpers
shouldShow.. def shouldShow(percent : Double)
return true only 'percent' times when asked repeatedly [details]
This function is used in the Skittr example to get a random set of users
param
percent - percentage as a double number <= 1.0
Boolean SecurityHelpers
snakify.. def snakify(name : String)
Turn a string of format "FooBar" into snake case "foo_bar" Note: snakify is not reversible, ie [details]
in general the following will _not_ be true: s == camelify(snakify(s))
return
- the underscored string
String StringHelpers
splitColonPair.. def splitColonPair(in : String, first : String, second : String)
Split a string separated by a point or by a column in 2 parts [details]
Uses default values if only one is found or if no parts are found
param
first - default value for the first part if no split can be done
second - default value for the second part if one or less parts can be found
in - string to split
return
- a pair containing the first and second parts
(String, String) StringHelpers
splitNameValuePairs.. def splitNameValuePairs(props : String)
Splits a string of the form <name1=value1, name2=value2, [details]
.. > and unquotes the quoted values. The result is a Map[String, String]
Map[String, String] StringHelpers
strToBPAssoc.. implicit def strToBPAssoc(in : String)
transforms a String to a BindParamAssoc object which can be associated to a BindParam object using the --> operator [details]

Usage: "David" --> "name"

deprecated
- use -> instead
BindParamAssoc BindHelpers
strToSuperArrowAssoc.. implicit def strToSuperArrowAssoc(in : String) SuperArrowAssoc BindHelpers
stringToSuper.. implicit def stringToSuper(in : String)
[details]
return
- a SuperString with more available methods such as roboSplit or commafy
SuperString StringHelpers
stripHead.. def stripHead(in : NodeSeq)
Remove all the tags, just leaving the child tags
NodeSeq BindHelpers
symToBPAssoc.. implicit def symToBPAssoc(in : Symbol)
transforms a Symbol to a BindParamAssoc object which can be associated to a BindParam object using the --> operator [details]

Usage: 'David --> "name"

deprecated
- use -> instead
BindParamAssoc BindHelpers
synchronized.. final def synchronized[T0](arg0 : T0) T0 AnyRef
template.. def template(xhtml : NodeSeq, prefix : String, tag1 : String, tag2 : String, tag3 : String)
Find three of many templates from the children
Box[(NodeSeq, NodeSeq, NodeSeq)] BindHelpers
template.. def template(xhtml : NodeSeq, prefix : String, tag : String)
Similar to chooseTemplate, this returns the contents of the element in a Full Box if found or an Empty Box otherwise
Box[NodeSeq] BindHelpers
template.. def template(xhtml : NodeSeq, prefix : String, tag1 : String, tag2 : String)
Find two of many templates from the children
Box[(NodeSeq, NodeSeq)] BindHelpers
time.. def time(when : Long)
alias for new Date(millis)
Date TimeHelpers
toBoolean.. def toBoolean(in : Any)
Convert any object to an "equivalent" Boolean depending on its value
Boolean BasicTypesHelpers
toByteArrayInputStream.. def toByteArrayInputStream(in : InputStream)
Convert any InputStream to a ByteArrayInputStream
ByteArrayInputStream BasicTypesHelpers
toCalendarExtension.. implicit def toCalendarExtension(c : Calendar)
implicit def used to add the setXXX methods to the Calendar class
CalendarExtension TimeHelpers
toDate.. def toDate(in : Any)
[details]
return
- a Full(date) or a failure if the input couldn't be translated to date (or Empty if the input is null)
Box[Date] TimeHelpers
toDateExtension.. implicit def toDateExtension(d : Date)
implicit def used to add the noTime method to the Date class
DateExtension TimeHelpers
toHashMap.. def toHashMap[A, B](in : Map[A, B])
Transform a general Map to a nutable HashMap
HashMap[A, B] HttpHelpers
toInt.. def toInt(in : Any)
Convert any object to an "equivalent" Int depending on its value
Int BasicTypesHelpers
toInternetDate.. def toInternetDate(in : Long)
[details]
return
- a date formatted with the internet format (from a number of millis)
String TimeHelpers
toInternetDate.. def toInternetDate(in : Date)
[details]
return
- a date formatted with the internet format
String TimeHelpers
toLong.. def toLong(in : Any)
Convert any object to an "equivalent" Long depending on its value
Long BasicTypesHelpers
toOptiCons.. implicit def toOptiCons(expr : => Boolean)
Implicit transformation from a Boolean expression to an OptionalCons object so that an element can be added to a list if the expression is true
OptionalCons BasicTypesHelpers
toString.. def toString String AnyRef
toSuperList.. implicit def toSuperList[T](in : List[T])
Add utility methods to Lists
SuperList[T] ListHelpers
tripleDESDDecryptStream.. def tripleDESDDecryptStream(in : InputStream, key : Array[Byte])
decrypt an InputStream with a Blowfish key (as a Byte array)
InputStream SecurityHelpers
tripleDESDecrypt.. def tripleDESDecrypt(enc : Array[Byte], key : SecretKey)
decrypt a Byte array with a Blowfish key (as a SecretKey object)
Array[Byte] SecurityHelpers
tripleDESDecrypt.. def tripleDESDecrypt(enc : String, key : SecretKey)
decrypt a Byte array with a Blowfish key (as a SecretKey object)
String SecurityHelpers
tripleDESDecrypt.. def tripleDESDecrypt(enc : Array[Byte], key : Array[Byte])
decrypt a Byte array with a Blowfish key (as a Byte array)
Array[Byte] SecurityHelpers
tripleDESDecrypt.. def tripleDESDecrypt(enc : String, key : Array[Byte])
decrypt a Byte array with a Blowfish key (as a SecretKey object)
String SecurityHelpers
tripleDESDecryptStream.. def tripleDESDecryptStream(in : InputStream, key : SecretKey)
decrypt an InputStream with a Blowfish key (as a SecretKey object)
InputStream SecurityHelpers
tripleDESEncrypt.. def tripleDESEncrypt(plain : Array[Byte], key : SecretKey)
encrypt a Byte array with a Blowfish key (as a SecretKey object)
Array[Byte] SecurityHelpers
tripleDESEncrypt.. def tripleDESEncrypt(plain : String, key : SecretKey)
encrypt a String with a Blowfish key (as a SecretKey object)
String SecurityHelpers
tripleDESEncrypt.. def tripleDESEncrypt(plain : Array[Byte], key : Array[Byte])
encrypt a Byte array with a Blowfish key (as a Byte array)
Array[Byte] SecurityHelpers
tripleDESEncrypt.. def tripleDESEncrypt(plain : String, key : Array[Byte])
encrypt a String with a Blowfish key (as a Byte array)
String SecurityHelpers
tripleDESEncryptStream.. def tripleDESEncryptStream(in : InputStream, key : SecretKey)
encrypt an InputStream with a Blowfish key (as a SecretKey object)
InputStream SecurityHelpers
tripleDESEncryptStream.. def tripleDESEncryptStream(in : InputStream, key : Array[Byte])
encrypt an InputStream with a Blowfish key (as a Byte array)
InputStream SecurityHelpers
tripleDESKeyFromBytes.. def tripleDESKeyFromBytes(key : Array[Byte])
create a Blowfish key from an array of bytes
SecretKey SecurityHelpers
tryo.. def tryo[T](onError : (Throwable) => Unit)(f : => T)
Wraps a "try" block around the function f and trigger a callback function if an exception is thrown [details]
param
f - - the block of code to evaluate
onError - - an optional callback function that will use the thrown exception as a parameter
return
-
  • Full(result of the evaluation of f) if f doesn't throw any exception
  • a Failure if f throws an exception
Box[T] ControlHelpers
tryo.. def tryo[T](ignore : Class[Any])(f : => T)
Wraps a "try" block around the function f [details]
Takes only one Class of exception to ignore
param
f - - the block of code to evaluate
ignore - - a single exception classes to ignore. A thrown exception will be ignored if it is assignable from this class.
return
-
  • Full(result of the evaluation of f) if f doesn't throw any exception
  • a Failure if f throws an exception
  • Empty if the exception class is in the ignore list
Box[T] ControlHelpers
tryo.. def tryo[T](handler : PartialFunction[Throwable, T], f : => T)
Wraps a "try" block around the function f [details]
If f throws an exception with its class in the 'ignore' list or if 'ignore' is null or an empty list, ignore the exception and return None.
param
f - - the block of code to evaluate
handler - - A partial function that handles exceptions
return
-
  • Full(result of the evaluation of f) if f doesn't throw any exception
  • a Failure if f throws an exception
Box[T] ControlHelpers
tryo.. def tryo[T](f : => T)
Wraps a "try" block around the function f [details]
param
f - - the block of code to evaluate
return
-
  • Full(result of the evaluation of f) if f doesn't throw any exception
  • a Failure if f throws an exception
Box[T] ControlHelpers
tryo.. def tryo[T](ignore : List[Class[Any]])(f : => T)
Wraps a "try" block around the function f [details]
param
f - - the block of code to evaluate
ignore - - a list of exception classes to ignore. A thrown exception will be ignored if it is assignable from one of the exception classes in the list
return
-
  • Full(result of the evaluation of f) if f doesn't throw any exception
  • a Failure if f throws an exception
  • Empty if the exception class is in the ignore list
Box[T] ControlHelpers
tryo.. def tryo[T](ignore : List[Class[Any]], onError : Box[(Throwable) => Unit])(f : => T)
Wraps a "try" block around the function f [details]
If f throws an exception with its class in the 'ignore' list or if 'ignore' is null or an empty list, ignore the exception and return None.
param
onError - - an optional callback function that will use the thrown exception as a parameter
f - - the block of code to evaluate
ignore - - a list of exception classes to ignore. A thrown exception will be ignored if it is assignable from one of the exception classes in the list
return
-
  • Full(result of the evaluation of f) if f doesn't throw any exception
  • a Failure if f throws an exception
  • Empty if the exception class is in the ignore list
Box[T] ControlHelpers
unCamelCase.. def unCamelCase(name : String) String ClassHelpers
unquote.. def unquote(str : String)
If str is surrounded by quotes it return the content between the quotes
String StringHelpers
urlDecode.. def urlDecode(in : String)
URL decode the string [details]
This is a pass-through to Java's URL decode with UTF-8
String HttpHelpers
urlEncode.. def urlEncode(in : String)
URL encode the string [details]
This is a pass-through to Java's URL encode with UTF-8
String HttpHelpers
wait.. final def wait(arg0 : Long, arg1 : Int) Unit AnyRef
wait.. final def wait Unit AnyRef
wait.. final def wait(arg0 : Long) Unit AnyRef
weeks.. def weeks(in : Long)
[details]
return
- the number of millis corresponding to 'in' weeks
Long TimeHelpers
xbind.. def xbind(namespace : String, xml : NodeSeq)(transform : PartialFunction[String, (NodeSeq) => NodeSeq])
Experimental extension to bind which passes in an additional "parameter" from the XHTML to the transform function, which can be used to format the returned NodeSeq [details]
deprecated
- use bind instead
NodeSeq BindHelpers
xmlParam.. def xmlParam(in : NodeSeq, param : String)
Finds the named attribute in specified XML element and returns a Full Box containing the value of the attribute if found [details]
Empty otherwise.
return
- a Full Box containing the value of the attribute if found; Empty otherwise
Box[String] BindHelpers
year.. def year(in : Date)
[details]
return
- the year corresponding to today (relative to UTC)
Int TimeHelpers
Copyright (c) 2006-2010 WorldWide Conferencing, LLC. All Rights Reserved.