aboutsummaryrefslogtreecommitdiff
path: root/src/org/json/simple/parser/Yytoken.java
blob: d67dbae63dfc27e1b35d1b5d7404989fdc081f4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
 * $Id: Yytoken.java,v 1.1 2006/04/15 14:10:48 platform Exp $
 * Created on 2006-4-15
 */
package org.json.simple.parser;

/**
 * @author FangYidong<fangyidong@yahoo.com.cn>
 */
public class Yytoken {
	public static final int TYPE_VALUE = 0;// JSON primitive value:
											// string,number,boolean,null
	public static final int TYPE_LEFT_BRACE = 1;
	public static final int TYPE_RIGHT_BRACE = 2;
	public static final int TYPE_LEFT_SQUARE = 3;
	public static final int TYPE_RIGHT_SQUARE = 4;
	public static final int TYPE_COMMA = 5;
	public static final int TYPE_COLON = 6;
	public static final int TYPE_EOF = -1;// end of file

	public int type = 0;
	public Object value = null;

	public Yytoken(final int type, final Object value) {
		this.type = type;
		this.value = value;
	}

	@Override
	public String toString() {
		final StringBuffer sb = new StringBuffer();
		switch (this.type) {
		case TYPE_VALUE:
			sb.append("VALUE(").append(this.value).append(")");
			break;
		case TYPE_LEFT_BRACE:
			sb.append("LEFT BRACE({)");
			break;
		case TYPE_RIGHT_BRACE:
			sb.append("RIGHT BRACE(})");
			break;
		case TYPE_LEFT_SQUARE:
			sb.append("LEFT SQUARE([)");
			break;
		case TYPE_RIGHT_SQUARE:
			sb.append("RIGHT SQUARE(])");
			break;
		case TYPE_COMMA:
			sb.append("COMMA(,)");
			break;
		case TYPE_COLON:
			sb.append("COLON(:)");
			break;
		case TYPE_EOF:
			sb.append("END OF FILE");
			break;
		}
		return sb.toString();
	}
}