fr.paris.lutece.plugins.calendar.service
Class Utils

java.lang.Object
  extended by fr.paris.lutece.plugins.calendar.service.Utils

public final class Utils
extends java.lang.Object

This class provides utils features to manipulate and convert calendars, date as string, ...


Constructor Summary
Utils()
           
 
Method Summary
static boolean checkTime(java.lang.String strTime)
          Return a boolean: if the time is well formed return true, else return false
static java.util.List<AgendaResource> getAgendaResourcesWithEvents()
          Get the multi agenda from database
static java.util.List<AgendaResource> getAgendaResourcesWithOccurrences()
          Get the multi agenda from database
static java.util.List<AgendaResource> getAgendaResourcesWithOccurrences(javax.servlet.http.HttpServletRequest request)
          Get all agendas from database checkin the security
static java.util.List<AgendaResource> getAgendaResourcesWithOccurrencesIds()
          Get the multi agenda from database with occurrences ordered by id
static Agenda getAgendaWithEvents(java.lang.String strAgenda, javax.servlet.http.HttpServletRequest request)
          Get a specified agenda from database with events
static Agenda getAgendaWithOccurrences(java.lang.String strAgenda, javax.servlet.http.HttpServletRequest request)
          Get a specified agenda from database with occurrences
static Agenda getAgendaWithOccurrencesOrderedbyId(java.lang.String strAgenda, javax.servlet.http.HttpServletRequest request)
          Get a specified agenda from database with occurrences
static java.lang.String[] getCalendarIds(javax.servlet.http.HttpServletRequest request)
          Get all calendar ids that the user is authorized to visualize
static java.lang.String getDate(java.util.Calendar calendar)
          Constructs a 8 digits date string YYYYMMDD
static java.lang.String getDate(java.util.Date dateDigit)
          Constructs a digit string from a date object
static java.lang.String getDate(int nYear, int nMonth, int nDay)
          Constructs a 8 digits date string code YYYYMMDD
static java.util.Date getDate(java.lang.String strDate)
          Constructs a Date object from YYYYMMDD
static java.util.Date getDateForward(java.util.Date dateDay, int nPeriodicity, int nOccurrence, java.lang.String[] arrayExcludedDays)
          Returns a date code corresponding to a calendar roll of n days forward
static java.lang.String getDateToday()
          Returns a the date code of today
static int getDay(java.lang.String strDate)
          Returns the day of month from a date code
static java.util.Date getDayAfter(java.util.Date dateDayAfter, int n)
          Returns a date code corresponding to a calendar roll of n days forward
static java.lang.String getDayAfter(java.lang.String strDate, int n)
          Returns a date code corresponding to a calendar roll of n days forward
static java.lang.String getDayLabel(java.lang.String strDate, java.util.Locale locale)
          Returns the day as an international formatted string corresponding to the date code
static int getDayOfWeek(java.lang.String strDate)
           
static java.util.Calendar getFirstDayOfWeek(java.lang.String strDate)
          Returns the first monday of a week as a formatted string corresponding to the date code
static int getMonth(java.lang.String strDate)
          Returns the month from a date code
static java.lang.String getMonthLabel(java.lang.String strDate, java.util.Locale locale)
          Returns the month as a formatted string corresponding to the date code
static java.lang.String getNextDay(java.lang.String strDate)
          Returns a date code corresponding to a calendar roll of one day forward
static java.lang.String getNextMonth(java.lang.String strDate)
           
static java.lang.String getNextMonth(java.lang.String strDateRef, int nCptDate)
          Returns a date code corresponding to a calendar roll of one month
static java.lang.String getNextWeek(java.lang.String strDate)
          Returns a date code corresponding to a calendar roll of one week forward
static int getOccurrenceWithinTwoDates(java.util.Date dateStart, java.util.Date dateEnd, java.lang.String[] arrayExcludedDays)
          Returns a date code corresponding to a calendar roll of one month
static java.lang.String getPreviousDay(java.lang.String strDate)
          Returns a date code corresponding to a calendar roll of one day backward
static java.lang.String getPreviousMonth(java.lang.String strDate)
          Returns a date code corresponding to a calendar roll of one month backward
static java.lang.String getPreviousWeek(java.lang.String strDate)
          Returns a date code corresponding to a calendar roll of one week backward
static java.lang.String getWeekDayLabel(java.lang.String strDate, java.util.Locale locale)
          Returns the day as an international formatted string corresponding to the date code
static java.lang.String getWeekLabel(java.lang.String strDate, java.util.Locale locale)
          Returns the Week as a formatted string corresponding to the date code
static int getYear(java.lang.String strDate)
          Returns the year from a date code
static boolean isDayExcluded(int nDayOfWeek, java.lang.String[] arrayExcludedDays)
          Check if a day is in the list of excluded days
static boolean isDayOff(java.util.Calendar calendar)
          Checks if the day if Off (ie: Sunday) or not
static boolean isValid(java.lang.String strDate)
          Checks a date code
static boolean isValidDate(java.util.Date dateEvent)
          Checks a date code
