Class SerializableCharset

  • All Implemented Interfaces:
    java.io.Serializable

    public class SerializableCharset
    extends java.lang.Object
    implements java.io.Serializable
    Serializable wrapper around a Charset.

    It serializes itself by writing out the name of the character set, for example "ISO-8859-1". On the other side, it deserializes itself by looking for a charset with the same name.

    A SerializableCharset is immutable.

    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.nio.charset.Charset charset  
      private java.lang.String charsetName  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private SerializableCharset​(java.nio.charset.Charset charset)
      Creates a SerializableCharset.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static SerializableCharset forCharset​(java.nio.charset.Charset charset)
      Returns a SerializableCharset wrapping the given Charset, or null if the charset is null.
      java.nio.charset.Charset getCharset()
      Returns the wrapped Charset.
      private void readObject​(java.io.ObjectInputStream in)
      Per Serializable.
      private void writeObject​(java.io.ObjectOutputStream out)
      Per Serializable.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • charset

        private java.nio.charset.Charset charset
      • charsetName

        private java.lang.String charsetName
    • Constructor Detail

      • SerializableCharset

        private SerializableCharset​(java.nio.charset.Charset charset)
        Creates a SerializableCharset. External users should call forCharset(Charset).
        Parameters:
        charset - Character set; must not be null
    • Method Detail

      • writeObject

        private void writeObject​(java.io.ObjectOutputStream out)
                          throws java.io.IOException
        Per Serializable.
        Throws:
        java.io.IOException
      • readObject

        private void readObject​(java.io.ObjectInputStream in)
                         throws java.io.IOException,
                                java.lang.ClassNotFoundException
        Per Serializable.
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • getCharset

        public java.nio.charset.Charset getCharset()
        Returns the wrapped Charset.
        Returns:
        the wrapped Charset
      • forCharset

        public static SerializableCharset forCharset​(java.nio.charset.Charset charset)
        Returns a SerializableCharset wrapping the given Charset, or null if the charset is null.
        Parameters:
        charset - Character set to wrap, or null
        Returns:
        Wrapped charset