This project has retired. For details please refer to its Attic page.
Yytoken xref

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.chemistry.opencmis.commons.impl.json.parser;
20  
21  /**
22   * (Taken from JSON.simple <http://code.google.com/p/json-simple/> and modified
23   * for OpenCMIS.)
24   * 
25   * @author FangYidong<fangyidong@yahoo.com.cn>
26   */
27  public class Yytoken {
28      public static final int TYPE_VALUE = 0;// JSON primitive value:
29                                             // string,number,boolean,null
30      public static final int TYPE_LEFT_BRACE = 1;
31      public static final int TYPE_RIGHT_BRACE = 2;
32      public static final int TYPE_LEFT_SQUARE = 3;
33      public static final int TYPE_RIGHT_SQUARE = 4;
34      public static final int TYPE_COMMA = 5;
35      public static final int TYPE_COLON = 6;
36      public static final int TYPE_EOF = -1;// end of file
37  
38      public int type = 0;
39      public Object value = null;
40  
41      public Yytoken(int type, Object value) {
42          this.type = type;
43          this.value = value;
44      }
45  
46      public String toString() {
47          StringBuilder sb = new StringBuilder();
48          switch (type) {
49          case TYPE_VALUE:
50              sb.append("VALUE(").append(value).append(")");
51              break;
52          case TYPE_LEFT_BRACE:
53              sb.append("LEFT BRACE({)");
54              break;
55          case TYPE_RIGHT_BRACE:
56              sb.append("RIGHT BRACE(})");
57              break;
58          case TYPE_LEFT_SQUARE:
59              sb.append("LEFT SQUARE([)");
60              break;
61          case TYPE_RIGHT_SQUARE:
62              sb.append("RIGHT SQUARE(])");
63              break;
64          case TYPE_COMMA:
65              sb.append("COMMA(,)");
66              break;
67          case TYPE_COLON:
68              sb.append("COLON(:)");
69              break;
70          case TYPE_EOF:
71              sb.append("END OF FILE");
72              break;
73          }
74          return sb.toString();
75      }
76  }