Top Description Fields Constructors Methods
net.fortuna.ical4j.model

public Class PeriodList<T extends Temporal>

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
net.fortuna.ical4j.util.RegEx, org.threeten.extra.Interval, java.io.Serializable, java.time.ZoneId, java.time.temporal.Temporal, java.util.*, java.util.stream.Collectors

$Id$ [23-Apr-2004] Defines a list of iCalendar periods. This class encapsulates a collection of naturally sorted periods that SHOULD conform to a common set of rules, including temporal type, applicable timezone and string representation (format). Results for a consumed time query will have the same temporal type, format type and (where applicable) timezone as the event start date. Results for a free-busy query will always be defined in UTC time (i.e. using temporal type java.time.Instant)

Note

By implementing the java.util.SortedSet interface period lists will always be sorted according to natural ordering.

Author
Ben Fortuna

Field Summary

Modifier and TypeField and Description
private final transient CalendarDateFormat
private final Set<Period<T>>
private static final long

Constructor Summary

AccessConstructor and Description
public
PeriodList()

Default constructor.

public
public
public
public
PeriodList(Interval[] intervals)

Method Summary

Modifier and TypeMethod and Description
public final PeriodList<T>

Returns:

true
add
(final Period<T>
the period to add
period
)

Add a period to the list.

public final PeriodList<T>

Returns:

a period list instance
add
(final PeriodList<T>
a list of periods to add
periods
)

A convenience method that combines all the periods in the specified list to this list.

public PeriodList<T>
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public Set<Period<T>>
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public final PeriodList<T>

Returns:

a period list
normalise
()

Returns a normalised version of this period list.

public static <T extends Temporal> PeriodList<T>
parse(final String
a string representation of a list of periods
aValue
)

Parses the specified string representation to create a list of periods.

public static <T extends Temporal> PeriodList<T>
parse(final String aValue, CalendarDateFormat calendarDateFormat)

public final PeriodList<T>

Returns:

true if the list contained the specified period
remove
(final Object
the period to remove
period
)

Remove a period from the list.

public final PeriodList<T>

Returns:

a period list
subtract
(final PeriodList<T>
a list of periods to subtract from this list
subtractions
)

Subtracts the intersection of this list with the specified list of periods from this list and returns the results as a new period list.

public List<Interval>
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public String
toString(ZoneId zoneId)

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

dateFormatback to summary
private final transient CalendarDateFormat dateFormat
periodsback to summary
private final Set<Period<T>> periods
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

PeriodListback to summary
public PeriodList()

Default constructor.

PeriodListback to summary
public PeriodList(CalendarDateFormat dateFormat)
PeriodListback to summary
public PeriodList(Collection<Period<T>> periods)
PeriodListback to summary
public PeriodList(Collection<Period<T>> periods, CalendarDateFormat dateFormat)
PeriodListback to summary
public PeriodList(Interval[] intervals)

Method Detail

addback to summary
public final PeriodList<T> add(final Period<T> period)

Add a period to the list.

Parameters
period:Period<T>

the period to add

Returns:PeriodList<T>

true

See Also
java.util.List#add(java.lang.Object)
addback to summary
public final PeriodList<T> add(final PeriodList<T> periods)

A convenience method that combines all the periods in the specified list to this list. The result returned is a new PeriodList instance, except where no periods are specified in the arguments. In such cases this instance is returned. Normalisation is also performed automatically after all periods have been added.

Parameters
periods:PeriodList<T>

a list of periods to add

Returns:PeriodList<T>

a period list instance

addAllback to summary
public PeriodList<T> addAll(Collection<Period<T>> arg0)
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getPeriodsback to summary
public Set<Period<T>> getPeriods()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
normaliseback to summary
public final PeriodList<T> normalise()

Returns a normalised version of this period list. Normalisation includes combining overlapping periods, removing periods contained by other periods, combining adjacent periods, and removing periods that consume no time.

Note

If the period list is already normalised then this period list is returned.

Returns:PeriodList<T>

a period list

parseback to summary
public static <T extends Temporal> PeriodList<T> parse(final String aValue)

Parses the specified string representation to create a list of periods.

Parameters
aValue:String

a string representation of a list of periods

Exceptions
DateTimeParseException:
thrown when an invalid string representation of a period list is provided
parseback to summary
public static <T extends Temporal> PeriodList<T> parse(final String aValue, CalendarDateFormat calendarDateFormat)
Annotations
@SuppressWarnings:unchecked
removeback to summary
public final PeriodList<T> remove(final Object period)

Remove a period from the list.

Parameters
period:Object

the period to remove

Returns:PeriodList<T>

true if the list contained the specified period

See Also
java.util.List#remove(java.lang.Object)
subtractback to summary
public final PeriodList<T> subtract(final PeriodList<T> subtractions)

Subtracts the intersection of this list with the specified list of periods from this list and returns the results as a new period list. If no intersection is identified this list is returned.

Parameters
subtractions:PeriodList<T>

a list of periods to subtract from this list

Returns:PeriodList<T>

a period list

toIntervalListback to summary
public List<Interval> toIntervalList()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
toStringback to summary
public String toString(ZoneId zoneId)