Top Description Inners Constructors Methods
com.google.gson.internal

public final Class Streams

extends Object
Class Inheritance
Imports
com.google.gson.JsonElement, .JsonIOException, .JsonNull, .JsonParseException, .JsonSyntaxException, com.google.gson.internal.bind.JsonElementTypeAdapter, com.google.gson.stream.JsonReader, .JsonToken, .JsonWriter, .MalformedJsonException, java.io.Closeable, .EOFException, .Flushable, .IOException, .Writer, java.util.Objects

Reads and writes GSON parse trees over streams.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
Streams.AppendableWriter

Adapts an Appendable so it can be passed anywhere a Writer is used.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static JsonElement
parse(JsonReader reader)

Takes a reader in any state and returns the next value as a JsonElement.

public static void
write(JsonElement element, JsonWriter writer)

Writes the JSON element to the writer, recursively.

public static Writer
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Streamsback to summary
private Streams()

Method Detail

parseback to summary
public static JsonElement parse(JsonReader reader) throws JsonParseException

Takes a reader in any state and returns the next value as a JsonElement.

writeback to summary
public static void write(JsonElement element, JsonWriter writer) throws IOException

Writes the JSON element to the writer, recursively.

writerForAppendableback to summary
public static Writer writerForAppendable(Appendable appendable)
com.google.gson.internal back to summary

private final Class Streams.AppendableWriter

extends Writer
Class Inheritance

Adapts an Appendable so it can be passed anywhere a Writer is used.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
Streams.AppendableWriter.CurrentWrite

A mutable char sequence pointing at a single char[].

Field Summary

Modifier and TypeField and Description
private final Appendable
private final Streams.AppendableWriter.CurrentWrite
Inherited from java.io.Writer:
lock

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Writer
append(CharSequence csq)

Overrides java.io.Writer.append.

Implements java.lang.Appendable.append.

Appends the specified character sequence to this writer.

public Writer
append(CharSequence csq, int start, int end)

Overrides java.io.Writer.append.

Implements java.lang.Appendable.append.

Appends a subsequence of the specified character sequence to this writer.

public void
close()

Implements abstract java.io.Writer.close.

Implements java.io.Closeable.close.

Closes the stream, flushing it first.

public void
flush()

Implements abstract java.io.Writer.flush.

Implements java.io.Flushable.flush.

Flushes the stream.

public void
write(char[] chars, int offset, int length)

Implements abstract java.io.Writer.write.

Writes a portion of an array of characters.

public void
write(int i)

Overrides java.io.Writer.write.

Writes a single character.

public void
write(String str, int off, int len)

Overrides java.io.Writer.write.

Writes a portion of a string.

Inherited from java.io.Writer:
appendnullWriterwritewrite

Field Detail

appendableback to summary
private final Appendable appendable
currentWriteback to summary
private final Streams.AppendableWriter.CurrentWrite currentWrite

Constructor Detail

AppendableWriterback to summary
pack-priv AppendableWriter(Appendable appendable)

Method Detail

appendback to summary
public Writer append(CharSequence csq) throws IOException

Overrides java.io.Writer.append.

Implements java.lang.Appendable.append.

Doc from java.io.Writer.append.

Appends the specified character sequence to this writer.

An invocation of this method of the form out.append(csq) when csq is not null, behaves in exactly the same way as the invocation

out.write(csq.toString())
out.write(csq.toString())

Depending on the specification of toString for the character sequence csq, the entire sequence may not be appended. For instance, invoking the toString method of a character buffer will return a subsequence whose content depends upon the buffer's position and limit.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
appendback to summary
public Writer append(CharSequence csq, int start, int end) throws IOException

Overrides java.io.Writer.append.

Implements java.lang.Appendable.append.

Doc from java.io.Writer.append.

Appends a subsequence of the specified character sequence to this writer.

An invocation of this method of the form out.append(csq, start, end) when csq is not null behaves in exactly the same way as the invocation

out.write(csq.subSequence(start, end).toString())
out.write(csq.subSequence(start, end).toString())
Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
closeback to summary
public void close() throws IOException

Implements abstract java.io.Writer.close.

Implements java.io.Closeable.close.

Doc from java.io.Writer.close.

Closes the stream, flushing it first. Once the stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously closed stream has no effect.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
flushback to summary
public void flush() throws IOException

Implements abstract java.io.Writer.flush.

Implements java.io.Flushable.flush.

Doc from java.io.Writer.flush.

Flushes the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams.

If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
writeback to summary
public void write(char[] chars, int offset, int length) throws IOException

Implements abstract java.io.Writer.write.

Doc from java.io.Writer.write.

Writes a portion of an array of characters.

Annotations
@SuppressWarnings:UngroupedOverloads
@Override
Exceptions
IOException:
If an I/O error occurs
writeback to summary
public void write(int i) throws IOException

Overrides java.io.Writer.write.

Doc from java.io.Writer.write.

Writes a single character. The character to be written is contained in the 16 low-order bits of the given integer value; the 16 high-order bits are ignored.

Subclasses that intend to support efficient single-character output should override this method.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
writeback to summary
public void write(String str, int off, int len) throws IOException

Overrides java.io.Writer.write.

Doc from java.io.Writer.write.

Writes a portion of a string.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
com.google.gson.internal back to summary

private Class Streams.AppendableWriter.CurrentWrite

extends Object
implements CharSequence
Class Inheritance
  • java.lang.Object
  • com.google.gson.internal.Streams.AppendableWriter.CurrentWrite
All Implemented Interfaces
java.lang.CharSequence

A mutable char sequence pointing at a single char[].

Field Summary

Modifier and TypeField and Description
private String
private char[]

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public char
charAt(int i)

Implements java.lang.CharSequence.charAt.

Returns the char value at the specified index.

public int
length()

Implements java.lang.CharSequence.length.

Returns the length of this character sequence.

pack-priv void
setChars(char[] chars)

public CharSequence
subSequence(int start, int end)

Implements java.lang.CharSequence.subSequence.

Returns a CharSequence that is a subsequence of this sequence.

public String
toString()

Overrides java.lang.Object.toString.

Implements java.lang.CharSequence.toString.

Returns a string containing the characters in this sequence in the same order as this sequence.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

cachedStringback to summary
private String cachedString
charsback to summary
private char[] chars

Constructor Detail

CurrentWriteback to summary
private CurrentWrite()

Method Detail

charAtback to summary
public char charAt(int i)

Implements java.lang.CharSequence.charAt.

Doc from java.lang.CharSequence.charAt.

Returns the char value at the specified index. An index ranges from zero to length() - 1. The first char value of the sequence is at index zero, the next at index one, and so on, as for array indexing.

If the char value specified by the index is a surrogate, the surrogate value is returned.

Annotations
@Override
lengthback to summary
public int length()

Implements java.lang.CharSequence.length.

Doc from java.lang.CharSequence.length.

Returns the length of this character sequence. The length is the number of 16-bit chars in the sequence.

Annotations
@Override
setCharsback to summary
pack-priv void setChars(char[] chars)
subSequenceback to summary
public CharSequence subSequence(int start, int end)

Implements java.lang.CharSequence.subSequence.

Doc from java.lang.CharSequence.subSequence.

Returns a CharSequence that is a subsequence of this sequence. The subsequence starts with the char value at the specified index and ends with the char value at index end - 1. The length (in chars) of the returned sequence is end - start, so if start == end then an empty sequence is returned.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Implements java.lang.CharSequence.toString.

Doc from java.lang.CharSequence.toString.

Returns a string containing the characters in this sequence in the same order as this sequence. The length of the string will be the length of this sequence.

Annotations
@Override