Package com.fasterxml.jackson.core.io
Class SerializedString
- java.lang.Object
-
- com.fasterxml.jackson.core.io.SerializedString
-
- All Implemented Interfaces:
SerializableString,java.io.Serializable
public class SerializedString extends java.lang.Object implements SerializableString, java.io.Serializable
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)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SerializedString(java.lang.String v)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intappendQuoted(char[] buffer, int offset)Method that will append quoted characters of this String into given buffer.intappendQuotedUTF8(byte[] buffer, int offset)Method that will append quoted UTF-8 bytes of this String into given buffer, if there is enough room; if not, returns -1.intappendUnquoted(char[] buffer, int offset)Method that will append unquoted characters of this String into given buffer.intappendUnquotedUTF8(byte[] buffer, int offset)Method that will append unquoted ('raw') UTF-8 bytes of this String into given buffer.char[]asQuotedChars()Accessor for accessing value that has been quoted (escaped) using JSON quoting rules (using backslash-prefixed codes) into a char array.byte[]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.byte[]asUnquotedUTF8()Accessor for accessing value as is (without JSON quoting (ecaping)) encoded as UTF-8 byte array.intcharLength()Returns length of the String as charactersbooleanequals(java.lang.Object o)java.lang.StringgetValue()Returns unquoted String that this object represents (and offers serialized forms for)inthashCode()intputQuotedUTF8(java.nio.ByteBuffer buffer)intputUnquotedUTF8(java.nio.ByteBuffer buffer)java.lang.StringtoString()intwriteQuotedUTF8(java.io.OutputStream out)intwriteUnquotedUTF8(java.io.OutputStream out)
-
-
-
Method Detail
-
getValue
public final java.lang.String getValue()
Description copied from interface:SerializableStringReturns unquoted String that this object represents (and offers serialized forms for)- Specified by:
getValuein interfaceSerializableString
-
charLength
public final int charLength()
Returns length of the String as characters- Specified by:
charLengthin interfaceSerializableString
-
asQuotedChars
public final char[] asQuotedChars()
Accessor for accessing value that has been quoted (escaped) using JSON quoting rules (using backslash-prefixed codes) into a char array.- Specified by:
asQuotedCharsin interfaceSerializableString
-
asQuotedUTF8
public final byte[] 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.- Specified by:
asQuotedUTF8in interfaceSerializableString
-
asUnquotedUTF8
public final byte[] asUnquotedUTF8()
Accessor for accessing value as is (without JSON quoting (ecaping)) encoded as UTF-8 byte array.- Specified by:
asUnquotedUTF8in interfaceSerializableString
-
appendQuoted
public int appendQuoted(char[] buffer, int offset)Description copied from interface:SerializableStringMethod 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;
- Specified by:
appendQuotedin interfaceSerializableString- Returns:
- Number of characters appended, if successful, otherwise -1
-
appendQuotedUTF8
public int appendQuotedUTF8(byte[] buffer, int offset)Description copied from interface:SerializableStringMethod 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;
- Specified by:
appendQuotedUTF8in interfaceSerializableString- Returns:
- Number of bytes appended, if successful, otherwise -1
-
appendUnquoted
public int appendUnquoted(char[] buffer, int offset)Description copied from interface:SerializableStringMethod 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;
- Specified by:
appendUnquotedin interfaceSerializableString- Returns:
- Number of characters appended, if successful, otherwise -1
-
appendUnquotedUTF8
public int appendUnquotedUTF8(byte[] buffer, int offset)Description copied from interface:SerializableStringMethod 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;
- Specified by:
appendUnquotedUTF8in interfaceSerializableString- Returns:
- Number of bytes appended, if successful, otherwise -1
-
writeQuotedUTF8
public int writeQuotedUTF8(java.io.OutputStream out) throws java.io.IOException- Specified by:
writeQuotedUTF8in interfaceSerializableString- Returns:
- Number of bytes written
- Throws:
java.io.IOException
-
writeUnquotedUTF8
public int writeUnquotedUTF8(java.io.OutputStream out) throws java.io.IOException- Specified by:
writeUnquotedUTF8in interfaceSerializableString- Returns:
- Number of bytes written
- Throws:
java.io.IOException
-
putQuotedUTF8
public int putQuotedUTF8(java.nio.ByteBuffer buffer)
- Specified by:
putQuotedUTF8in interfaceSerializableString- Returns:
- Number of bytes put, if successful, otherwise -1
-
putUnquotedUTF8
public int putUnquotedUTF8(java.nio.ByteBuffer buffer)
- Specified by:
putUnquotedUTF8in interfaceSerializableString- Returns:
- Number of bytes put, if successful, otherwise -1
-
toString
public final java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public final int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public final boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
-