public class DateVersionSelector extends Object implements VersionSelector
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 and Description |
---|
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. |
Modifier and Type | Method and Description |
---|---|
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.
|
InternalVersion |
select(InternalVersionHistory versionHistory)
Selects a version of the given version history.
|
static InternalVersion |
selectByDate(InternalVersionHistory 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
|
public DateVersionSelector(Calendar date)
DateVersionSelector
that will select the latest
version of all those that are older than the given date.date
- reference datepublic DateVersionSelector(Calendar date, boolean returnLatest)
DateVersionSelector
that will select the latest
version of all those that are older than the given date.date
- reference datereturnLatest
- if true
latest is selectedpublic Calendar getDate()
public void setDate(Calendar date)
date
- reference datepublic boolean isReturnLatest()
true
if it returns latest.public void setReturnLatest(boolean returnLatest)
returnLatest
- the returnLatest
flagpublic InternalVersion select(InternalVersionHistory versionHistory) throws RepositoryException
null
. Please note,
that a version selector is not allowed to return the root version.
Selects a version from the given version history using the previously
assigned hint in the following order: name, label, date, latest.select
in interface VersionSelector
versionHistory
- version history to select a version fromnull
.RepositoryException
- if an error occurs.public static InternalVersion selectByDate(InternalVersionHistory history, Calendar date) throws RepositoryException
history
- history to select fromdate
- reference datenull
RepositoryException
- if an error occursCopyright © 2004–2024 The Apache Software Foundation. All rights reserved.