time
Class TimeMask

java.lang.Object
  extended by time.TimeMask
All Implemented Interfaces:
java.lang.Iterable<TimeField>, java.util.Collection<TimeField>, java.util.Set<TimeField>, java.util.SortedSet<TimeField>

public final class TimeMask
extends java.lang.Object
implements java.util.SortedSet<TimeField>

A TimeMask is a sorted set of TimeField which is used to defined Time. It defines a format which will be used to manipulate Time.

Author:
Arnaud Roques

Constructor Summary
TimeMask(java.util.Collection<TimeField> s)
          Create a new TimeMask from several TimeField.
TimeMask(TimeField... f)
          Create a new TimeMask from several TimeField.
TimeMask(TimeMask... masks)
          Create a new TimeMask from several other TimeMask.
TimeMask(TimeMask mask, TimeField... f)
          Create a new TimeMask by adding TimeField to an existing TimeMask.
 
Method Summary
 boolean add(TimeField o)
          As TimeMask are immutable, throws a UnsupportedOperationException.
 boolean addAll(java.util.Collection<? extends TimeField> c)
          As TimeMask are immutable, throws a UnsupportedOperationException.
 void clear()
          As TimeMask are immutable, throws a UnsupportedOperationException.
 java.util.Comparator<? super TimeField> comparator()
          Return null, as natural order of TimeField are used in TimeMask.
 boolean contains(java.lang.Object obj)
          Returns true if this TimeMask contains the specified element.
 boolean containsAll(java.util.Collection<?> c)
          Returns true if this TimeMask contains all of the elements in the specified collection.
 boolean equals(java.lang.Object anObject)
          Compares this TimeMask to the specified object.
 TimeField first()
          Return the most significant TimeField of this TimeMask.
 java.util.SortedSet<TimeField> getFields()
          Return all TimeField contained in this TimeMask.
 int hashCode()
          Returns a hash code value for this object.
 TimeMask headSet(TimeField toField)
          Build a new TimeMask with TimeField of this TimeMask which are more significant (exclusive) than a TimeField.
 boolean isEmpty()
          Return true is this TimeMask contains no TimeField.
 java.util.Iterator<TimeField> iterator()
          Return an iterator over TimeField contained in this TimeMask.
 TimeField last()
          Return the less significant TimeField of this TimeMask.
 boolean remove(java.lang.Object o)
          As TimeMask are immutable, throws a UnsupportedOperationException.
 TimeMask remove(TimeField... f)
          Build a new TimeMask by removing some TimeField of this TimeMask.
 boolean removeAll(java.util.Collection<?> c)
          As TimeMask are immutable, throws a UnsupportedOperationException.
 boolean retainAll(java.util.Collection<?> c)
          As TimeMask are immutable, throws a UnsupportedOperationException.
 int size()
          Return the number of TimeFields in the TimeMask.
 TimeMask subSet(TimeField fromField, TimeField toField)
          Build a new TimeMask with some TimeField of this TimeMask.
 TimeMask tailSet(TimeField fromField)
          Build a new TimeMask with TimeField of this TimeMask which are less significant (inclusive) than a TimeField.
 java.lang.Object[] toArray()
           
<T> T[]
toArray(T[] a)
           
 java.lang.String toString()
          Convert this TimeMask to a String.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TimeMask

public TimeMask(TimeField... f)
Create a new TimeMask from several TimeField. The TimeFields will be sorted. It is recommanded that all TimeField belongs to the same chronology, although this is not mandatory. A TimeMask that mixes several TimeField from different chronologies is likely to be useless.

Parameters:
f - all TimeField used by the TimeMask.
Throws:
java.lang.NullPointerException - if one or more of the TimeField is null.

TimeMask

public TimeMask(java.util.Collection<TimeField> s)
Create a new TimeMask from several TimeField. The TimeFields will be sorted. It is recommanded that all TimeField belongs to the same chronology, although this is not mandatory. A TimeMask that mixes several TimeField from different chronologies is likely to be useless.

