Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OKBJavaConnector/ECJClient/src/ec/util/DecodeReturn.java @ 6152

Last change on this file since 6152 was 6152, checked in by bfarka, 13 years ago

added ecj and custom statistics to communicate with the okb services #1441

File size: 3.0 KB
Line 
1/*
2  Copyright 2006 by Sean Luke
3  Licensed under the Academic Free License version 3.0
4  See the file "LICENSE" for more information
5*/
6
7
8package ec.util;
9
10/*
11 * DecodeReturn.java
12 *
13 * Created: Sat Oct 23 15:23:39 1999
14 * By: Sean Luke
15 */
16
17/**
18 * DecodeReturn is used by Code to provide varied information returned
19 * when decoding.
20 * You start the decoding process by initializing the DecodeReturn
21 * on a string you want to decode items out of.  Then you repeatedly
22 * pass the DecodeReturn to Code.decode(...), and each time the
23 * DecodeReturn will contain information about the next token, namely,
24 * its type, the data of the token (depending on type, this
25 * can be in one of three slots, d, l, or s), and the start position
26 * for reading the next token.
27 *
28 * <p>In case of an error, type is set to DecodeReturn.T_ERROR,
29 * pos is kept at the token where the error occured, and
30 * s is set to an error message.
31 *
32 * @author Sean Luke
33 * @version 1.0
34 */
35
36public class DecodeReturn
37    {
38    /** The actual error is stored in the String slot */
39    public static final byte T_ERROR = -1;
40
41    public static final byte T_BOOLEAN = 0;
42    public static final byte T_BYTE = 1;
43    public static final byte T_CHAR = 2;
44    /** Same as T_CHAR */
45    public static final byte T_CHARACTER = 2;
46    public static final byte T_SHORT = 3;
47    public static final byte T_INT = 4;
48    /** Same as T_INT */
49    public static final byte T_INTEGER = 4;
50    public static final byte T_LONG = 5;
51    public static final byte T_FLOAT = 6;
52    public static final byte T_DOUBLE = 7;
53    public static final byte T_STRING = 8;
54
55    /** The Line number, if it has been posted. */
56    public int lineNumber = 0;
57   
58    /** The DecodeReturn type */
59    public byte type;
60
61    /** The DecodeReturn string that's read from. */
62    public String data;
63
64    /** The DecodeReturn new position in the string.  Set this yourself.
65        New values get set here automatically. */
66    public int pos;
67
68    /** Stores booleans (0=false), bytes, chars, shorts, ints, longs */
69    public long l;
70
71    /** Stores floats, doubles */
72    public double d;
73   
74    /** Stores strings, error messages */
75    public String s;
76
77    /** Use this to make a new DecodeReturn starting at position 0 */
78    public DecodeReturn(String _data) { data = _data; pos = 0; }
79
80    /** Use this to make a new DecodeReturn starting at some position */
81    public DecodeReturn(String _data, int _pos) { data = _data; pos = _pos; }
82
83    /** Sets the DecodeReturn to begin scanning at _pos, which should be valid. */
84    public DecodeReturn scanAt(int _pos)
85        {
86        pos = Math.min(Math.max(_pos,0),data.length());
87        return this;
88        }
89
90    /** Use this to reuse your DecodeReturn for another string */
91    public DecodeReturn reset(final String _data) { data = _data; pos = 0; return this; }
92   
93    /** Use this to reuse your DecodeReturn for another string */
94    public DecodeReturn reset(final String _data, int _pos) { data = _data; pos = _pos; return this; }
95    }
Note: See TracBrowser for help on using the repository browser.