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