com.mysql.cj.util

## Class LazyString

- java.lang.Object
- - com.mysql.cj.util.LazyString

All Implemented Interfaces:
  Supplier<String>

    public class LazyString
    extends Object
    implements Supplier<String>

A lazy string that can take a byte buffer and encoding and interpret it as a string if/when requested. The string is cached and saved for any further requests. "NULL" values can be represented by a 0-len string or a null passed to LazyString(String).

### Field Summary

Fields
`private byte[]` `buffer`
`private String` `encoding`
`private int` `length`
`private int` `offset`
`private String` `string`

### Constructor Summary

Constructors
Constructor and Description
`LazyString(byte[] buffer, int offset, int length)`
`LazyString(byte[] buffer, int offset, int length, String encoding)`
`LazyString(String string)`

### Method Summary

All Methods Instance Methods Concrete Methods
`private String` `createAndCacheString()`
`String` `get()`
`int` `length()`
`String` `toString()`

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

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

### Field Detail

#### string

    private String string

#### buffer

    private byte[] buffer

#### offset

    private int offset

#### length

    private int length

#### encoding

    private String encoding

### Constructor Detail

#### LazyString

    public LazyString(String string)

#### LazyString

    public LazyString(byte[] buffer,
                      int offset,
                      int length,
                      String encoding)

#### LazyString

    public LazyString(byte[] buffer,
                      int offset,
                      int length)

### Method Detail

#### createAndCacheString

    private String createAndCacheString()

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### length

    public int length()

#### get

    public String get()

Specified by:
  `get` in interface `Supplier<String>`

Copyright © 2016, 2025, Oracle and/or its affiliates.