org.objectweb.jotm.impl.core.conflict
Class BasicConflictTable

java.lang.Object
  |
  +--org.objectweb.jotm.impl.core.conflict.BasicConflictTable
All Implemented Interfaces:
ConflictTable

public class BasicConflictTable
extends java.lang.Object
implements ConflictTable

BasicConflictTable is an implementation of conflict table. An example of a conflict table construction:

    String[] ops =     {"balance", "deposit", "withdraw"};
    boolean[][] cTable =
    /* balance * /    {{ false,     false,    false,},
    /* deposit * /     { false,     false,    true, },
    /* withdraw * /    { true,      true,     true  }};

    ConflictTable tab = new BasicConflictTable(ops, cTable);
   
In the example above, e.g., "balance" is not conflicting with any acquired lock mode, while "withdraw" is conflicting with all of them.


Constructor Summary
BasicConflictTable(java.lang.String[] iLocks, boolean[][] iConflictTable)
          Constructs conflict table.
 
Method Summary
 java.lang.String[] getLockModes()
          Gets lock modes.
 boolean isConflict(java.lang.String requestLock, java.lang.String holdLock)
          Tests if there is conflict between two lock modes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicConflictTable

public BasicConflictTable(java.lang.String[] iLocks,
                          boolean[][] iConflictTable)
Constructs conflict table.

Parameters:
iLocks - lock modes
iConflictTable - table of conflicts, where the first index is the requested lock mode and the second index the acquired lock mode; true means there is a conflict, false othrwise
Method Detail

getLockModes

public java.lang.String[] getLockModes()
Description copied from interface: ConflictTable
Gets lock modes. The method return an array of all lock modes defined in this conflict table.

Specified by:
getLockModes in interface ConflictTable
Returns:
array of all conflict table lock modes

isConflict

public boolean isConflict(java.lang.String requestLock,
                          java.lang.String holdLock)
                   throws ConflictUndefinedException
Description copied from interface: ConflictTable
Tests if there is conflict between two lock modes. Note that it is important to differentiate between the requested and hold lock modes, since the conflict table can be assymetric.

Specified by:
isConflict in interface ConflictTable
Parameters:
requestLock - requested lock mode
holdLock - hold lock mode
Returns:
true if given lock modes are conflicting, false otherwise
Throws:
ConflictUndefinedException - if conflict between given lock modes is undefined