copy JsonReader.java and JsonWriter.java from AOSP

This commit is contained in:
Julian Winkler
2024-06-24 18:47:14 +02:00
committed by Mis012
parent 50e8bcda22
commit 051e80ae91
5 changed files with 1855 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,68 @@
/*
* Copyright (C) 2010 The Android Open Source Project
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*/
package android.util;
/**
* Lexical scoping elements within a JSON reader or writer.
*/
enum JsonScope {
/**
* An array with no elements requires no separators or newlines before
* it is closed.
*/
EMPTY_ARRAY,
/**
* A array with at least one value requires a comma and newline before
* the next element.
*/
NONEMPTY_ARRAY,
/**
* An object with no name/value pairs requires no separators or newlines
* before it is closed.
*/
EMPTY_OBJECT,
/**
* An object whose most recent element is a key. The next element must
* be a value.
*/
DANGLING_NAME,
/**
* An object with at least one name/value pair requires a comma and
* newline before the next element.
*/
NONEMPTY_OBJECT,
/**
* No object or array has been started.
*/
EMPTY_DOCUMENT,
/**
* A document with at an array or object.
*/
NONEMPTY_DOCUMENT,
/**
* A document that's been closed and cannot be accessed.
*/
CLOSED,
}

View File

@@ -0,0 +1,82 @@
/*
* Copyright (C) 2010 The Android Open Source Project
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*/
package android.util;
/**
* A structure, name or value type in a JSON-encoded string.
*/
public enum JsonToken {
/**
* The opening of a JSON array. Written using {@link JsonWriter#beginObject}
* and read using {@link JsonReader#beginObject}.
*/
BEGIN_ARRAY,
/**
* The closing of a JSON array. Written using {@link JsonWriter#endArray}
* and read using {@link JsonReader#endArray}.
*/
END_ARRAY,
/**
* The opening of a JSON object. Written using {@link JsonWriter#beginObject}
* and read using {@link JsonReader#beginObject}.
*/
BEGIN_OBJECT,
/**
* The closing of a JSON object. Written using {@link JsonWriter#endObject}
* and read using {@link JsonReader#endObject}.
*/
END_OBJECT,
/**
* A JSON property name. Within objects, tokens alternate between names and
* their values. Written using {@link JsonWriter#name} and read using {@link
* JsonReader#nextName}
*/
NAME,
/**
* A JSON string.
*/
STRING,
/**
* A JSON number represented in this API by a Java {@code double}, {@code
* long}, or {@code int}.
*/
NUMBER,
/**
* A JSON {@code true} or {@code false}.
*/
BOOLEAN,
/**
* A JSON {@code null}.
*/
NULL,
/**
* The end of the JSON stream. This sentinel value is returned by {@link
* JsonReader#peek()} to signal that the JSON-encoded value has no more
* tokens.
*/
END_DOCUMENT
}

File diff suppressed because it is too large Load Diff

View File

@@ -370,6 +370,10 @@ hax_jar = jar('hax', [
'android/util/DecompiledXmlResourceParser.java', 'android/util/DecompiledXmlResourceParser.java',
'android/util/DisplayMetrics.java', 'android/util/DisplayMetrics.java',
'android/util/FloatMath.java', 'android/util/FloatMath.java',
'android/util/JsonReader.java',
'android/util/JsonScope.java',
'android/util/JsonToken.java',
'android/util/JsonWriter.java',
'android/util/LayoutDirection.java', 'android/util/LayoutDirection.java',
'android/util/Log.java', 'android/util/Log.java',
'android/util/LongSparseArray.java', 'android/util/LongSparseArray.java',