Parameters:
s - all TimeField used by the TimeMask.
Throws:
java.lang.NullPointerException - if one or more of the TimeField is null.

TimeMask

public TimeMask(TimeMask... masks)
Create a new TimeMask from several other TimeMask. All TimeField from every TimeMask are collected in the new TimeMask.

Parameters:
masks - all TimeMask that will be merged in the new TimeMask.
Throws:
java.lang.NullPointerException - if one or more of the TimeMask is null.

TimeMask

public TimeMask(TimeMask mask,
                TimeField... f)
Create a new TimeMask by adding TimeField to an existing TimeMask.

Parameters:
mask - the original TimeMask
f - all TimeField to add in the new TimeMask
Throws:
java.lang.NullPointerException - if mask is null.
java.lang.NullPointerException - if one or more of the TimeField is null.
Method Detail

getFields

public java.util.SortedSet<TimeField> getFields()
Return all TimeField contained in this TimeMask.

Returns:
all TimeField contained in this TimeMask.

size

public int size()
Return the number of TimeFields in the TimeMask.

Specified by:
size in interface java.util.Collection<TimeField>
Specified by:
size in interface java.util.Set<TimeField>
Returns:
number of TimeFields in the TimeMask.

equals

public boolean equals(java.lang.Object anObject)
Compares this TimeMask to the specified object. The result is true if and only if the argument is not null and is a TimeMask that have the same sequence of TimeField as this object.

Specified by:
equals in interface java.util.Collection<TimeField>
Specified by:
equals in interface java.util.Set<TimeField>
Overrides:
equals in class java.lang.Object
Parameters:
anObject - - the object to compare this TimeMask against.

hashCode

public int hashCode()
Returns a hash code value for this object.

Specified by:
hashCode in interface java.util.Collection<TimeField>
Specified by:
hashCode in interface java.util.Set<TimeField>
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Convert this TimeMask to a String.

Overrides:
toString in class java.lang.Object
Returns:
a String describing this TimeMask

last

public TimeField last()
Return the less significant TimeField of this TimeMask.

Specified by:
last in interface java.util.SortedSet<TimeField>
Returns:
the less significant TimeField of this TimeMask.

first

public TimeField first()
Return the most significant TimeField of this TimeMask.

Specified by:
first in interface java.util.SortedSet<TimeField>
Returns:
the most significant TimeField of this TimeMask.

tailSet

public TimeMask tailSet(TimeField fromField)
Build a new TimeMask with TimeField of this TimeMask which are less significant (inclusive) than a TimeField.

Specified by:
tailSet in interface java.util.SortedSet<TimeField>
Parameters:
fromField - TimeField to compare with.
Returns:
new TimeMask with some of the less significant TimeField of this TimeMask.
Throws:
java.lang.NullPointerException - if fromField is null.
java.lang.IllegalArgumentException - if fromField is not in the range of this TimeMask.

headSet

public TimeMask headSet(TimeField toField)
Build a new TimeMask with TimeField of this TimeMask which are more significant (exclusive) than a TimeField.

Specified by:
headSet in interface java.util.SortedSet<TimeField>
Parameters:
toField - TimeField to compare with.
Returns:
new TimeMask with some of the more significant TimeField of this TimeMask.
Throws:
java.lang.NullPointerException - if toField is null.
java.lang.IllegalArgumentException - if toField is not in the range of this TimeMask.

subSet

public TimeMask subSet(TimeField fromField,
                       TimeField toField)
Build a new TimeMask with some TimeField of this TimeMask. Only TimeField that are: will be in the returned TimeMask.

Specified by:
subSet in interface java.util.SortedSet<TimeField>
Parameters:
fromField - lower limit of the TimeField.
toField - uppder limit TimeField.
Returns:
new TimeMask with some of the TimeField of this TimeMask.
Throws:
java.lang.NullPointerException - if fromField or toField is null.
java.lang.IllegalArgumentException - if fromField or toField is not in the range of this TimeMask.
java.lang.IllegalArgumentException - if fromField is greater than toField.

