com.h3c.util.codec

## Class CodecFactory

- java.lang.Object
- - com.h3c.util.codec.CodecFactory

-     public final class CodecFactory
      extends Object

  This factory class produces different implementations of codecs.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <E extends Enum<E>> StringCodec` | `createCodecForEnumNames(Class<E> eClass)` A convenience method to create a string codec for the constant names of the specified enumeration class.
    `static ClassNameCodec` | `createEntropicCodecForClassNames()` A convenience method to create an entropic string codec tailored for class names.
    `static EntropicStringSetCodec` | `createEntropicStringSetCodec(Set<String> originals, Algorithm a)` Creates and returns an entropic string codec instance.
    `static <E extends Enum<E>> EnumCodec<E>` | `createEnumCodec(Class<E> eClass)` Creates and returns an EnumCodec for the specified enum class.
    `static StringCodec` | `createGeneralCodec(Set<String> originals)` A convenience method to create a string codec for a general set of strings.
    `static StringSetCodec` | `createStringSetCodec(Set<String> originals, Algorithm a)` Creates and returns a string codec instance.

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

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

- - ### Method Detail

    - #### createStringSetCodec

          public static StringSetCodec createStringSetCodec(Set<String> originals,
                                            Algorithm a)

      Creates and returns a string codec instance. If the algorithm specified is null, the `Algorithm.PREFIX` algorithm will be employed.
      Parameters:
        `originals` - the original strings with which to initialize the codec
        `a` - the encoding algorithm to use
      Returns:
        a string codec
      Throws:
        `NullPointerException` - if originals is null
        `IllegalArgumentException` - if originals is empty

    - #### createEntropicStringSetCodec

          public static EntropicStringSetCodec createEntropicStringSetCodec(Set<String> originals,
                                                            Algorithm a)

      Creates and returns an entropic string codec instance. If the originals parameter is null (or an empty set), the codec instance returned will be devoid of any mappings to start. If the algorithm specified is null, the `Algorithm.PREFIX` algorithm will be employed.
      Parameters:
        `originals` - the original strings with which to initialize the codec
        `a` - the encoding algorithm to use
      Returns:
        an entropic string codec

    - #### createGeneralCodec

          public static StringCodec createGeneralCodec(Set<String> originals)

      A convenience method to create a string codec for a general set of strings. The implementation uses the PREFIX encoding method.
      Parameters:
        `originals` - the original string set
      Returns:
        the codec

    - #### createCodecForEnumNames

          public static <E extends Enum<E>> StringCodec createCodecForEnumNames(Class<E> eClass)

      A convenience method to create a string codec for the constant names of the specified enumeration class.
      Type Parameters:
        `E` - constraint that the class must extend Enum
      Parameters:
        `eClass` - the enumeration class
      Returns:
        the codec

    - #### createEntropicCodecForClassNames

          public static ClassNameCodec createEntropicCodecForClassNames()

      A convenience method to create an entropic string codec tailored for class names.
      Returns:
        the codec

    - #### createEnumCodec

          public static <E extends Enum<E>> EnumCodec<E> createEnumCodec(Class<E> eClass)

      Creates and returns an EnumCodec for the specified enum class.
      Type Parameters:
        `E` - enum class constraint
      Parameters:
        `eClass` - the enum class
      Returns:
        the codec

Copyright © 2014. All Rights Reserved.