3 import net
.automatalib
.words
.Word
;
6 * Contains the full input for which non-determinism was observed, as well as the full new output
7 * and the (possibly shorter) old output with which it disagrees
9 * @author Ramon Janssen
11 public class CacheInconsistencyException
extends RuntimeException
{
12 private final Word oldOutput
, newOutput
, input
;
14 public CacheInconsistencyException(Word input
, Word oldOutput
, Word newOutput
) {
16 this.oldOutput
= oldOutput
;
17 this.newOutput
= newOutput
;
20 public CacheInconsistencyException(String message
, Word input
, Word oldOutput
, Word newOutput
) {
23 this.oldOutput
= oldOutput
;
24 this.newOutput
= newOutput
;
29 * The shortest cached output word which does not correspond with the new output
32 public Word
getOldOutput() {
33 return this.oldOutput
;
37 * The full new output word
40 public Word
getNewOutput() {
41 return this.newOutput
;
45 * The shortest sublist of the input word which still shows non-determinism
48 public Word
getShortestInconsistentInput() {
49 int indexOfInconsistency
= 0;
50 while (oldOutput
.getSymbol(indexOfInconsistency
).equals(newOutput
.getSymbol(indexOfInconsistency
))) {
51 indexOfInconsistency
++;
53 return this.input
.subWord(0, indexOfInconsistency
);
57 public String
toString() {
58 return "Non-determinism detected\nfull input:\n" + this.input
+ "\nfull new output:\n" + this.newOutput
+ "\nold output:\n" + this.oldOutput
;