Top Description Fields Constructors Methods
com.fasterxml.jackson.core.io

public Class SerializedString

extends Object
implements SerializableString, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, com.fasterxml.jackson.core.SerializableString
Imports
java.io.*, java.nio.ByteBuffer, java.util.Objects, com.fasterxml.jackson.core.SerializableString

String token that can lazily serialize String contained and then reuse that serialization later on. This is similar to JDBC prepared statements, for example, in that instances should only be created when they are used more than use; prime candidates are various serializers.

Class is final for performance reasons and since this is not designed to be extensible or customizable (customizations would occur in calling code)

Field Summary

Modifier and TypeField and Description
protected transient String
_jdkSerializeValue

Ugly hack, to work through the requirement that _value is indeed final, and that JDK serialization won't call ctor(s).

protected volatile char[]
protected volatile byte[]
protected volatile byte[]
protected final String
private static final JsonStringEncoder
private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
appendQuoted(char[]
Buffer to append JSON-escaped String into
buffer
,
int
Offset in buffer to append String at
offset
)

Implements com.fasterxml.jackson.core.SerializableString.appendQuoted.

Method that will append quoted characters of this String into given buffer.

public int
appendQuotedUTF8(byte[]
Buffer to append JSON-escaped String into
buffer
,
int
Offset in buffer to append String at
offset
)

Implements com.fasterxml.jackson.core.SerializableString.appendQuotedUTF8.

Method that will append quoted UTF-8 bytes of this String into given buffer, if there is enough room; if not, returns -1.

public int
appendUnquoted(char[]
Buffer to append literal (unescaped) String into
buffer
,
int
Offset in buffer to append String at
offset
)

Implements com.fasterxml.jackson.core.SerializableString.appendUnquoted.

Method that will append unquoted characters of this String into given buffer.

public int
appendUnquotedUTF8(byte[]
Buffer to append literal (unescaped) String into
buffer
,
int
Offset in buffer to append String at
offset
)

Implements com.fasterxml.jackson.core.SerializableString.appendUnquotedUTF8.

Method that will append unquoted ('raw') UTF-8 bytes of this String into given buffer.

public final char[]
asQuotedChars()

Implements com.fasterxml.jackson.core.SerializableString.asQuotedChars.

Accessor for accessing value that has been quoted (escaped) using JSON quoting rules (using backslash-prefixed codes) into a char array.

public final byte[]
asQuotedUTF8()

Implements com.fasterxml.jackson.core.SerializableString.asQuotedUTF8.

Accessor for accessing value that has been quoted (escaped) using JSON quoting rules (using backslash-prefixed codes), and encoded using UTF-8 encoding into a byte array.

public final byte[]
asUnquotedUTF8()

Implements com.fasterxml.jackson.core.SerializableString.asUnquotedUTF8.

Accessor for accessing value as is (without JSON quoting (ecaping)) encoded as UTF-8 byte array.

public final int
charLength()

Implements com.fasterxml.jackson.core.SerializableString.charLength.

Returns length of the String as characters

public final boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public final String
getValue()

Implements com.fasterxml.jackson.core.SerializableString.getValue.

Returns unquoted String that this object represents (and offers serialized forms for)

public final int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public int
putQuotedUTF8(ByteBuffer
java.nio.ByteBuffer to append String into
buffer
)

Implements com.fasterxml.jackson.core.SerializableString.putQuotedUTF8.

Method for appending JSON-escaped UTF-8 encoded String value into given java.nio.ByteBuffer, if it fits.

public int
putUnquotedUTF8(ByteBuffer
java.nio.ByteBuffer to append String into
buffer
)

Implements com.fasterxml.jackson.core.SerializableString.putUnquotedUTF8.

Method for appending unquoted ('raw') UTF-8 encoded String value into given java.nio.ByteBuffer, if it fits.

private void
protected Object
public final String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

private void
public int
writeQuotedUTF8(OutputStream
java.io.OutputStream to write String into
out
)

Implements com.fasterxml.jackson.core.SerializableString.writeQuotedUTF8.

Method for writing JSON-escaped UTF-8 encoded String value using given java.io.OutputStream.

