alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Lift Framework example source code file (Helpers.scala)

This example Lift Framework source code file (Helpers.scala) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Lift Framework tags/keywords

basictypeshelpers, classhelpers, helpers, httphelpers, iohelpers, iohelpers, liftflowofcontrolexception, liftflowofcontrolexception, listhelpers, node, none, seq, stringhelpers, timehelpers

The Lift Framework Helpers.scala source code

/*
 * Copyright 2006-2011 WorldWide Conferencing, LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.liftweb
package util

import scala.xml._

/**
 * The Helpers object provides a lot of utility functions:<ul>
 * <li>Time and date
 * <li>URL
 * <li>Hash generation
 * <li>Class instantiation
 * <li>Control abstractions
 * <li>Basic types conversions
 * <li>XML bindings
 * </ul>
 */

object Helpers extends TimeHelpers with StringHelpers with ListHelpers
with SecurityHelpers with BindHelpers with HttpHelpers
with IoHelpers with BasicTypesHelpers
with ClassHelpers with ControlHelpers
{

}

/**
 * Used for type-safe pattern matching of an Any and returns a Seq[Node]
 */
object SafeNodeSeq {
  // I didn't use unapplySeq as I ran into a compiler(2.7.1 final) crash at LiftRules#convertResponse.
  // I opened the scala ticket https://lampsvn.epfl.ch/trac/scala/ticket/1059#comment:1
  def unapply(any: Any) : Option[Seq[Node]] = any match {
    case s: Seq[_] =>  Some(s flatMap ( _ match {
            case n: Node => n
            case _ => NodeSeq.Empty
          }))
    case _ => None
  }
}

/**
 * The superclass for all Lift flow of control exceptions
 */
class LiftFlowOfControlException(msg: String) extends RuntimeException(msg)

Other Lift Framework examples (source code examples)

Here is a short list of links related to this Lift Framework Helpers.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.