1 package org.djutils.decoderdumper;
2
3
4
5
6
7
8
9
10
11 public class FixedString implements Decoder
12 {
13
14
15
16
17 private final String fixedResult;
18
19
20 private boolean appendWasCalled = false;
21
22
23
24
25
26 public FixedString(final String fixedResult)
27 {
28 this.fixedResult = fixedResult;
29 }
30
31 @Override
32 public String getResult()
33 {
34 if (this.appendWasCalled)
35 {
36 this.appendWasCalled = false;
37 return this.fixedResult;
38 }
39 return "";
40 }
41
42 @Override
43 public int getMaximumWidth()
44 {
45 return this.fixedResult.length();
46 }
47
48 @Override
49 public boolean append(final int address, final byte theByte)
50 {
51 this.appendWasCalled = true;
52 return false;
53 }
54
55 @Override
56 public boolean ignoreForIdenticalOutputCheck()
57 {
58 return false;
59 }
60
61 @Override
62 public String toString()
63 {
64 return "FixedString [fixedResult=" + this.fixedResult + ", appendWasCalled=" + this.appendWasCalled + "]";
65 }
66
67 }