1 /*
2  * Copyright (C) 2010 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package com.google.gson.stream;
18
19 /**
20  * A structure, name or value type in a JSON-encoded string.
21  *
22  * @author Jesse Wilson
23  * @since 1.6
24  */

25 public enum JsonToken {
26
27   /**
28    * The opening of a JSON array. Written using {@link JsonWriter#beginArray}
29    * and read using {@link JsonReader#beginArray}.
30    */

31   BEGIN_ARRAY,
32
33   /**
34    * The closing of a JSON array. Written using {@link JsonWriter#endArray}
35    * and read using {@link JsonReader#endArray}.
36    */

37   END_ARRAY,
38
39   /**
40    * The opening of a JSON object. Written using {@link JsonWriter#beginObject}
41    * and read using {@link JsonReader#beginObject}.
42    */

43   BEGIN_OBJECT,
44
45   /**
46    * The closing of a JSON object. Written using {@link JsonWriter#endObject}
47    * and read using {@link JsonReader#endObject}.
48    */

49   END_OBJECT,
50
51   /**
52    * A JSON property name. Within objects, tokens alternate between names and
53    * their values. Written using {@link JsonWriter#name} and read using {@link
54    * JsonReader#nextName}
55    */

56   NAME,
57
58   /**
59    * A JSON string.
60    */

61   STRING,
62
63   /**
64    * A JSON number represented in this API by a Java {@code double}, {@code
65    * long}, or {@code int}.
66    */

67   NUMBER,
68
69   /**
70    * A JSON {@code true} or {@code false}.
71    */

72   BOOLEAN,
73
74   /**
75    * A JSON {@code null}.
76    */

77   NULL,
78
79   /**
80    * The end of the JSON stream. This sentinel value is returned by {@link
81    * JsonReader#peek()} to signal that the JSON-encoded value has no more
82    * tokens.
83    */

84   END_DOCUMENT
85 }
86