1 package org.djutils.decoderdumper;
2
3
4
5
6
7
8
9
10
11
12 public class HexAddressDecoder implements Decoder
13 {
14
15 private final int roundToMultiple;
16
17
18
19
20
21
22 public HexAddressDecoder(final int roundToMultiple)
23 {
24 this.roundToMultiple = roundToMultiple > 0 ? roundToMultiple : 1;
25 }
26
27
28 private String result = "";
29
30 @Override
31 public String getResult()
32 {
33 String retVal = this.result;
34 this.result = "";
35 return retVal;
36 }
37
38 @Override
39 public int getMaximumWidth()
40 {
41 return 8;
42 }
43
44 @Override
45 public boolean append(final int address, final byte theByte)
46 {
47 this.result = String.format("%08x", address / this.roundToMultiple * this.roundToMultiple);
48 return this.roundToMultiple > 1 && address % this.roundToMultiple == this.roundToMultiple - 1;
49 }
50
51 @Override
52 public boolean ignoreForIdenticalOutputCheck()
53 {
54 return true;
55 }
56
57 @Override
58 public String toString()
59 {
60 return "HexAddressDecoder [result=" + this.result + "]";
61 }
62
63 }