org.apache.jackrabbit.core.version
Class DateVersionSelector

java.lang.Object
  extended by org.apache.jackrabbit.core.version.DateVersionSelector
All Implemented Interfaces:
VersionSelector

public class DateVersionSelector
extends Object
implements VersionSelector

This Class implements a version selector that selects a version by creation date. The selected version is the latest that is older or equal than the given date. If no version could be found null is returned unless the returnLatest flag is set to true, where the latest version is returned.

V1.0 - 02-Sep-2006 V1.1 - 03-Sep-2006 V1.2 - 05-Sep-2006 new DateVersionSelector("03-Sep-2006").select() -> V1.1 new DateVersionSelector("04-Sep-2006").select() -> V1.1 new DateVersionSelector("01-Sep-2006").select() -> null new DateVersionSelector("01-Sep-2006", true).select() -> V1.2 new DateVersionSelector(null, true).select() -> V1.2


Constructor Summary
DateVersionSelector(Calendar date)
          Creates a DateVersionSelector that will select the latest version of all those that are older than the given date.
DateVersionSelector(Calendar date, boolean returnLatest)
          Creates a DateVersionSelector that will select the latest version of all those that are older than the given date.
 
Method Summary
 Calendar getDate()
          Returns the date hint
 boolean isReturnLatest()
          Returns the flag, if the latest version should be selected, if no version can be found using the given hint.
 Version select(VersionHistory versionHistory)
          Selects a version from the given version history using the previously assigned hint in the following order: name, label, date, latest.
static Version selectByDate(VersionHistory history, Calendar date)
          Selects a version by date.
 void setDate(Calendar date)
          Sets the date hint
 void setReturnLatest(boolean returnLatest)
          Sets the flag, if the latest version should be selected, if no version can be found using the given hint.
 String toString()
          returns debug information
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DateVersionSelector

public DateVersionSelector(Calendar date)
Creates a DateVersionSelector that will select the latest version of all those that are older than the given date.

Parameters:
date -

DateVersionSelector

public DateVersionSelector(Calendar date,
                           boolean returnLatest)
Creates a DateVersionSelector that will select the latest version of all those that are older than the given date.

Parameters:
date -
returnLatest -
Method Detail

getDate

public Calendar getDate()
Returns the date hint

Returns:
the date hint.

setDate

public void setDate(Calendar date)
Sets the date hint

Parameters:
date -

isReturnLatest

public boolean isReturnLatest()
Returns the flag, if the latest version should be selected, if no version can be found using the given hint.

Returns:
true if it returns latest.

setReturnLatest

public void setReturnLatest(boolean returnLatest)
Sets the flag, if the latest version should be selected, if no version can be found using the given hint.

Parameters:
returnLatest -

select

public Version select(VersionHistory versionHistory)
               throws RepositoryException
Selects a version from the given version history using the previously assigned hint in the following order: name, label, date, latest.

Specified by:
select in interface VersionSelector
Parameters:
versionHistory -
Returns:
Throws:
RepositoryException

selectByDate

public static Version selectByDate(VersionHistory history,
                                   Calendar date)
                            throws RepositoryException
Selects a version by date.

Parameters:
history -
date -
Returns:
the latest version that is older than the given date date or null
Throws:
RepositoryException

toString

public String toString()
returns debug information

Overrides:
toString in class Object
Returns:
debug information


Copyright © 2004-2008 The Apache Software Foundation. All Rights Reserved.