public int
writeUnquotedUTF8(OutputStream
java.io.OutputStream to write String into
out
)

Implements com.fasterxml.jackson.core.SerializableString.writeUnquotedUTF8.

Method for writing unescaped UTF-8 encoded String value using given java.io.OutputStream.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

_jdkSerializeValueback to summary
protected transient String _jdkSerializeValue

Ugly hack, to work through the requirement that _value is indeed final, and that JDK serialization won't call ctor(s).

Since
2.1
_quotedCharsback to summary
protected volatile char[] _quotedChars
_quotedUTF8Refback to summary
protected volatile byte[] _quotedUTF8Ref
_unquotedUTF8Refback to summary
protected volatile byte[] _unquotedUTF8Ref
_valueback to summary
protected final String _value
JSON_ENCODERback to summary
private static final JsonStringEncoder JSON_ENCODER
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

SerializedStringback to summary
public SerializedString(String v)

Method Detail

appendQuotedback to summary
public int appendQuoted(char[] buffer, int offset)

Implements com.fasterxml.jackson.core.SerializableString.appendQuoted.

Doc from com.fasterxml.jackson.core.SerializableString.appendQuoted.

Method that will append quoted characters of this String into given buffer. Functionally equivalent to:

  char[] ch = str.asQuotedChars();
  System.arraycopy(ch, 0, buffer, offset, ch.length);
  return ch.length;
Parameters
buffer:char[]

Buffer to append JSON-escaped String into

offset:int

Offset in buffer to append String at

Returns:int

Number of characters appended, if successful, otherwise -1

Annotations
@Override
appendQuotedUTF8back to summary
public int appendQuotedUTF8(byte[] buffer, int offset)

Implements com.fasterxml.jackson.core.SerializableString.appendQuotedUTF8.

Doc from com.fasterxml.jackson.core.SerializableString.appendQuotedUTF8.

Method that will append quoted UTF-8 bytes of this String into given buffer, if there is enough room; if not, returns -1. Functionally equivalent to:

  byte[] bytes = str.asQuotedUTF8();
  System.arraycopy(bytes, 0, buffer, offset, bytes.length);
  return bytes.length;
Parameters
buffer:byte[]

Buffer to append JSON-escaped String into

offset:int

Offset in buffer to append String at

Returns:int

Number of bytes appended, if successful, otherwise -1

Annotations
@Override
appendUnquotedback to summary
public int appendUnquoted(char[] buffer, int offset)

Implements com.fasterxml.jackson.core.SerializableString.appendUnquoted.

Doc from com.fasterxml.jackson.core.SerializableString.appendUnquoted.

Method that will append unquoted characters of this String into given buffer. Functionally equivalent to:

  char[] ch = str.getValue().toCharArray();
  System.arraycopy(bytes, 0, buffer, offset, ch.length);
  return ch.length;
Parameters
buffer:char[]

Buffer to append literal (unescaped) String into

offset:int

Offset in buffer to append String at

Returns:int

Number of characters appended, if successful, otherwise -1

Annotations
@Override
appendUnquotedUTF8back to summary
public int appendUnquotedUTF8(byte[] buffer, int offset)

Implements com.fasterxml.jackson.core.SerializableString.appendUnquotedUTF8.

Doc from com.fasterxml.jackson.core.SerializableString.appendUnquotedUTF8.

Method that will append unquoted ('raw') UTF-8 bytes of this String into given buffer. Functionally equivalent to:

  byte[] bytes = str.asUnquotedUTF8();
  System.arraycopy(bytes, 0, buffer, offset, bytes.length);
  return bytes.length;
Parameters
buffer:byte[]

Buffer to append literal (unescaped) String into

offset:int

Offset in buffer to append String at

Returns:int

Number of bytes appended, if successful, otherwise -1

Annotations
@Override
asQuotedCharsback to summary
public final char[] asQuotedChars()

Implements com.fasterxml.jackson.core.SerializableString.asQuotedChars.

Accessor for accessing value that has been quoted (escaped) using JSON quoting rules (using backslash-prefixed codes) into a char array.

Returns:char[]

Doc from com.fasterxml.jackson.core.SerializableString.asQuotedChars.

