001/* ============
002 * Orson Charts
003 * ============
004 * 
005 * (C)opyright 2013, 2014, by Object Refinery Limited.
006 * 
007 * http://www.object-refinery.com/orsoncharts/index.html
008 * 
009 * JSON.simple
010 * -----------
011 * The code in this file originates from the JSON.simple project by 
012 * FangYidong<fangyidong@yahoo.com.cn>:
013 * 
014 *     https://code.google.com/p/json-simple/
015 *  
016 * which is licensed under the Apache Software License version 2.0.  
017 * 
018 * It has been modified locally and repackaged under 
019 * com.orsoncharts.util.json.* to avoid conflicts with any other version that
020 * may be present on the classpath. 
021 * 
022 */
023
024package com.orsoncharts.util.json.parser;
025
026/**
027 * 
028 */
029public class Yytoken {
030    public static final int TYPE_VALUE = 0;//JSON primitive value: string,number,boolean,null
031    public static final int TYPE_LEFT_BRACE = 1;
032    public static final int TYPE_RIGHT_BRACE = 2;
033    public static final int TYPE_LEFT_SQUARE = 3;
034    public static final int TYPE_RIGHT_SQUARE = 4;
035    public static final int TYPE_COMMA = 5;
036    public static final int TYPE_COLON = 6;
037    public static final int TYPE_EOF = -1;//end of file
038    
039    public int type = 0;
040    public Object value = null;
041    
042    public Yytoken(int type,Object value){
043        this.type=type;
044        this.value=value;
045    }
046    
047    @Override
048    public String toString(){
049        StringBuilder sb = new StringBuilder();
050        switch (type) {
051        case TYPE_VALUE:
052            sb.append("VALUE(").append(value).append(")");
053            break;
054        case TYPE_LEFT_BRACE:
055            sb.append("LEFT BRACE({)");
056            break;
057        case TYPE_RIGHT_BRACE:
058            sb.append("RIGHT BRACE(})");
059            break;
060        case TYPE_LEFT_SQUARE:
061            sb.append("LEFT SQUARE([)");
062            break;
063        case TYPE_RIGHT_SQUARE:
064            sb.append("RIGHT SQUARE(])");
065            break;
066        case TYPE_COMMA:
067            sb.append("COMMA(,)");
068            break;
069        case TYPE_COLON:
070            sb.append("COLON(:)");
071            break;
072        case TYPE_EOF:
073            sb.append("END OF FILE");
074            break;
075        }
076        return sb.toString();
077    }
078}