public class PercentCodec extends Object implements BinaryEncoder, BinaryDecoder
This class is immutable. It is also thread-safe besides using BitSet which is not thread-safe, but its public interface only call the access
Constructor and Description |
---|
PercentCodec()
Constructs a Percent coded that will encode all the non US-ASCII characters using the Percent-Encoding
while it will not encode all the US-ASCII characters, except for character '%' that is used as escape
character for Percent-Encoding.
|
PercentCodec(byte[] alwaysEncodeChars,
boolean plusForSpace)
Constructs a Percent codec by specifying the characters that belong to US-ASCII that should
always be encoded.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
decode(byte[] bytes)
Decode bytes encoded with Percent-Encoding based on RFC 3986.
|
Object |
decode(Object obj)
Decodes a byte[] Object, whose bytes are encoded with Percent-Encoding.
|
byte[] |
encode(byte[] bytes)
Percent-Encoding based on RFC 3986.
|
Object |
encode(Object obj)
Encodes an object into using the Percent-Encoding.
|
public PercentCodec()
public PercentCodec(byte[] alwaysEncodeChars, boolean plusForSpace)
alwaysEncodeChars
- the unsafe characters that should always be encodedplusForSpace
- the flag defining if the space character should be encoded as '+'public byte[] encode(byte[] bytes) throws EncoderException
encode
in interface BinaryEncoder
bytes
- Data to be encodedEncoderException
- thrown if the Encoder encounters a failure condition during the encoding process.public byte[] decode(byte[] bytes) throws DecoderException
decode
in interface BinaryDecoder
bytes
- A byte array which has been encoded with the appropriate encoderDecoderException
- A decoder exception is thrown if a Decoder encounters a failure condition during the decode process.public Object encode(Object obj) throws EncoderException
encode
in interface Encoder
obj
- the object to encodeEncoderException
- if the object is not a byte arraypublic Object decode(Object obj) throws DecoderException
decode
in interface Decoder
obj
- the object to decodeDecoderException
- if the object is not a byte arrayCopyright © 2002–2020 The Apache Software Foundation. All rights reserved.