lishuai | 2ddc469 | 2015-07-31 15:15:16 +0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
lishuai | 2ddc469 | 2015-07-31 15:15:16 +0800 | [diff] [blame] | 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 | package org.onosproject.ovsdb.rfc.jsonrpc; |
| 17 | |
| 18 | import java.util.Stack; |
| 19 | |
| 20 | /** |
| 21 | * Context for decode parameters. |
| 22 | */ |
| 23 | public class JsonReadContext { |
| 24 | private Stack<Byte> bufStack; |
| 25 | private boolean isStartMatch; |
| 26 | private int lastReadBytes; |
| 27 | |
| 28 | /** |
| 29 | * Constructs a JsonReadContext object. This class only need initial |
| 30 | * parameter value for the readToJsonNode method of JsonRpcReaderUtil |
| 31 | * entity. |
| 32 | */ |
| 33 | public JsonReadContext() { |
| 34 | bufStack = new Stack<Byte>(); |
| 35 | isStartMatch = false; |
| 36 | lastReadBytes = 0; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Return bufStack. |
| 41 | * @return bufStack |
| 42 | */ |
| 43 | public Stack<Byte> getBufStack() { |
| 44 | return bufStack; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Set bufStack, used for match the braces and double quotes. |
| 49 | * @param bufStack Stack of Byte |
| 50 | */ |
| 51 | public void setBufStack(Stack<Byte> bufStack) { |
| 52 | this.bufStack = bufStack; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Return isStartMatch. |
| 57 | * @return isStartMatch |
| 58 | */ |
| 59 | public boolean isStartMatch() { |
| 60 | return isStartMatch; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Set isStartMatch. |
| 65 | * @param isStartMatch mark whether the matching has started |
| 66 | */ |
| 67 | public void setStartMatch(boolean isStartMatch) { |
| 68 | this.isStartMatch = isStartMatch; |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Return lastReadBytes. |
| 73 | * @return lastReadBytes |
| 74 | */ |
| 75 | public int getLastReadBytes() { |
| 76 | return lastReadBytes; |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Set lastReadBytes. |
| 81 | * @param lastReadBytes the bytes for last decoding incomplete record |
| 82 | */ |
| 83 | public void setLastReadBytes(int lastReadBytes) { |
| 84 | this.lastReadBytes = lastReadBytes; |
| 85 | } |
| 86 | } |