| 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 | * Lexical scoping elements within a JSON reader or writer. |
| 21 | * |
| 22 | * @author Jesse Wilson |
| 23 | * @since 1.6 |
| 24 | */ |
| 25 | final class JsonScope { |
| 26 | |
| 27 | /** |
| 28 | * An array with no elements requires no separators or newlines before |
| 29 | * it is closed. |
| 30 | */ |
| 31 | static final int EMPTY_ARRAY = 1; |
| 32 | |
| 33 | /** |
| 34 | * A array with at least one value requires a comma and newline before |
| 35 | * the next element. |
| 36 | */ |
| 37 | static final int NONEMPTY_ARRAY = 2; |
| 38 | |
| 39 | /** |
| 40 | * An object with no name/value pairs requires no separators or newlines |
| 41 | * before it is closed. |
| 42 | */ |
| 43 | static final int EMPTY_OBJECT = 3; |
| 44 | |
| 45 | /** |
| 46 | * An object whose most recent element is a key. The next element must |
| 47 | * be a value. |
| 48 | */ |
| 49 | static final int DANGLING_NAME = 4; |
| 50 | |
| 51 | /** |
| 52 | * An object with at least one name/value pair requires a comma and |
| 53 | * newline before the next element. |
| 54 | */ |
| 55 | static final int NONEMPTY_OBJECT = 5; |
| 56 | |
| 57 | /** |
| 58 | * No object or array has been started. |
| 59 | */ |
| 60 | static final int EMPTY_DOCUMENT = 6; |
| 61 | |
| 62 | /** |
| 63 | * A document with at an array or object. |
| 64 | */ |
| 65 | static final int NONEMPTY_DOCUMENT = 7; |
| 66 | |
| 67 | /** |
| 68 | * A document that's been closed and cannot be accessed. |
| 69 | */ |
| 70 | static final int CLOSED = 8; |
| 71 | } |