Crossfire JXClient, Trunk  R20561
com.realtime.crossfire.jxclient.util.Codec Class Reference

Utility class to encode arbitrary Strings to fit in a single text line. More...

+ Collaboration diagram for com.realtime.crossfire.jxclient.util.Codec:

Static Public Member Functions

static String decode (@NotNull final String str)
 Decodes a string which was encoded by encode(String). More...
 
static String encode (@NotNull final String str)
 Encodes a string to make it fit into one line. More...
 

Private Member Functions

 Codec ()
 Private constructor to prevent instantiation. More...
 

Static Private Attributes

static final Pattern [] PATTERNS_DECODE
 Patterns that must be decoded. More...
 
static final Pattern [] PATTERNS_ENCODE
 Patterns that must be encoded. More...
 
static final String [] REPLACEMENTS_DECODE
 The replacement strings for PATTERNS_DECODE. More...
 
static final String [] REPLACEMENTS_ENCODE
 The replacement strings for PATTERNS_ENCODE. More...
 

Detailed Description

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 or
and s.equals(decode(encode(s))) holds.

Author
Andreas Kirschbaum

Definition at line 35 of file Codec.java.

Constructor & Destructor Documentation

◆ Codec()

com.realtime.crossfire.jxclient.util.Codec.Codec ( )
private

Private constructor to prevent instantiation.

Definition at line 82 of file Codec.java.

Member Function Documentation

◆ decode()

static String com.realtime.crossfire.jxclient.util.Codec.decode ( @NotNull final String  str)
static

Decodes a string which was encoded by encode(String).

Parameters
strthe string to be decoded
Returns
the decoded string
See also
#encode(String)

Definition at line 108 of file Codec.java.

Referenced by com.realtime.crossfire.jxclient.settings.Settings.loadValues().

+ Here is the caller graph for this function:

◆ encode()

static String com.realtime.crossfire.jxclient.util.Codec.encode ( @NotNull final String  str)
static

Encodes a string to make it fit into one line.

Parameters
strthe string to be encoded
Returns
the encoded string
See also
#decode(String)

Definition at line 92 of file Codec.java.

Referenced by com.realtime.crossfire.jxclient.settings.Settings.saveNode().

+ Here is the caller graph for this function:

Member Data Documentation

◆ PATTERNS_DECODE

final Pattern [] com.realtime.crossfire.jxclient.util.Codec.PATTERNS_DECODE
staticprivate
Initial value:
= {
Pattern.compile("\\\\n"),
Pattern.compile("\\\\r"),
Pattern.compile("\\\\\\\\"),
}

Patterns that must be decoded.

The corresponding replacement strings are REPLACEMENTS_DECODE.

Definition at line 63 of file Codec.java.

◆ PATTERNS_ENCODE

final Pattern [] com.realtime.crossfire.jxclient.util.Codec.PATTERNS_ENCODE
staticprivate
Initial value:
= {
Pattern.compile("\\\\"),
Pattern.compile("\r"),
Pattern.compile("\n"),
}

Patterns that must be encoded.

The corresponding replacement strings are REPLACEMENTS_ENCODE.

Definition at line 42 of file Codec.java.

◆ REPLACEMENTS_DECODE

final String [] com.realtime.crossfire.jxclient.util.Codec.REPLACEMENTS_DECODE
staticprivate
Initial value:
= {
Matcher.quoteReplacement("\n"),
Matcher.quoteReplacement("\r"),
Matcher.quoteReplacement("\\"),
}

The replacement strings for PATTERNS_DECODE.

Definition at line 73 of file Codec.java.

◆ REPLACEMENTS_ENCODE

final String [] com.realtime.crossfire.jxclient.util.Codec.REPLACEMENTS_ENCODE
staticprivate
Initial value:
= {
Matcher.quoteReplacement("\\\\"),
Matcher.quoteReplacement("\\r"),
Matcher.quoteReplacement("\\n"),
}

The replacement strings for PATTERNS_ENCODE.

Definition at line 52 of file Codec.java.


The documentation for this class was generated from the following file: