Class YamlEncoder

    • Constructor Detail

      • YamlEncoder

        public YamlEncoder()
        Creates a new YamlEncoder that does basic string decoding. More extensive support like adding quotes to string isn't possible as we don't have the full TextUnit here. If a PLAIN or SINGLE type string needs quotes because of a new escape char then we can't do it here but must wait until all TextUnit's are returned for the scalar block. This is the normal case when a subfilter is called.

        SnakeYaml should handle these cases: Escape codes: Numeric : { "\x12": 8-bit, "ሴ": 16-bit, "\U00102030": 32-bit } Protective: { "\\": '\', "\"": '"', "\ ": ' ', "\": TAB } C : { "\0": NUL, "\a": BEL, "\b": BS, "\f": FF, "\n": LF, "\r": CR, "\t": TAB, "\v": VTAB } Additional: { "\e": ESC, "\_": NBSP, "\N": NEL, "\L": LS, "\P": PS }

    • Method Detail

      • reset

        public void reset()
        Description copied from interface: IEncoder
        Reset state in this encoder in preparation for processing new content.
        Specified by:
        reset in interface IEncoder
      • setOptions

        public void setOptions​(IParameters params,
                               String encoding,
                               String lineBreak)
        Description copied from interface: IEncoder
        Sets the options for this encoder.
        Specified by:
        setOptions in interface IEncoder
        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

        public String encode​(String text,
                             EncoderContext context)
        Description copied from interface: IEncoder
        Encodes a given text with this encoder.
        Specified by:
        encode in interface IEncoder
        Parameters:
        text - the text to encode.
        context - the context of the text: 0=text, 1=skeleton, 2=inline.
        Returns:
        the encoded text.
      • encode

        public String encode​(char ch,
                             EncoderContext context)
        Description copied from interface: IEncoder
        Encodes a given character with this encoding.
        Specified by:
        encode in interface IEncoder
        Parameters:
        ch - 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).
      • encode

        public String encode​(int value,
                             EncoderContext context)
        Description copied from interface: IEncoder
        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.
        Specified by:
        encode in interface IEncoder
        Parameters:
        value - 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).
      • toNative

        public String toNative​(String propertyName,
                               String value)
        Description copied from interface: IEncoder
        Converts any property values from its standard representation to the native representation for this encoder.
        Specified by:
        toNative in interface IEncoder
        Parameters:
        propertyName - the name of the property.
        value - the standard value to convert.
        Returns:
        the native representation of the given value.
      • getLineBreak

        public String getLineBreak()
        Description copied from interface: IEncoder
        Gets the line-break to use for this encoder.
        Specified by:
        getLineBreak in interface IEncoder
        Returns:
        the line-break used for this encoder.
      • getCharsetEncoder

        public CharsetEncoder getCharsetEncoder()
        Description copied from interface: IEncoder
        Gets the character set encoder used for this encoder.
        Specified by:
        getCharsetEncoder in interface IEncoder
        Returns:
        the character set encoder used for this encoder. This can be null.
      • getParameters

        public IParameters getParameters()
        Description copied from interface: IEncoder
        Gets the parameters object with all the configuration information specific to this encoder.
        Specified by:
        getParameters in interface IEncoder
        Returns:
        the parameters object used for this encoder. This can be null.
      • getEncoding

        public String getEncoding()
        Description copied from interface: IEncoder
        Gets the name of the charset encoding to use.
        Specified by:
        getEncoding in interface IEncoder
        Returns:
        the charset encoding used for this encoder.
      • setScalarType

        public void setScalarType​(YamlScalarTypes scalarType)