View Javadoc
1   package org.djutils.decoderdumper;
2   
3   import java.io.IOException;
4   
5   /**
6    * Decoder interface.
7    * <p>
8    * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
9    * BSD-style license. See <a href="https://djutils.org/docs/current/djutils/licenses.html">DJUTILS License</a>.
10   * </p>
11   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
12   * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a>
13   */
14  public interface Decoder
15  {
16      /**
17       * Retrieve the current result of this Decoder. Decoders that handle multiple byte input may be somewhere within a token.
18       * Such Decoders should report a partial result. If no data has been added, the result must be the empty string.
19       * @return String; the current result of this Decoder
20       */
21      String getResult();
22  
23      /**
24       * Retrieve the maximum width (in characters) of results that this Decoder can return (all shorter results will be padded to
25       * this width with spaces, unless this is the last active Decoder).
26       * @return int; the maximum width (in characters) of results that this Decoder can return
27       */
28      int getMaximumWidth();
29  
30      /**
31       * Decode one (more) byte. This method must return true when a line becomes full due to this call, otherwise this method
32       * must return false.
33       * @param address int; the address that corresponds with the byte
34       * @param theByte byte; the byte
35       * @return boolean; true if an output line has been completed by this call; false if at least one more byte can be appended
36       *         to the local accumulator before the current output line is full
37       * @throws IOException when the output device throws this exception
38       */
39      boolean append(int address, byte theByte) throws IOException;
40  
41      /**
42       * If the result of this Decoder should not be used to compare output lines for suppressing identical lines, this method
43       * should return true; otherwise it should return false.
44       * @return boolean; true if the result of this Decoder should be ignored in testing for identical output lines; otherwise
45       *         false
46       */
47      boolean ignoreForIdenticalOutputCheck();
48  
49  }