1 package org.sapia.soto.state; 2 3 4 16 public class Result { 17 private String _nextState; 18 private String _currentState; 19 private boolean _errorHandled; 20 private boolean _aborted; 21 private Err _err; 22 private Context _ctx; 23 private StateMachine _stm; 24 25 public Result(StateMachine engine, Context ctx) { 26 _ctx = ctx; 27 _stm = engine; 28 } 29 30 34 public String getNextStateId() { 35 return _nextState; 36 } 37 38 42 public void setNextStateId(String id) { 43 _nextState = id; 44 } 45 46 51 public void abort() { 52 _aborted = true; 53 } 54 55 61 public boolean isAborted() { 62 return _aborted; 63 } 64 65 68 public boolean isError() { 69 return _err != null; 70 } 71 72 75 public Context getContext() { 76 return _ctx; 77 } 78 79 83 public void error(String msg) { 84 _err = new Err(msg); 85 } 86 87 91 public void error(Err err) { 92 _err = err; 93 } 94 95 99 public void setCurrentStateId(String id) { 100 _currentState = id; 101 } 102 103 106 public String getCurrentStateId() { 107 return _currentState; 108 } 109 110 115 public void error(String msg, Throwable err) { 116 _err = new Err(msg, err); 117 } 118 119 122 public void error(Throwable err) { 123 _err = new Err(err); 124 } 125 126 134 public Err handleError() throws IllegalStateException { 135 _errorHandled = true; 136 137 return _err; 138 } 139 140 147 public boolean isErrorHandled() { 148 return _errorHandled; 149 } 150 151 157 public void exec(String stateId, String module) 158 throws UnknownStateException, StateExecException { 159 _stm.execute(stateId, module, this); 160 } 161 162 165 void reset() { 166 _nextState = null; 167 } 168 169 173 Err getError() { 174 return _err; 175 } 176 } 177 | Popular Tags |