Stringifier (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.io, interface: Stringifier

Package org.apache.hadoop.io

# Interface Stringifier<T>

Type Parameters:
  `T` - the class of the objects to stringify

All Superinterfaces:
  `AutoCloseable`, `Closeable`

All Known Implementing Classes:
  `DefaultStringifier`

@Public @Stable public interface Stringifier<T> extends Closeable
Stringifier interface offers two methods to convert an object to a string representation and restore the object given its string representation.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  Closes this object.
  `T`
  `fromString(String str)`
  Restores the object from its string representation.
  `String`
  `toString(T obj)`
  Converts the object to a string representation

- ## Method Details

  - ### toString

    String toString(T obj) throws IOException
    Converts the object to a string representation
    Parameters:
      `obj` - the object to convert
    Returns:
      the string representation of the object
    Throws:
      `IOException` - if the object cannot be converted

  - ### fromString

    T fromString(String str) throws IOException
    Restores the object from its string representation.
    Parameters:
      `str` - the string representation of the object
    Returns:
      restored object
    Throws:
      `IOException` - if the object cannot be restored

  - ### close

    void close() throws IOException
    Closes this object.
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `Closeable`
    Throws:
      `IOException` - if an I/O error occurs