static void loadAgendaEvents(AgendaResource agenda, fr.paris.lutece.portal.service.plugin.Plugin plugin)
          Return the agenda
static void loadAgendaOccurrences(AgendaResource agenda, fr.paris.lutece.portal.service.plugin.Plugin plugin)
          Return the agenda
static void loadAgendaOccurrencesOrderedById(AgendaResource agenda, fr.paris.lutece.portal.service.plugin.Plugin plugin)
          Return the occurrences of an agenda ordered by id
static java.lang.String ParseHtmlToPlainTextString(java.lang.String strHTML)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

getDate

public static java.lang.String getDate(int nYear,
                                       int nMonth,
                                       int nDay)
Constructs a 8 digits date string code YYYYMMDD

Parameters:
nYear - The Year
nMonth - The month index (0-11)
nDay - The day of the month (1-31)
Returns:
The date string code

getDate

public static java.lang.String getDate(java.util.Calendar calendar)
Constructs a 8 digits date string YYYYMMDD

Parameters:
calendar - A calendar positionned on the date
Returns:
The date code

getDateToday

public static java.lang.String getDateToday()
Returns a the date code of today

Returns:
The date code

getYear

public static int getYear(java.lang.String strDate)
Returns the year from a date code

Parameters:
strDate - The date code
Returns:
The Year

getMonth

public static int getMonth(java.lang.String strDate)
Returns the month from a date code

Parameters:
strDate - The date code
Returns:
The month index (0 - 11)

getDay

public static int getDay(java.lang.String strDate)
Returns the day of month from a date code

Parameters:
strDate - The date code
Returns:
The day

getMonthLabel

public static java.lang.String getMonthLabel(java.lang.String strDate,
                                             java.util.Locale locale)
Returns the month as a formatted string corresponding to the date code

Parameters:
locale - The locale used for display settings
strDate - The date code
Returns:
The month label

getWeekLabel

public static java.lang.String getWeekLabel(java.lang.String strDate,
                                            java.util.Locale locale)
Returns the Week as a formatted string corresponding to the date code

Parameters:
locale - The locale used for display settings
strDate - The date code
Returns:
The week label

getFirstDayOfWeek

public static java.util.Calendar getFirstDayOfWeek(java.lang.String strDate)
Returns the first monday of a week as a formatted string corresponding to the date code

Parameters:
strDate - The date code
Returns:
The first day label

getDayLabel

public static java.lang.String getDayLabel(java.lang.String strDate,
                                           java.util.Locale locale)
Returns the day as an international formatted string corresponding to the date code

Parameters:
locale - The locale used for display settings
strDate - The date code
Returns:
The day as a string

getWeekDayLabel

public static java.lang.String getWeekDayLabel(java.lang.String strDate,
                                               java.util.Locale locale)
Returns the day as an international formatted string corresponding to the date code

Parameters:
locale - The locale used for display settings
strDate - The date code
Returns:
The day as a string

getNextMonth

public static java.lang.String getNextMonth(java.lang.String strDate)
Parameters:
strDate -
Returns:

getPreviousMonth

public static java.lang.String getPreviousMonth(java.lang.String strDate)
Returns a date code corresponding to a calendar roll of one month backward

Parameters:
strDate - The date code
Returns:
A new date code one month earlier

getPreviousWeek

public static java.lang.String getPreviousWeek(java.lang.String strDate)
Returns a date code corresponding to a calendar roll of one week backward

Parameters:
strDate - The date code
Returns:
A new date code one month earlier

getNextWeek

public static java.lang.String getNextWeek(java.lang.String strDate)
Returns a date code corresponding to a calendar roll of one week forward

Parameters:
strDate - The date code
Returns:
A new date code one month earlier

getNextDay

public static java.lang.String getNextDay(java.lang.String strDate)
Returns a date code corresponding to a calendar roll of one day forward

Parameters:
strDate - The date code
Returns:
A new date code one month earlier

getPreviousDay

public static java.lang.String getPreviousDay(java.lang.String strDate)
Returns a date code corresponding to a calendar roll of one day backward

Parameters:
strDate - The date code
Returns:
A new date code one month earlier

isValid

public static boolean isValid(java.lang.String strDate)
Checks a date code

Parameters:
strDate - The date code
Returns:
True if valid otherwise false

isDayOff

public static boolean isDayOff(java.util.Calendar calendar)
Checks if the day if Off (ie: Sunday) or not

Parameters:
calendar - A calendar object positionned on the day to check
Returns:
True if the day if Off, otherwise false

checkTime

public static boolean checkTime(java.lang.String strTime)
Return a boolean: if the time is well formed return true, else return false

Parameters:
strTime - The time
Returns:
a boolean

getDayAfter

public static java.lang.String getDayAfter(java.lang.String strDate,
                                           int n)
Returns a date code corresponding to a calendar roll of n days forward

Parameters:
n - number of days to roll
strDate - The date code
Returns:
A new date code one month earlier

getDayAfter

public static java.util.Date getDayAfter(java.util.Date dateDayAfter,
                                         int n)
Returns a date code corresponding to a calendar roll of n days forward

