org.apache.jackrabbit.core.version
Class LabelVersionSelector

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

public class LabelVersionSelector
extends Object
implements VersionSelector

This Class implements a version selector that selects a version by label.

V1.0 V1.1 - "foo" new LabelVersionSelector("foo").select() --> V1.1 new LabelVersionSelector("bar").select() --> null


Constructor Summary
LabelVersionSelector(Name label)
          Creates a LabelVersionSelector that will try to select a version with the given label.
 
Method Summary
 Name getLabel()
          Returns the label hint
 InternalVersion select(InternalVersionHistory versionHistory)
          Selects a version of the given version history.
static InternalVersion selectByLabel(InternalVersionHistory history, Name label)
          Selects a version by label
 void setLabel(Name label)
          Sets the label 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

LabelVersionSelector

public LabelVersionSelector(Name label)
Creates a LabelVersionSelector that will try to select a version with the given label.

Parameters:
label - label hint
Method Detail

getLabel

public Name getLabel()
Returns the label hint

Returns:
the label hint.

setLabel

public void setLabel(Name label)
Sets the label hint

Parameters:
label - label hint

select

public InternalVersion select(InternalVersionHistory versionHistory)
                       throws RepositoryException
Selects a version of the given version history. If this VersionSelector is unable to select one, it can return 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.

Specified by:
select in interface VersionSelector
Parameters:
versionHistory - version history to select a version from
Returns:
A version or null.
Throws:
RepositoryException - if an error occurs.

selectByLabel

public static InternalVersion selectByLabel(InternalVersionHistory history,
                                            Name label)
                                     throws RepositoryException
Selects a version by label

Parameters:
history - history to select from
label - desired label
Returns:
the version with the given label or null
Throws:
RepositoryException - if an error occurs

toString

public String toString()
returns debug information

Overrides:
toString in class Object
Returns:
debug information


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