Class JsonDocument
- java.lang.Object
-
- de.dytanic.cloudnet.common.document.gson.JsonDocument
-
- All Implemented Interfaces:
IJsonDocPropertyable,IDocument<JsonDocument>,IPersistable,IReadable,java.io.Serializable,java.lang.Cloneable,java.lang.Iterable<java.lang.String>
public class JsonDocument extends java.lang.Object implements IDocument<JsonDocument>, java.lang.Cloneable
The Gson implementation of IDocument class. It includes simple append and remove operations, file reading and writing to create simple configuration files- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static JsonDocumentEMPTYstatic com.google.gson.GsonGSONprotected com.google.gson.JsonObjectjsonObject
-
Constructor Summary
Constructors Constructor Description JsonDocument()JsonDocument(com.google.gson.JsonElement jsonElement)Deprecated.causes issues because of the relocated Gson, will be made private in a future releaseJsonDocument(com.google.gson.JsonObject jsonObject)Deprecated.causes issues because of the relocated Gson, will be made private in a future releaseJsonDocument(java.lang.Object toObjectMirror)JsonDocument(java.lang.String key, JsonDocument value)JsonDocument(java.lang.String key, java.lang.Boolean value)JsonDocument(java.lang.String key, java.lang.Character value)JsonDocument(java.lang.String key, java.lang.Number value)JsonDocument(java.lang.String key, java.lang.Object value)JsonDocument(java.lang.String key, java.lang.String value)JsonDocument(java.lang.String key, java.util.Properties value)JsonDocument(java.util.Properties properties)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description @NotNull JsonDocumentappend(@NotNull java.io.Reader reader)JsonDocumentappend(com.google.gson.JsonObject jsonObject)Deprecated.causes issues because of the relocated Gson, will be made private in a future releaseJsonDocumentappend(JsonDocument document)JsonDocumentappend(java.lang.String key, byte[] bytes)JsonDocumentappend(java.lang.String key, JsonDocument value)JsonDocumentappend(java.lang.String key, java.lang.Boolean value)JsonDocumentappend(java.lang.String key, java.lang.Character value)JsonDocumentappend(java.lang.String key, java.lang.Number value)JsonDocumentappend(java.lang.String key, java.lang.Object value)JsonDocumentappend(java.lang.String key, java.lang.String value)JsonDocumentappend(java.lang.String key, java.util.Properties properties)JsonDocumentappend(java.util.Map<java.lang.String,java.lang.Object> map)JsonDocumentappend(java.util.Properties properties)JsonDocumentappendNull(java.lang.String key)JsonDocumentclear()JsonDocumentclone()booleancontains(java.lang.String key)com.google.gson.JsonElementget(java.lang.String key)Deprecated.causes issues because of the relocated Gson, will be removed in a future release<T> Tget(java.lang.String key, com.google.gson.Gson gson, java.lang.Class<T> clazz)<T> Tget(java.lang.String key, com.google.gson.Gson gson, java.lang.reflect.Type type)<T> Tget(java.lang.String key, java.lang.Class<T> clazz)<T> Tget(java.lang.String key, java.lang.Class<T> clazz, T def)<T> Tget(java.lang.String key, java.lang.reflect.Type type)<T> Tget(java.lang.String key, java.lang.reflect.Type type, T def)java.math.BigDecimalgetBigDecimal(java.lang.String key)java.math.BigDecimalgetBigDecimal(java.lang.String key, java.math.BigDecimal def)java.math.BigIntegergetBigInteger(java.lang.String key)java.math.BigIntegergetBigInteger(java.lang.String key, java.math.BigInteger def)byte[]getBinary(java.lang.String key)byte[]getBinary(java.lang.String key, byte[] def)booleangetBoolean(java.lang.String key)java.lang.BooleangetBoolean(java.lang.String key, java.lang.Boolean def)bytegetByte(java.lang.String key)chargetChar(java.lang.String key)java.lang.CharactergetChar(java.lang.String key, java.lang.Character def)JsonDocumentgetDocument(java.lang.String key)JsonDocumentgetDocument(java.lang.String key, JsonDocument def)doublegetDouble(java.lang.String key)java.lang.DoublegetDouble(java.lang.String key, java.lang.Double def)floatgetFloat(java.lang.String key)java.lang.FloatgetFloat(java.lang.String key, java.lang.Float def)intgetInt(java.lang.String key)java.lang.IntegergetInt(java.lang.String key, java.lang.Integer def)com.google.gson.JsonArraygetJsonArray(java.lang.String key)Deprecated.causes issues because of the relocated Gson, will be removed in a future releasecom.google.gson.JsonArraygetJsonArray(java.lang.String key, com.google.gson.JsonArray def)Deprecated.causes issues because of the relocated Gson, will be removed in a future releasecom.google.gson.JsonObjectgetJsonObject(java.lang.String key)Deprecated.causes issues because of the relocated Gson, will be removed in a future releasecom.google.gson.JsonObjectgetJsonObject(java.lang.String key, com.google.gson.JsonObject def)Deprecated.causes issues because of the relocated Gson, will be removed in a future releaselonggetLong(java.lang.String key)java.lang.LonggetLong(java.lang.String key, java.lang.Long def)JsonDocumentgetProperties()java.util.PropertiesgetProperties(java.lang.String key)java.util.PropertiesgetProperties(java.lang.String key, java.util.Properties def)<E> EgetProperty(JsonDocProperty<E> docProperty)shortgetShort(java.lang.String key)java.lang.ShortgetShort(java.lang.String key, java.lang.Short def)java.lang.StringgetString(java.lang.String key)java.lang.StringgetString(java.lang.String key, java.lang.String def)<E> booleanhasProperty(JsonDocProperty<E> docProperty)@NotNull java.util.Iterator<java.lang.String>iterator()java.util.Collection<java.lang.String>keys()static JsonDocumentnewDocument()static JsonDocumentnewDocument(byte[] bytes)static JsonDocumentnewDocument(com.google.gson.JsonObject jsonObject)Deprecated.causes issues because of the relocated Gson, will be removed in a future releasestatic JsonDocumentnewDocument(java.io.File file)Deprecated.static JsonDocumentnewDocument(java.io.InputStream stream)static JsonDocumentnewDocument(java.lang.Object object)static JsonDocumentnewDocument(java.lang.String json)static JsonDocumentnewDocument(java.lang.String key, java.lang.Boolean value)static JsonDocumentnewDocument(java.lang.String key, java.lang.Character value)static JsonDocumentnewDocument(java.lang.String key, java.lang.Number value)static JsonDocumentnewDocument(java.lang.String key, java.lang.Object value)static JsonDocumentnewDocument(java.lang.String key, java.lang.String value)static JsonDocumentnewDocument(java.nio.file.Path path)@NotNull JsonDocumentread(byte[] bytes)@NotNull JsonDocumentread(@NotNull java.io.InputStream inputStream)@NotNull JsonDocumentread(@NotNull java.io.Reader reader)JsonDocumentremove(java.lang.String key)<E> JsonDocumentremoveProperty(JsonDocProperty<E> docProperty)<E> JsonDocumentsetProperty(JsonDocProperty<E> docProperty, E val)intsize()byte[]toByteArray()<T> TtoInstanceOf(java.lang.Class<T> clazz)<T> TtoInstanceOf(java.lang.reflect.Type type)java.lang.StringtoJson()com.google.gson.JsonObjecttoJsonObject()Deprecated.causes issues because of the relocated Gson, will be removed in a future releasejava.lang.StringtoPrettyJson()java.lang.StringtoString()@NotNull JsonDocumentwrite(java.io.Writer writer)-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface de.dytanic.cloudnet.common.document.IPersistable
write, write, write, write, write, write, write
-
-
-
-
Field Detail
-
EMPTY
public static final JsonDocument EMPTY
-
GSON
public static final com.google.gson.Gson GSON
-
jsonObject
protected final com.google.gson.JsonObject jsonObject
-
-
Constructor Detail
-
JsonDocument
@Deprecated public JsonDocument(com.google.gson.JsonObject jsonObject)
Deprecated.causes issues because of the relocated Gson, will be made private in a future release
-
JsonDocument
public JsonDocument()
-
JsonDocument
public JsonDocument(java.lang.Object toObjectMirror)
-
JsonDocument
@Deprecated public JsonDocument(com.google.gson.JsonElement jsonElement)
Deprecated.causes issues because of the relocated Gson, will be made private in a future release
-
JsonDocument
public JsonDocument(java.util.Properties properties)
-
JsonDocument
public JsonDocument(java.lang.String key, java.lang.String value)
-
JsonDocument
public JsonDocument(java.lang.String key, java.lang.Object value)
-
JsonDocument
public JsonDocument(java.lang.String key, java.lang.Boolean value)
-
JsonDocument
public JsonDocument(java.lang.String key, java.lang.Number value)
-
JsonDocument
public JsonDocument(java.lang.String key, java.lang.Character value)
-
JsonDocument
public JsonDocument(java.lang.String key, JsonDocument value)
-
JsonDocument
public JsonDocument(java.lang.String key, java.util.Properties value)
-
-
Method Detail
-
newDocument
public static JsonDocument newDocument()
-
newDocument
@Deprecated public static JsonDocument newDocument(com.google.gson.JsonObject jsonObject)
Deprecated.causes issues because of the relocated Gson, will be removed in a future release
-
newDocument
public static JsonDocument newDocument(java.lang.String key, java.lang.String value)
-
newDocument
public static JsonDocument newDocument(java.lang.String key, java.lang.Number value)
-
newDocument
public static JsonDocument newDocument(java.lang.String key, java.lang.Character value)
-
newDocument
public static JsonDocument newDocument(java.lang.String key, java.lang.Boolean value)
-
newDocument
public static JsonDocument newDocument(java.lang.String key, java.lang.Object value)
-
newDocument
public static JsonDocument newDocument(byte[] bytes)
-
newDocument
public static JsonDocument newDocument(java.lang.Object object)
-
newDocument
@Deprecated public static JsonDocument newDocument(java.io.File file)
Deprecated.
-
newDocument
public static JsonDocument newDocument(java.nio.file.Path path)
-
newDocument
public static JsonDocument newDocument(java.io.InputStream stream)
-
newDocument
public static JsonDocument newDocument(java.lang.String json)
-
keys
public java.util.Collection<java.lang.String> keys()
- Specified by:
keysin interfaceIDocument<JsonDocument>
-
size
public int size()
- Specified by:
sizein interfaceIDocument<JsonDocument>
-
clear
public JsonDocument clear()
- Specified by:
clearin interfaceIDocument<JsonDocument>
-
remove
public JsonDocument remove(java.lang.String key)
- Specified by:
removein interfaceIDocument<JsonDocument>
-
contains
public boolean contains(java.lang.String key)
- Specified by:
containsin interfaceIDocument<JsonDocument>
-
toInstanceOf
public <T> T toInstanceOf(java.lang.Class<T> clazz)
- Specified by:
toInstanceOfin interfaceIDocument<JsonDocument>
-
toInstanceOf
public <T> T toInstanceOf(java.lang.reflect.Type type)
- Specified by:
toInstanceOfin interfaceIDocument<JsonDocument>
-
append
public JsonDocument append(java.lang.String key, java.lang.Object value)
- Specified by:
appendin interfaceIDocument<JsonDocument>
-
append
public JsonDocument append(java.lang.String key, java.lang.Number value)
- Specified by:
appendin interfaceIDocument<JsonDocument>
-
append
public JsonDocument append(java.lang.String key, java.lang.Boolean value)
- Specified by:
appendin interfaceIDocument<JsonDocument>
-
append
public JsonDocument append(java.lang.String key, java.lang.String value)
- Specified by:
appendin interfaceIDocument<JsonDocument>
-
append
public JsonDocument append(java.lang.String key, java.lang.Character value)
- Specified by:
appendin interfaceIDocument<JsonDocument>
-
append
public JsonDocument append(java.lang.String key, JsonDocument value)
- Specified by:
appendin interfaceIDocument<JsonDocument>
-
append
public JsonDocument append(JsonDocument document)
- Specified by:
appendin interfaceIDocument<JsonDocument>
-
append
@Deprecated public JsonDocument append(com.google.gson.JsonObject jsonObject)
Deprecated.causes issues because of the relocated Gson, will be made private in a future release
-
append
public JsonDocument append(java.util.Properties properties)
- Specified by:
appendin interfaceIDocument<JsonDocument>
-
append
public JsonDocument append(java.lang.String key, java.util.Properties properties)
- Specified by:
appendin interfaceIDocument<JsonDocument>
-
append
public JsonDocument append(java.lang.String key, byte[] bytes)
- Specified by:
appendin interfaceIDocument<JsonDocument>
-
append
public JsonDocument append(java.util.Map<java.lang.String,java.lang.Object> map)
- Specified by:
appendin interfaceIDocument<JsonDocument>
-
append
@NotNull public @NotNull JsonDocument append(@NotNull @NotNull java.io.Reader reader)
-
appendNull
public JsonDocument appendNull(java.lang.String key)
- Specified by:
appendNullin interfaceIDocument<JsonDocument>
-
getDocument
public JsonDocument getDocument(java.lang.String key)
- Specified by:
getDocumentin interfaceIDocument<JsonDocument>
-
getInt
public int getInt(java.lang.String key)
- Specified by:
getIntin interfaceIDocument<JsonDocument>
-
getDouble
public double getDouble(java.lang.String key)
- Specified by:
getDoublein interfaceIDocument<JsonDocument>
-
getFloat
public float getFloat(java.lang.String key)
- Specified by:
getFloatin interfaceIDocument<JsonDocument>
-
getByte
public byte getByte(java.lang.String key)
- Specified by:
getBytein interfaceIDocument<JsonDocument>
-
getShort
public short getShort(java.lang.String key)
- Specified by:
getShortin interfaceIDocument<JsonDocument>
-
getLong
public long getLong(java.lang.String key)
- Specified by:
getLongin interfaceIDocument<JsonDocument>
-
getBoolean
public boolean getBoolean(java.lang.String key)
- Specified by:
getBooleanin interfaceIDocument<JsonDocument>
-
getString
public java.lang.String getString(java.lang.String key)
- Specified by:
getStringin interfaceIDocument<JsonDocument>
-
getChar
public char getChar(java.lang.String key)
- Specified by:
getCharin interfaceIDocument<JsonDocument>
-
getBigDecimal
public java.math.BigDecimal getBigDecimal(java.lang.String key)
- Specified by:
getBigDecimalin interfaceIDocument<JsonDocument>
-
getBigInteger
public java.math.BigInteger getBigInteger(java.lang.String key)
- Specified by:
getBigIntegerin interfaceIDocument<JsonDocument>
-
getJsonArray
@Deprecated public com.google.gson.JsonArray getJsonArray(java.lang.String key)
Deprecated.causes issues because of the relocated Gson, will be removed in a future release
-
getJsonObject
@Deprecated public com.google.gson.JsonObject getJsonObject(java.lang.String key)
Deprecated.causes issues because of the relocated Gson, will be removed in a future release
-
getProperties
public java.util.Properties getProperties(java.lang.String key)
- Specified by:
getPropertiesin interfaceIDocument<JsonDocument>
-
get
@Deprecated public com.google.gson.JsonElement get(java.lang.String key)
Deprecated.causes issues because of the relocated Gson, will be removed in a future release
-
getBinary
public byte[] getBinary(java.lang.String key)
- Specified by:
getBinaryin interfaceIDocument<JsonDocument>
-
get
public <T> T get(java.lang.String key, java.lang.Class<T> clazz)- Specified by:
getin interfaceIDocument<JsonDocument>
-
get
public <T> T get(java.lang.String key, java.lang.reflect.Type type)- Specified by:
getin interfaceIDocument<JsonDocument>
-
get
public <T> T get(java.lang.String key, com.google.gson.Gson gson, java.lang.Class<T> clazz)
-
get
public <T> T get(java.lang.String key, com.google.gson.Gson gson, java.lang.reflect.Type type)
-
getInt
public java.lang.Integer getInt(java.lang.String key, java.lang.Integer def)
-
getShort
public java.lang.Short getShort(java.lang.String key, java.lang.Short def)
-
getBoolean
public java.lang.Boolean getBoolean(java.lang.String key, java.lang.Boolean def)
-
getLong
public java.lang.Long getLong(java.lang.String key, java.lang.Long def)
-
getDouble
public java.lang.Double getDouble(java.lang.String key, java.lang.Double def)
-
getFloat
public java.lang.Float getFloat(java.lang.String key, java.lang.Float def)
-
getString
public java.lang.String getString(java.lang.String key, java.lang.String def)
-
getDocument
public JsonDocument getDocument(java.lang.String key, JsonDocument def)
-
getJsonArray
@Deprecated public com.google.gson.JsonArray getJsonArray(java.lang.String key, com.google.gson.JsonArray def)Deprecated.causes issues because of the relocated Gson, will be removed in a future release
-
getJsonObject
@Deprecated public com.google.gson.JsonObject getJsonObject(java.lang.String key, com.google.gson.JsonObject def)Deprecated.causes issues because of the relocated Gson, will be removed in a future release
-
getBinary
public byte[] getBinary(java.lang.String key, byte[] def)
-
get
public <T> T get(java.lang.String key, java.lang.reflect.Type type, T def)
-
get
public <T> T get(java.lang.String key, java.lang.Class<T> clazz, T def)
-
getProperties
public java.util.Properties getProperties(java.lang.String key, java.util.Properties def)
-
getBigInteger
public java.math.BigInteger getBigInteger(java.lang.String key, java.math.BigInteger def)
-
getBigDecimal
public java.math.BigDecimal getBigDecimal(java.lang.String key, java.math.BigDecimal def)
-
getChar
public java.lang.Character getChar(java.lang.String key, java.lang.Character def)
-
write
@NotNull public @NotNull JsonDocument write(java.io.Writer writer)
- Specified by:
writein interfaceIPersistable
-
read
@NotNull public @NotNull JsonDocument read(@NotNull @NotNull java.io.Reader reader)
-
read
@NotNull public @NotNull JsonDocument read(byte[] bytes)
-
read
@NotNull public @NotNull JsonDocument read(@NotNull @NotNull java.io.InputStream inputStream)
-
setProperty
public <E> JsonDocument setProperty(JsonDocProperty<E> docProperty, E val)
- Specified by:
setPropertyin interfaceIJsonDocPropertyable
-
getProperty
public <E> E getProperty(JsonDocProperty<E> docProperty)
- Specified by:
getPropertyin interfaceIJsonDocPropertyable
-
removeProperty
public <E> JsonDocument removeProperty(JsonDocProperty<E> docProperty)
- Specified by:
removePropertyin interfaceIJsonDocPropertyable
-
hasProperty
public <E> boolean hasProperty(JsonDocProperty<E> docProperty)
- Specified by:
hasPropertyin interfaceIJsonDocPropertyable
-
getProperties
public JsonDocument getProperties()
- Specified by:
getPropertiesin interfaceIJsonDocPropertyable
-
toJsonObject
@Deprecated public com.google.gson.JsonObject toJsonObject()
Deprecated.causes issues because of the relocated Gson, will be removed in a future release
-
toPrettyJson
public java.lang.String toPrettyJson()
-
toJson
public java.lang.String toJson()
-
toByteArray
public byte[] toByteArray()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
iterator
@NotNull public @NotNull java.util.Iterator<java.lang.String> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<java.lang.String>
-
clone
public JsonDocument clone()
- Overrides:
clonein classjava.lang.Object
-
-