com.realtime.crossfire.jxclient.settings
Class Codec

java.lang.Object
  extended by com.realtime.crossfire.jxclient.settings.Codec

public class Codec
extends java.lang.Object

Utility class to encode arbitrary Strings to fit in a single text line. For any string s, encode(s) is a string that does not contain \r or \n characters and s.equals(decode(encode(s))) holds.


Field Summary
private static java.util.regex.Pattern[] PATTERNS_DECODE
          Patterns that must be decoded.
private static java.util.regex.Pattern[] PATTERNS_ENCODE
          Patterns that must be encoded.
private static java.lang.String[] REPLACEMENTS_DECODE
          The replacement strings for PATTERNS_DECODE.
private static java.lang.String[] REPLACEMENTS_ENCODE
          The replacement strings for PATTERNS_ENCODE.
 
Constructor Summary
private Codec()
          Private constructor to prevent instantiation.
 
Method Summary
static java.lang.String decode(java.lang.String str)
          Decode a string which was encoded by encode(String).
static java.lang.String encode(java.lang.String str)
          Encode a string to make it fit into one line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATTERNS_DECODE

@NotNull
private static final java.util.regex.Pattern[] PATTERNS_DECODE
Patterns that must be decoded. The corresponding replacement strings are REPLACEMENTS_DECODE.


PATTERNS_ENCODE

@NotNull
private static final java.util.regex.Pattern[] PATTERNS_ENCODE
Patterns that must be encoded. The corresponding replacement strings are REPLACEMENTS_ENCODE.


REPLACEMENTS_DECODE

@NotNull
private static final java.lang.String[] REPLACEMENTS_DECODE
The replacement strings for PATTERNS_DECODE.


REPLACEMENTS_ENCODE

@NotNull
private static final java.lang.String[] REPLACEMENTS_ENCODE
The replacement strings for PATTERNS_ENCODE.

Constructor Detail

Codec

private Codec()
Private constructor to prevent instantiation.

Method Detail

decode

@NotNull
public static java.lang.String decode(@NotNull
                                              java.lang.String str)
Decode a string which was encoded by encode(String).

Parameters:
str - The string to be decoded.
Returns:
The decoded string.
See Also:
encode(String)

encode

@NotNull
public static java.lang.String encode(@NotNull
                                              java.lang.String str)
Encode a string to make it fit into one line.

Parameters:
str - The string to be encoded.
Returns:
The encoded string.
See Also:
decode(String)