org.apache.myfaces.custom.schedule.util
Class ScheduleUtil

java.lang.Object
  extended by org.apache.myfaces.custom.schedule.util.ScheduleUtil

public class ScheduleUtil
extends Object

Some utility methods

Version:
$Revision: 387334 $
Author:
Jurgen Lust (latest modification by $Author: jlust $), Kito Mann (some methods taken from the source code of his book 'JavaServer Faces in Action', which is also released under the Apache License, Bruno Aranda (adaptation of Jurgen's code to myfaces)

Method Summary
static boolean areEquivalentIntervals(TreeSet intervals1, TreeSet intervals2)
           Check if two sets of intervals are equivalent.
static boolean canModifyValue(javax.faces.component.UIComponent component)
           Check if the value of the given component can be modified
static int compareDays(Date date1, Date date2, TimeZone tz)
           Compare 2 dates after truncating them.
static boolean getBooleanProperty(javax.faces.component.UIComponent component, Boolean property, String key, boolean defaultValue)
           Get the boolean value of a UIComponent, even if it is a value binding expression.
static boolean getBooleanValue(Object attributeValue, boolean valueIfNull)
           Get the boolean value of an attribute
static Calendar getCalendarInstance(Date date, TimeZone timeZone)
           
static Date getDateFromId(String id, TimeZone timeZone)
          get a date from the given date ID
static String getDateId(Date date, TimeZone timeZone)
          get a String identifying this date
static float getFloatProperty(javax.faces.component.UIComponent component, Float property, String key, float defaultValue)
           Get the float value of a UIComponent, even if it is a value binding expression.
static int getHashCodeForDay(Date date, TimeZone tz)
           Get the hashcode for the truncated date
static int getIntegerProperty(javax.faces.component.UIComponent component, Integer property, String key, int defaultValue)
           Get the int value of a UIComponent, even if it is a value binding expression.
static Object getObjectProperty(javax.faces.component.UIComponent component, Object property, String key, Object defaultValue)
           Get the object value of a UIComponent, even if it is a value binding expression.
static String getStringProperty(javax.faces.component.UIComponent component, String property, String key, String defaultValue)
           Get the String value of a UIComponent, even if it is a value binding expression.
static boolean isBindingExpression(Object value)
           Check if the value of a UIComponent is a value or method binding expression.
static boolean isSameDay(Date date1, Date date2, TimeZone tz)
           Check if the 2 dates are in the same day.
static boolean isSameTime(Date date1, Date date2)
           Check if the 2 dates are at the same time of day.
static Date truncate(Date date, TimeZone tz)
          truncate the given Date to 00:00:00 that same day
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isBindingExpression

public static boolean isBindingExpression(Object value)

Check if the value of a UIComponent is a value or method binding expression.

Parameters:
value - the value to check
Returns:
whether the value is a binding expression

getBooleanProperty

public static boolean getBooleanProperty(javax.faces.component.UIComponent component,
                                         Boolean property,
                                         String key,
                                         boolean defaultValue)

Get the boolean value of a UIComponent, even if it is a value binding expression.

Parameters:
component - the component
property - the property
key - the key of the value binding
defaultValue - the default value
Returns:
the boolean value

getBooleanValue

public static boolean getBooleanValue(Object attributeValue,
                                      boolean valueIfNull)

Get the boolean value of an attribute

Parameters:
attributeValue - the attribute value
valueIfNull - the default value
Returns:
the boolean value

getFloatProperty

public static float getFloatProperty(javax.faces.component.UIComponent component,
                                     Float property,
                                     String key,
                                     float defaultValue)

Get the float value of a UIComponent, even if it is a value binding expression.

Parameters:
component - the component
property - the property
key - the key of the value binding
defaultValue - the default value
Returns:
the float value

getHashCodeForDay

public static int getHashCodeForDay(Date date,
                                    TimeZone tz)

Get the hashcode for the truncated date

Parameters:
date - the date
Returns:
the hashCode of the truncated date

getIntegerProperty

public static int getIntegerProperty(javax.faces.component.UIComponent component,
                                     Integer property,
                                     String key,
                                     int defaultValue)

Get the int value of a UIComponent, even if it is a value binding expression.

Parameters:
component - the component
property - the property
key - the key of the value binding
defaultValue - the default value
Returns:
the int value

getObjectProperty

public static Object getObjectProperty(javax.faces.component.UIComponent component,
                                       Object property,
                                       String key,
                                       Object defaultValue)

Get the object value of a UIComponent, even if it is a value binding expression.

Parameters:
component - the component
property - the property
key - the key of the value binding
defaultValue - the default value
Returns:
the object value

isSameDay

public static boolean isSameDay(Date date1,
                                Date date2,
                                TimeZone tz)

Check if the 2 dates are in the same day.

Parameters:
date1 - the first date
date2 - the second date
Returns:
whether the dates are in the same day

isSameTime

public static boolean isSameTime(Date date1,
                                 Date date2)

Check if the 2 dates are at the same time of day.

Parameters:
date1 - the first date
date2 - the second date
Returns:
whether the dates are at the same time of day

areEquivalentIntervals

public static boolean areEquivalentIntervals(TreeSet intervals1,
                                             TreeSet intervals2)

Check if two sets of intervals are equivalent. Intervals are equivalent if their label is the same and they begin and end at the same time of day.

Parameters:
intervals1 - the first set of intervals
intervals2 - the second set of intervals
Returns:
whether the dates are at the same time of day

getStringProperty

public static String getStringProperty(javax.faces.component.UIComponent component,
                                       String property,
                                       String key,
                                       String defaultValue)

Get the String value of a UIComponent, even if it is a value binding expression.

Parameters:
component - the component
property - the property
key - the key of the value binding
defaultValue - the default value
Returns:
the String value

canModifyValue

public static boolean canModifyValue(javax.faces.component.UIComponent component)

Check if the value of the given component can be modified

Parameters:
component - the component
Returns:
whether the value can be modified

compareDays

public static int compareDays(Date date1,
                              Date date2,
                              TimeZone tz)

Compare 2 dates after truncating them.

Parameters:
date1 - the first date
date2 - the second date
Returns:
the comparison

truncate

public static Date truncate(Date date,
                            TimeZone tz)
truncate the given Date to 00:00:00 that same day

Parameters:
date - the date that should be truncated
Returns:
the truncated date

getDateId

public static String getDateId(Date date,
                               TimeZone timeZone)
get a String identifying this date

Parameters:
date - the date
Returns:
the identifier for this date

getDateFromId

public static Date getDateFromId(String id,
                                 TimeZone timeZone)
get a date from the given date ID

Parameters:
id - the date ID
Returns:
the date

getCalendarInstance

public static Calendar getCalendarInstance(Date date,
                                           TimeZone timeZone)


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.