Parameters:
n - number of days to roll
dateDayAfter - The date
Returns:
A new date code with n days forward

getDateForward

public static java.util.Date getDateForward(java.util.Date dateDay,
                                            int nPeriodicity,
                                            int nOccurrence,
                                            java.lang.String[] arrayExcludedDays)
Returns a date code corresponding to a calendar roll of n days forward

Parameters:
dateDay - the reference date
periodicity - the frequence of an occurrence day, week, month
nOccurrence - the number of occurrences
arrayExcludedDays - list of excluded days
Returns:
A new date code one month earlier

getDate

public static java.util.Date getDate(java.lang.String strDate)
Constructs a Date object from YYYYMMDD

Parameters:
strDate - a 8 digits date string YYYYMMDD
Returns:
The date code

getDate

public static java.lang.String getDate(java.util.Date dateDigit)
Constructs a digit string from a date object

Parameters:
The - date code
Returns:
strDate a 8 digits date string YYYYMMDD

getNextMonth

public static java.lang.String getNextMonth(java.lang.String strDateRef,
                                            int nCptDate)
Returns a date code corresponding to a calendar roll of one month

Parameters:
strDateRef - The date reference
Returns:
A date code incremented with strDateRef parameter

getOccurrenceWithinTwoDates

public static int getOccurrenceWithinTwoDates(java.util.Date dateStart,
                                              java.util.Date dateEnd,
                                              java.lang.String[] arrayExcludedDays)
Returns a date code corresponding to a calendar roll of one month

Parameters:
dateStart - The date start
dateEnd - The date end
arrayExcludedDays - list of excluded days
Returns:
A date code incremented with strDateRef parameter

getAgendaWithEvents

public static Agenda getAgendaWithEvents(java.lang.String strAgenda,
                                         javax.servlet.http.HttpServletRequest request)
Get a specified agenda from database with events

Parameters:
request - The HTTP request
Returns:
An agenda object

getAgendaWithOccurrences

public static Agenda getAgendaWithOccurrences(java.lang.String strAgenda,
                                              javax.servlet.http.HttpServletRequest request)
Get a specified agenda from database with occurrences

Parameters:
request - The HTTP request
Returns:
An agenda object

getAgendaWithOccurrencesOrderedbyId

public static Agenda getAgendaWithOccurrencesOrderedbyId(java.lang.String strAgenda,
                                                         javax.servlet.http.HttpServletRequest request)
Get a specified agenda from database with occurrences

Parameters:
request - The HTTP request
Returns:
An agenda object

getAgendaResourcesWithOccurrences

public static java.util.List<AgendaResource> getAgendaResourcesWithOccurrences(javax.servlet.http.HttpServletRequest request)
Get all agendas from database checkin the security

Returns:
An agenda object

getAgendaResourcesWithOccurrences

public static java.util.List<AgendaResource> getAgendaResourcesWithOccurrences()
Get the multi agenda from database

Returns:
An agenda object

getAgendaResourcesWithEvents

public static java.util.List<AgendaResource> getAgendaResourcesWithEvents()
Get the multi agenda from database

Returns:
An agenda object

getAgendaResourcesWithOccurrencesIds

public static java.util.List<AgendaResource> getAgendaResourcesWithOccurrencesIds()
Get the multi agenda from database with occurrences ordered by id

Returns:
An agenda object

loadAgendaOccurrences

public static void loadAgendaOccurrences(AgendaResource agenda,
                                         fr.paris.lutece.portal.service.plugin.Plugin plugin)
Return the agenda

Parameters:
agenda - The agenda

loadAgendaOccurrencesOrderedById

public static void loadAgendaOccurrencesOrderedById(AgendaResource agenda,
                                                    fr.paris.lutece.portal.service.plugin.Plugin plugin)
Return the occurrences of an agenda ordered by id

Parameters:
agenda - The agenda

loadAgendaEvents

public static void loadAgendaEvents(AgendaResource agenda,
                                    fr.paris.lutece.portal.service.plugin.Plugin plugin)
Return the agenda

Parameters:
agenda - The agenda

isValidDate

public static boolean isValidDate(java.util.Date dateEvent)
Checks a date code

Parameters:
dateEvent - The date code
Returns:
True if valid otherwise false

ParseHtmlToPlainTextString

public static java.lang.String ParseHtmlToPlainTextString(java.lang.String strHTML)

getCalendarIds

public static java.lang.String[] getCalendarIds(javax.servlet.http.HttpServletRequest request)
Get all calendar ids that the user is authorized to visualize

Parameters:
request - HttpServletRequest
Returns:
String array

getDayOfWeek

public static int getDayOfWeek(java.lang.String strDate)

isDayExcluded

public static boolean isDayExcluded(int nDayOfWeek,
                                    java.lang.String[] arrayExcludedDays)
Check if a day is in the list of excluded days

Parameters:
nDayOfWeek - the day to check
listExcludedDays - the list of excluded days
Returns:
true if it is excluded, false otherwise


Copyright © 2012 Mairie de Paris. All Rights Reserved.