com.hazelcast.com.fasterxml.jackson.core.io

## Class SerializedString

- java.lang.Object
- - com.hazelcast.com.fasterxml.jackson.core.io.SerializedString

- All Implemented Interfaces:
    SerializableString, Serializable

      public class SerializedString
      extends Object
      implements SerializableString, 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

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected String` | `_jdkSerializeValue` Ugly hack, to work through the requirement that _value is indeed final, and that JDK serialization won't call ctor(s).
    `protected char[]` | `_quotedChars`
    `protected byte[]` | `_quotedUTF8Ref`
    `protected byte[]` | `_unquotedUTF8Ref`
    `protected String` | `_value`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SerializedString(String v)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `appendQuoted(char[] buffer, int offset)` Method that will append quoted characters of this String into given buffer.
    `int` | `appendQuotedUTF8(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.
    `int` | `appendUnquoted(char[] buffer, int offset)` Method that will append unquoted characters of this String into given buffer.
    `int` | `appendUnquotedUTF8(byte[] buffer, int offset)` Method that will append unquoted ('raw') UTF-8 bytes of this String into given buffer.
    `char[]` | `asQuotedChars()` Returns JSON quoted form of the String, as character array.
    `byte[]` | `asQuotedUTF8()` Accessor for accessing value as is (without JSON quoting) encoded using UTF-8 encoding.
    `byte[]` | `asUnquotedUTF8()` Accessor for accessing value that has been quoted using JSON quoting rules, and encoded using UTF-8 encoding.
    `int` | `charLength()` Returns length of the String as characters
    `boolean` | `equals(Object o)`
    `String` | `getValue()` Returns unquoted String that this object represents (and offers serialized forms for)
    `int` | `hashCode()`
    `int` | `putQuotedUTF8(ByteBuffer buffer)`
    `int` | `putUnquotedUTF8(ByteBuffer buffer)`
    `protected Object` | `readResolve()`
    `String` | `toString()`
    `int` | `writeQuotedUTF8(OutputStream out)`
    `int` | `writeUnquotedUTF8(OutputStream out)`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### _value

          protected final String _value

    - #### _quotedUTF8Ref

          protected byte[] _quotedUTF8Ref

    - #### _unquotedUTF8Ref

          protected byte[] _unquotedUTF8Ref

    - #### _quotedChars

          protected char[] _quotedChars

    - #### _jdkSerializeValue

          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

  - ### Constructor Detail

    - #### SerializedString

          public SerializedString(String v)

  - ### Method Detail

    - #### readResolve

          protected Object readResolve()

    - #### getValue

          public final String getValue()

      Description copied from interface: `SerializableString`
      Returns unquoted String that this object represents (and offers serialized forms for)
      Specified by:
        `getValue` in interface `SerializableString`

    - #### charLength

          public final int charLength()

      Returns length of the String as characters
      Specified by:
        `charLength` in interface `SerializableString`

    - #### asQuotedChars

          public final char[] asQuotedChars()

      Description copied from interface: `SerializableString`
      Returns JSON quoted form of the String, as character array. Result can be embedded as-is in textual JSON as property name or JSON String.
      Specified by:
        `asQuotedChars` in interface `SerializableString`

    - #### asUnquotedUTF8

          public final byte[] asUnquotedUTF8()

      Accessor for accessing value that has been quoted using JSON quoting rules, and encoded using UTF-8 encoding.
      Specified by:
        `asUnquotedUTF8` in interface `SerializableString`

    - #### asQuotedUTF8

          public final byte[] asQuotedUTF8()

      Accessor for accessing value as is (without JSON quoting) encoded using UTF-8 encoding.
      Specified by:
        `asQuotedUTF8` in interface `SerializableString`

    - #### appendQuotedUTF8

          public int appendQuotedUTF8(byte[] buffer,
                                      int offset)

      Description copied from interface: `SerializableString`
      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;

      Specified by:
        `appendQuotedUTF8` in interface `SerializableString`
      Returns:
        Number of bytes appended, if successful, otherwise -1

    - #### appendQuoted

          public int appendQuoted(char[] buffer,
                                  int offset)

      Description copied from interface: `SerializableString`
      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;

      Specified by:
        `appendQuoted` in interface `SerializableString`
      Returns:
        Number of characters appended, if successful, otherwise -1

    - #### appendUnquotedUTF8

          public int appendUnquotedUTF8(byte[] buffer,
                                        int offset)

      Description copied from interface: `SerializableString`
      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;

      Specified by:
        `appendUnquotedUTF8` in interface `SerializableString`
      Returns:
        Number of bytes appended, if successful, otherwise -1

    - #### appendUnquoted

          public int appendUnquoted(char[] buffer,
                                    int offset)

      Description copied from interface: `SerializableString`
      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;

      Specified by:
        `appendUnquoted` in interface `SerializableString`
      Returns:
        Number of characters appended, if successful, otherwise -1

    - #### writeQuotedUTF8

          public int writeQuotedUTF8(OutputStream out)
                              throws IOException

      Specified by:
        `writeQuotedUTF8` in interface `SerializableString`
      Returns:
        Number of bytes written
      Throws:
        `IOException`

    - #### writeUnquotedUTF8

          public int writeUnquotedUTF8(OutputStream out)
                                throws IOException

      Specified by:
        `writeUnquotedUTF8` in interface `SerializableString`
      Returns:
        Number of bytes written
      Throws:
        `IOException`

    - #### putQuotedUTF8

          public int putQuotedUTF8(ByteBuffer buffer)

      Specified by:
        `putQuotedUTF8` in interface `SerializableString`
      Returns:
        Number of bytes put, if successful, otherwise -1

    - #### putUnquotedUTF8

          public int putUnquotedUTF8(ByteBuffer buffer)

      Specified by:
        `putUnquotedUTF8` in interface `SerializableString`
      Returns:
        Number of bytes put, if successful, otherwise -1

    - #### toString

          public final String toString()

      Overrides:
        `toString` in class `Object`

    - #### hashCode

          public final int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public final boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

Copyright © 2020. All rights reserved.