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 booleancanRead(FormatVersion other)Returnstrueifthisversion can read data written by theotherversion.intcompareTo(@NotNull FormatVersion other)booleanequals(Object obj)StringtoString()static FormatVersionvalueOf(String s)Returns a format version for the given String representation.static Iterable<FormatVersion>values()static @NotNull FormatVersionversionOf(@NotNull DocumentStore store)Reads theFormatVersionfrom the given store.booleanwriteTo(@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)
Returnstrueifthisversion can read data written by theotherversion.- Parameters:
other- the version the data was written in.- Returns:
trueif this version can read,falseotherwise.
-
versionOf
@NotNull public static @NotNull FormatVersion versionOf(@NotNull @NotNull DocumentStore store) throws DocumentStoreException
Reads theFormatVersionfrom the given store. This method returnsV0if 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 DocumentStoreExceptionWrites this version to the given document store. The write operation will fail with aDocumentStoreExceptionif 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:
trueif the version in the store was updated,falseotherwise. This method will also returnfalseif 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:
compareToin interfaceComparable<FormatVersion>
-
-