Class PercentCodec

  • All Implemented Interfaces:
    Codec<java.lang.Character>

    public class PercentCodec
    extends AbstractCharacterCodec
    Implementation of the Codec interface for percent encoding (aka URL encoding).
    Since:
    June 1, 2007
    Author:
    Jeff Williams (jeff.williams .at. aspectsecurity.com) Aspect Security
    See Also:
    Encoder
    • Constructor Detail

      • PercentCodec

        public PercentCodec()
    • Method Detail

      • encodeCharacter

        public java.lang.String encodeCharacter​(char[] immune,
                                                java.lang.Character c)
        Encode a character for URLs
        Specified by:
        encodeCharacter in interface Codec<java.lang.Character>
        Overrides:
        encodeCharacter in class AbstractCodec<java.lang.Character>
        Parameters:
        immune - Additional characters not to encode. Note this could break URL encoding as referenced in RFC 3986. You should especially be wary of including '%' in this list of immune characters since it is used as the "escape" character for the hex encoding and including it may result in subsequent and/or dangerous results when decoding.
        c - character to encode
        Returns:
        the encoded string representing c
        See Also:
        method instead of this one!!! YOU HAVE BEEN WARNED!!!!
      • decodeCharacter

        public java.lang.Character decodeCharacter​(PushbackSequence<java.lang.Character> input)
        Returns the decoded version of the next character from the input string and advances the current character in the PushbackSequence. If the current character is not encoded, this method MUST reset the PushbackString. Formats all are legal both upper/lower case: %hh;
        Specified by:
        decodeCharacter in interface Codec<java.lang.Character>
        Overrides:
        decodeCharacter in class AbstractCodec<java.lang.Character>
        Parameters:
        input - encoded character using percent characters (such as URL encoding)
        Returns:
        the decoded Character