org.cert.cc.util
Class NullSafe

java.lang.Object
  extended by org.cert.cc.util.NullSafe

public final class NullSafe
extends Object

NullSafe is a collection of null and thread safe static methods.

© 2010 Carnegie Mellon University

Author:
Steve Scholnick

Method Summary
static Calendar clone(Calendar input)
          Creates a new Calendar from an existing one
static boolean equals(Object o1, Object o2)
          Returns if two objects are equals.
static Calendar incrementDays(Calendar input, int numberOfDays)
          Increments input Calendar the number of days specified.
static Calendar incrementDays(Date d, int numberOfDays)
          Increments input Date the number of days specified.
static boolean isDigitsOnly(String s)
          Returns if the String contains only digits.
static boolean isEmpty(String s)
          Returns if a String is empty.
static boolean isWeekend(Calendar c)
          Returns if the Calendar's current day is a weekend day
static boolean toBoolean(String s)
          Returns a boolean created from a String.
static String trim(String s)
          Returns a trimmed String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

incrementDays

public static Calendar incrementDays(Calendar input,
                                     int numberOfDays)
Increments input Calendar the number of days specified. Weekend days are skipped. The original Calendar is not changed.

Parameters:
input - Input Calendar
numberOfDays - Number of days
Returns:
Newly incremented Calendar

incrementDays

public static Calendar incrementDays(Date d,
                                     int numberOfDays)
Increments input Date the number of days specified. Weekend days are skipped. The original Date is not changed.

Parameters:
input - Input Date
numberOfDays - Number of days
Returns:
Newly incremented Calendar

clone

public static Calendar clone(Calendar input)
Creates a new Calendar from an existing one


isWeekend

public static boolean isWeekend(Calendar c)
Returns if the Calendar's current day is a weekend day


isEmpty

public static boolean isEmpty(String s)
Returns if a String is empty. An empty String is defined as:

Parameters:
s - Input String
Returns:
Is empty?

isDigitsOnly

public static boolean isDigitsOnly(String s)
Returns if the String contains only digits. An empty String will return null


trim

public static String trim(String s)
Returns a trimmed String. null input returns a null

Parameters:
s - String
Returns:
trimmed String

equals

public static boolean equals(Object o1,
                             Object o2)
Returns if two objects are equals. If both objects are null, they are considered equal and true is returned.

Parameters:
o1 - first object
o2 - second object
Returns:
equality

toBoolean

public static boolean toBoolean(String s)
Returns a boolean created from a String. If the String is empty, false is returned. yes, true, and 1 are all considered true; everything else is false. The check is case-insensitive.

Parameters:
s - String
Returns:
boolean


Copyright © 2012 Carnegie Mellon University