Class FormatVersion
- java.lang.Object
-
- org.apache.jackrabbit.oak.plugins.document.FormatVersion
-
- All Implemented Interfaces:
Comparable<FormatVersion>
public final class FormatVersion extends Object implements Comparable<FormatVersion>
The format version currently in use by the DocumentNodeStore and written to the underlying DocumentStore. A versioncanRead(org.apache.jackrabbit.oak.plugins.document.FormatVersion)
the current or older versions.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canRead(FormatVersion other)
Returnstrue
ifthis
version can read data written by theother
version.int
compareTo(@NotNull FormatVersion other)
boolean
equals(Object obj)
String
toString()
static FormatVersion
valueOf(String s)
Returns a format version for the given String representation.static Iterable<FormatVersion>
values()
static @NotNull FormatVersion
versionOf(@NotNull DocumentStore store)
Reads theFormatVersion
from the given store.boolean
writeTo(@NotNull DocumentStore store)
Writes this version to the given document store.
-
-
-
Method Detail
-
values
public static Iterable<FormatVersion> values()
- Returns:
- well known format versions.
-
canRead
public boolean canRead(FormatVersion other)
Returnstrue
ifthis
version can read data written by theother
version.- Parameters:
other
- the version the data was written in.- Returns:
true
if this version can read,false
otherwise.
-
versionOf
@NotNull public static @NotNull FormatVersion versionOf(@NotNull @NotNull DocumentStore store) throws DocumentStoreException
Reads theFormatVersion
from the given store. This method returnsV0
if the store currently does not have a version set.- Parameters:
store
- the store to read from.- Returns:
- the format version of the store.
- Throws:
DocumentStoreException
- if an error occurs while reading from the store.
-
writeTo
public boolean writeTo(@NotNull @NotNull DocumentStore store) throws DocumentStoreException
Writes this version to the given document store. The write operation will fail with aDocumentStoreException
if the version change is considered incompatible or cannot be applied for some other reason. This includes:- An attempt to downgrade the existing version
- There are active cluster nodes using an existing version
- The version was changed concurrently
- Parameters:
store
- the document store.- Returns:
true
if the version in the store was updated,false
otherwise. This method will also returnfalse
if the version in the store equals this version and now update was required.- Throws:
DocumentStoreException
- if the write operation fails. Reasons include: 1) an attempt to downgrade the existing version, 2) there are active cluster nodes using an existing version, 3) the version was changed concurrently.
-
valueOf
public static FormatVersion valueOf(String s) throws IllegalArgumentException
Returns a format version for the given String representation. This method either returns one of the well known versions or an entirely new version if the version is not well known.- Parameters:
s
- the String representation of a format version.- Returns:
- the parsed format version.
- Throws:
IllegalArgumentException
- if the string is malformed.
-
compareTo
public int compareTo(@NotNull @NotNull FormatVersion other)
- Specified by:
compareTo
in interfaceComparable<FormatVersion>
-
-