Class Period

java.lang.Object
org.alfresco.service.cmr.repository.Period
All Implemented Interfaces:
Serializable

public class Period extends Object implements Serializable
Implementation for the period data type "d:period" A period is specified by the period type and an optional expression. The string value is periodType|expression Examples are: none day - one day day|3 - 3 days week - one week week|1 - one week week|2 - two weeks month year monthend quarterend The period type specifies a period implementation. This is registered with this class and is used to when adding the period to a date, handles any processing of the expression, reports if the expression is not required, optional or mandatory. The period data type can be also passed as a Map of keys: periodType and expression.
Author:
andyh
See Also:
  • Constructor Details

    • Period

      public Period(String period)
      Create a period without an accompanying expression.
      Parameters:
      period - String
    • Period

      public Period(Map<String,String> source)
      Create a period using key-value
      Parameters:
      source -
  • Method Details

    • registerProvider

      public static void registerProvider(PeriodProvider periodProvider)
      Register a provider
      Parameters:
      periodProvider - PeriodProvider
    • getProvider

      public static PeriodProvider getProvider(String periodType)
      Find a provider
      Parameters:
      periodType - String
      Returns:
      the provider
      Throws:
      IllegalStateException - of there is no implementation
    • getProviderNames

      public static Set<String> getProviderNames()
      Get the set of registered providers
      Returns:
      - the set of registered providers
    • getPeriodType

      public String getPeriodType()
      Returns:
      the periodType
    • getExpression

      public String getExpression()
      Returns:
      the expression
    • getNextDate

      public Date getNextDate(Date date)
      Calculate the next date for this period given the a start date.
      Parameters:
      date - Date
      Returns:
      the next date.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object