00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 package com.sleepycat.db;
00011
00012 import com.sleepycat.db.internal.DbConstants;
00013
00014 public final class RecoveryOperation {
00015 public static final RecoveryOperation BACKWARD_ROLL =
00016 new RecoveryOperation("BACKWARD_ROLL", DbConstants.DB_TXN_BACKWARD_ROLL);
00017 public static final RecoveryOperation FORWARD_ROLL =
00018 new RecoveryOperation("FORWARD_ROLL", DbConstants.DB_TXN_FORWARD_ROLL);
00019 public static final RecoveryOperation ABORT =
00020 new RecoveryOperation("ABORT", DbConstants.DB_TXN_ABORT);
00021 public static final RecoveryOperation APPLY =
00022 new RecoveryOperation("APPLY", DbConstants.DB_TXN_APPLY);
00023 public static final RecoveryOperation PRINT =
00024 new RecoveryOperation("PRINT", DbConstants.DB_TXN_PRINT);
00025
00026 private String operationName;
00027 private int flag;
00028
00029 private RecoveryOperation(String operationName, int flag) {
00030 this.operationName = operationName;
00031 this.flag = flag;
00032 }
00033
00034 public String toString() {
00035 return "RecoveryOperation." + operationName;
00036 }
00037
00038
00039 public static RecoveryOperation fromFlag(int flag) {
00040 switch (flag) {
00041 case DbConstants.DB_TXN_BACKWARD_ROLL:
00042 return BACKWARD_ROLL;
00043 case DbConstants.DB_TXN_FORWARD_ROLL:
00044 return FORWARD_ROLL;
00045 case DbConstants.DB_TXN_ABORT:
00046 return ABORT;
00047 case DbConstants.DB_TXN_APPLY:
00048 return APPLY;
00049 case DbConstants.DB_TXN_PRINT:
00050 return PRINT;
00051 default:
00052 throw new IllegalArgumentException(
00053 "Unknown recover operation: " + flag);
00054 }
00055 }
00056 }