Class Encoders


  • public final class Encoders
    extends java.lang.Object
    Encoders -- Public factory method for obtaining instances of Encoders. Classes implementing the encoders are not directly exposed as part of the API since encoding strategies are subject to change. In many cases encoders will share the same implementation, but have different internal flags for how to handle varied content. For example the XML_CONTENT and XML_ATTRIBUTE contexts may currently share the same class with each instances having a different set of flags. Future version may optimize them into different classes.

    All encoders returned by the factory are thread-safe.

    • Constructor Detail

      • Encoders

        private Encoders()
        No instances.
    • Method Detail

      • map

        private static <T extends Encoder> T map​(java.lang.String name,
                                                 T encoder)
        Internal method to setup and map encoder singletons.
        Type Parameters:
        T - the encoder type
        Parameters:
        name - -- name of the encoder (one of the constants above)
        encoder - -- the encoder singleton instance
        Returns:
        the encoder argument.
      • forName

        public static Encoder forName​(java.lang.String contextName)
                               throws java.lang.NullPointerException,
                                      UnsupportedContextException
        Returns a new instance of an Encoder for the specified context. The returned instance is thread-safe.
        Parameters:
        contextName - the context name (one of the String constants defined in this class)
        Returns:
        an encoder for the specified context.
        Throws:
        java.lang.NullPointerException - if contextName is null
        UnsupportedContextException - if contextName is not recognized.