net.sf.okapi.common.encoder

## Interface IEncoder

- All Known Subinterfaces:
    ILayerProvider
  All Known Implementing Classes:
    CDATAEncoder, DefaultEncoder, DTDEncoder, EncoderManager, HtmlEncoder, JSONEncoder, LayerProvider, OpenXMLEncoder, PHPContentEncoder, POEncoder, PropertiesEncoder, TSEncoder, XMLEncoder

      public interface IEncoder

  Provides common methods to encode/escape text to a specific format.

  Important: Each class implementing this interface must have a nullary constructor, so the object can be instantiated using the Class.fromName() methods by the EncoderManager.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `encode(char value, EncoderContext context)` Encodes a given character with this encoding.
    `java.lang.String` | `encode(int codePoint, EncoderContext context)` Encodes a given code-point with this encoding.
    `java.lang.String` | `encode(java.lang.String text, EncoderContext context)` Encodes a given text with this encoder.
    `java.nio.charset.CharsetEncoder` | `getCharsetEncoder()` Gets the character set encoder used for this encoder.
    `java.lang.String` | `getEncoding()` Gets the name of the charset encoding to use.
    `java.lang.String` | `getLineBreak()` Gets the line-break to use for this encoder.
    `IParameters` | `getParameters()` Gets the parameters object with all the configuration information specific to this encoder.
    `void` | `setOptions(IParameters params, java.lang.String encoding, java.lang.String lineBreak)` Sets the options for this encoder.
    `java.lang.String` | `toNative(java.lang.String propertyName, java.lang.String value)` Converts any property values from its standard representation to the native representation for this encoder.

- - ### Method Detail

    - #### setOptions

          void setOptions(IParameters params,
                        java.lang.String encoding,
                        java.lang.String lineBreak)

      Sets the options for this encoder.
      Parameters:
        `params` - the parameters object with all the configuration information specific to this encoder.
        `encoding` - the name of the charset encoding to use.
        `lineBreak` - the type of line break to use.

    - #### encode

          java.lang.String encode(java.lang.String text,
                                EncoderContext context)

      Encodes a given text with this encoder.
      Parameters:
        `text` - the text to encode.
        `context` - the context of the text: 0=text, 1=skeleton, 2=inline.
      Returns:
        the encoded text.

    - #### encode

          java.lang.String encode(int codePoint,
                                EncoderContext context)

      Encodes a given code-point with this encoding. If this method is called from a loop it is assumed that the code point is tested by the caller to know if it is a supplemental one or not and and any index update to skip the low surrogate part of the pair is done on the caller side.
      Parameters:
        `codePoint` - the code-point to encode.
        `context` - the context of the character: 0=text, 1=skeleton, 2=inline.
      Returns:
        the encoded character (as a string since it can be now made up of more than one character).

    - #### encode

          java.lang.String encode(char value,
                                EncoderContext context)

      Encodes a given character with this encoding.
      Parameters:
        `value` - the character to encode.
        `context` - the context of the character: 0=text, 1=skeleton, 2=inline.
      Returns:
        the encoded character 9as a string since it can be now made up of more than one character).

    - #### toNative

          java.lang.String toNative(java.lang.String propertyName,
                                  java.lang.String value)

      Converts any property values from its standard representation to the native representation for this encoder.
      Parameters:
        `propertyName` - the name of the property.
        `value` - the standard value to convert.
      Returns:
        the native representation of the given value.

    - #### getLineBreak

          java.lang.String getLineBreak()

      Gets the line-break to use for this encoder.
      Returns:
        the line-break used for this encoder.

    - #### getEncoding

          java.lang.String getEncoding()

      Gets the name of the charset encoding to use.
      Returns:
        the charset encoding used for this encoder.

    - #### getCharsetEncoder

          java.nio.charset.CharsetEncoder getCharsetEncoder()

      Gets the character set encoder used for this encoder.
      Returns:
        the character set encoder used for this encoder. This can be null.

    - #### getParameters

          IParameters getParameters()

      Gets the parameters object with all the configuration information specific to this encoder.
      Returns:
        the parameters object used for this encoder. This can be null.