comparator

public java.util.Comparator<? super TimeField> comparator()
Return null, as natural order of TimeField are used in TimeMask.

Specified by:
comparator in interface java.util.SortedSet<TimeField>
Returns:
null

clear

public void clear()
As TimeMask are immutable, throws a UnsupportedOperationException.

Specified by:
clear in interface java.util.Collection<TimeField>
Specified by:
clear in interface java.util.Set<TimeField>

removeAll

public boolean removeAll(java.util.Collection<?> c)
As TimeMask are immutable, throws a UnsupportedOperationException.

Specified by:
removeAll in interface java.util.Collection<TimeField>
Specified by:
removeAll in interface java.util.Set<TimeField>

retainAll

public boolean retainAll(java.util.Collection<?> c)
As TimeMask are immutable, throws a UnsupportedOperationException.

Specified by:
retainAll in interface java.util.Collection<TimeField>
Specified by:
retainAll in interface java.util.Set<TimeField>

addAll

public boolean addAll(java.util.Collection<? extends TimeField> c)
As TimeMask are immutable, throws a UnsupportedOperationException.

Specified by:
addAll in interface java.util.Collection<TimeField>
Specified by:
addAll in interface java.util.Set<TimeField>

remove

public boolean remove(java.lang.Object o)
As TimeMask are immutable, throws a UnsupportedOperationException.

Specified by:
remove in interface java.util.Collection<TimeField>
Specified by:
remove in interface java.util.Set<TimeField>
See Also:
remove(TimeField... f)

remove

public TimeMask remove(TimeField... f)
Build a new TimeMask by removing some TimeField of this TimeMask.

Parameters:
f - all TimeField to remove from this TimeField.
Returns:
a new TimeMask that contains less TimeField than this TimeMask.
Throws:
java.lang.IllegalArgumentException - if one or more of the TimeField are not contained in the TimeMask.

add

public boolean add(TimeField o)
As TimeMask are immutable, throws a UnsupportedOperationException.

Specified by:
add in interface java.util.Collection<TimeField>
Specified by:
add in interface java.util.Set<TimeField>
See Also:
TimeMask(TimeMask mask, TimeField... f)

containsAll

public boolean containsAll(java.util.Collection<?> c)
Returns true if this TimeMask contains all of the elements in the specified collection.

Specified by:
containsAll in interface java.util.Collection<TimeField>
Specified by:
containsAll in interface java.util.Set<TimeField>
Parameters:
c - collection to be checked for containment in this TimeMask.
Returns:
true if this TimeMask contains all of the elements in the specified collection.

contains

public boolean contains(java.lang.Object obj)
Returns true if this TimeMask contains the specified element.

Specified by:
contains in interface java.util.Collection<TimeField>
Specified by:
contains in interface java.util.Set<TimeField>
Parameters:
obj - object to be checked for containment in this TimeMask.

toArray

public <T> T[] toArray(T[] a)
Specified by:
toArray in interface java.util.Collection<TimeField>
Specified by:
toArray in interface java.util.Set<TimeField>

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection<TimeField>
Specified by:
toArray in interface java.util.Set<TimeField>

iterator

public java.util.Iterator<TimeField> iterator()
Return an iterator over TimeField contained in this TimeMask.

Specified by:
iterator in interface java.lang.Iterable<TimeField>
Specified by:
iterator in interface java.util.Collection<TimeField>
Specified by:
iterator in interface java.util.Set<TimeField>

isEmpty

public boolean isEmpty()
Return true is this TimeMask contains no TimeField.

Specified by:
isEmpty in interface java.util.Collection<TimeField>
Specified by:
isEmpty in interface java.util.Set<TimeField>
Returns:
true is this TimeMask contains no TimeField.