org.magnos.data
Enum StoreAccess

java.lang.Object
  extended by java.lang.Enum<StoreAccess>
      extended by org.magnos.data.StoreAccess
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<StoreAccess>

public enum StoreAccess
extends java.lang.Enum<StoreAccess>

A stores access imposes restrictions on the store and its permanent medium if one exists.

Author:
Philip Diffenderfer

Enum Constant Summary
Exclusive
          A store with read and write access.
ReadOnly
          A store with only read access.
ReadWrite
          A store with read and write access.
 
Field Summary
 boolean canLock
          Whether the store should acquire exclisive access to any persisted medium.
 boolean canRead
          Whether the store can have data read from it.
 boolean canWrite
          Whether the store can have data written to it.
 StoreAccess next
          The next access if this state could not be applied.
 
Method Summary
 void tryRead(Store store)
          Checks if this access can read on the given store, if not an access exception is thrown.
 void tryWrite(Store store)
          Checks if this access can writen on the given store, if not an access exception is thrown.
static StoreAccess valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static StoreAccess[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

ReadOnly

public static final StoreAccess ReadOnly
A store with only read access. Any attempt to write to the store will cause a StoreIOException to be thrown.


ReadWrite

public static final StoreAccess ReadWrite
A store with read and write access. The implementation will not use any locking mechanism to ensure its the only process using the medium to which the store may be persisted to.


Exclusive

public static final StoreAccess Exclusive
A store with read and write access. The implementation may also choose to acquire an exclusive lock on the data if the data is persisted to some medium. This will avoid concurrent access to the data by this process and any other process.

Field Detail

canRead

public final boolean canRead
Whether the store can have data read from it.


canWrite

public final boolean canWrite
Whether the store can have data written to it.


canLock

public final boolean canLock
Whether the store should acquire exclisive access to any persisted medium.


next

public final StoreAccess next
The next access if this state could not be applied.

Method Detail

values

public static StoreAccess[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (StoreAccess c : StoreAccess.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static StoreAccess valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null

tryRead

public void tryRead(Store store)
Checks if this access can read on the given store, if not an access exception is thrown.

Parameters:
store - The store to try to read on.

tryWrite

public void tryWrite(Store store)
Checks if this access can writen on the given store, if not an access exception is thrown.

Parameters:
store - The store to try to write on.