Package com.cedarsoftware.io
Class JsonValue
java.lang.Object
com.cedarsoftware.io.JsonValue
- Direct Known Subclasses:
JsonObject
This class is the parent class for all parsed JSON objects, arrays, or primitive values.
- Author:
- John DeRegnaucourt ([email protected])
Copyright (c) Cedar Software LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
License
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intstatic final Stringprotected longstatic final Stringprotected booleanstatic final Stringstatic final Stringprotected intstatic final Stringprotected Longstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected Objectstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidClears the type resolution cache.intgetCol()longgetId()Class<?>Deprecated.This method will be removed in a future version.intgetLine()static intGets the current maximum size of the type resolution cache.Class<?>getType()static intGets the current number of entries in the type resolution cache.booleanhasId()A JsonObject starts off with an id of -1.abstract booleanisArray()booleanbooleanvoidsetFinishedTarget(Object o, boolean isFinished) voidsetId(long id) voidsetJavaType(Class<?> type) Deprecated.This method will be removed in a future version.static voidsetMaxTypeResolutionCacheSize(int cacheSize) Sets the maximum size of the type resolution cache.voidsetReferenceId(Long id) voidSets the type on this JsonValue.
-
Field Details
-
KEYS
- See Also:
-
ITEMS
- See Also:
-
ID
- See Also:
-
REF
- See Also:
-
TYPE
- See Also:
-
ENUM
- See Also:
-
SHORT_TYPE
- See Also:
-
SHORT_ITEMS
- See Also:
-
SHORT_KEYS
- See Also:
-
SHORT_ID
- See Also:
-
SHORT_REF
- See Also:
-
VALUE
- See Also:
-
target
-
isFinished
protected boolean isFinished -
id
protected long id -
refId
-
line
protected int line -
col
protected int col
-
-
Constructor Details
-
JsonValue
public JsonValue()
-
-
Method Details
-
getLine
public int getLine() -
getCol
public int getCol() -
isReference
public boolean isReference() -
getReferenceId
-
setReferenceId
-
isFinished
public boolean isFinished() -
setFinished
public void setFinished() -
setTarget
-
setFinishedTarget
-
getTarget
-
isArray
public abstract boolean isArray() -
getType
-
setType
Sets the type on this JsonValue. Uses a cache to avoid repeated resolution checks for the same types. -
getRawType
-
getRawTypeName
-
getId
public long getId() -
setId
public void setId(long id) -
hasId
public boolean hasId()A JsonObject starts off with an id of -1. Also, an id of 0 is not considered a valid id. It must be 1 or greater. JsonWriter utilizes this fact. -
setJavaType
Deprecated.This method will be removed in a future version. Use setType() instead.Do not use this method. Call setType() instead. -
getJavaType
Deprecated.This method will be removed in a future version. Use getRawType() instead.Do not use this method. Call getType() or getRawType() instead. -
setMaxTypeResolutionCacheSize
public static void setMaxTypeResolutionCacheSize(int cacheSize) Sets the maximum size of the type resolution cache. This affects all JsonValue instances as the cache is static.- Parameters:
cacheSize- int maximum number of entries to cache. Must be at least 1.- Throws:
JsonIoException- if cacheSize is less than 1
-
getMaxTypeResolutionCacheSize
public static int getMaxTypeResolutionCacheSize()Gets the current maximum size of the type resolution cache.- Returns:
- int current maximum cache size
-
getTypeResolutionCacheSize
public static int getTypeResolutionCacheSize()Gets the current number of entries in the type resolution cache.- Returns:
- int current cache size
-
clearTypeResolutionCache
public static void clearTypeResolutionCache()Clears the type resolution cache. This may be useful for memory management in long-running applications.
-