JSON quoted form of the String as char[]

Annotations
@Override
asQuotedUTF8back to summary
public final byte[] asQuotedUTF8()

Implements com.fasterxml.jackson.core.SerializableString.asQuotedUTF8.

Accessor for accessing value that has been quoted (escaped) using JSON quoting rules (using backslash-prefixed codes), and encoded using UTF-8 encoding into a byte array.

Returns:byte[]

Doc from com.fasterxml.jackson.core.SerializableString.asQuotedUTF8.

UTF-8 encoded version of JSON-escaped String

Annotations
@Override
asUnquotedUTF8back to summary
public final byte[] asUnquotedUTF8()

Implements com.fasterxml.jackson.core.SerializableString.asUnquotedUTF8.

Accessor for accessing value as is (without JSON quoting (ecaping)) encoded as UTF-8 byte array.

Returns:byte[]

Doc from com.fasterxml.jackson.core.SerializableString.asUnquotedUTF8.

UTF-8 encoded version of String, without any escaping

Annotations
@Override
charLengthback to summary
public final int charLength()

Implements com.fasterxml.jackson.core.SerializableString.charLength.

Returns length of the String as characters

Returns:int

Doc from com.fasterxml.jackson.core.SerializableString.charLength.

Length of the String in characters

Annotations
@Override
equalsback to summary
public final boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getValueback to summary
public final String getValue()

Implements com.fasterxml.jackson.core.SerializableString.getValue.

Doc from com.fasterxml.jackson.core.SerializableString.getValue.

Returns unquoted String that this object represents (and offers serialized forms for)

Returns:String

Unquoted String

Annotations
@Override
hashCodeback to summary
public final int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
putQuotedUTF8back to summary
public int putQuotedUTF8(ByteBuffer buffer)

Implements com.fasterxml.jackson.core.SerializableString.putQuotedUTF8.

Doc from com.fasterxml.jackson.core.SerializableString.putQuotedUTF8.

Method for appending JSON-escaped UTF-8 encoded String value into given java.nio.ByteBuffer, if it fits.

Parameters
buffer:ByteBuffer

java.nio.ByteBuffer to append String into

Returns:int

Number of bytes put, if contents fit, otherwise -1

Annotations
@Override
putUnquotedUTF8back to summary
public int putUnquotedUTF8(ByteBuffer buffer)

Implements com.fasterxml.jackson.core.SerializableString.putUnquotedUTF8.

Doc from com.fasterxml.jackson.core.SerializableString.putUnquotedUTF8.

Method for appending unquoted ('raw') UTF-8 encoded String value into given java.nio.ByteBuffer, if it fits.

Parameters
buffer:ByteBuffer

java.nio.ByteBuffer to append String into

Returns:int

Number of bytes put, if contents fit, otherwise -1

Annotations
@Override
readObjectback to summary
private void readObject(ObjectInputStream in) throws IOException
readResolveback to summary
protected Object readResolve()
toStringback to summary
public final String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
writeObjectback to summary
private void writeObject(ObjectOutputStream out) throws IOException
writeQuotedUTF8back to summary
public int writeQuotedUTF8(OutputStream out) throws IOException

Implements com.fasterxml.jackson.core.SerializableString.writeQuotedUTF8.

Doc from com.fasterxml.jackson.core.SerializableString.writeQuotedUTF8.

Method for writing JSON-escaped UTF-8 encoded String value using given java.io.OutputStream.

Parameters
out:OutputStream

java.io.OutputStream to write String into

Returns:int

Number of bytes written

Annotations
@Override
Exceptions
IOException:
if underlying stream write fails
writeUnquotedUTF8back to summary
public int writeUnquotedUTF8(OutputStream out) throws IOException

Implements com.fasterxml.jackson.core.SerializableString.writeUnquotedUTF8.

Doc from com.fasterxml.jackson.core.SerializableString.writeUnquotedUTF8.

Method for writing unescaped UTF-8 encoded String value using given java.io.OutputStream.

Parameters
out:OutputStream

java.io.OutputStream to write String into

Returns:int

Number of bytes written

Annotations
@Override
Exceptions
IOException:
if underlying stream write fails