Gridarta Editor
net.sf.gridarta.preferences.Codec Class Reference

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

+ Collaboration diagram for net.sf.gridarta.preferences.Codec:

Static Public Member Functions

static String decode (@NotNull final String str)
 Decode a string which was encoded by encode(String). More...
 
static String encode (@NotNull final String str)
 Encode 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 = { Pattern.compile("\\\\n"), Pattern.compile("\\\\r"), Pattern.compile("\\\\\\\\"), }
 Patterns that must be decoded. More...
 
static final Pattern [] PATTERNS_ENCODE = { Pattern.compile("\\\\"), Pattern.compile("\r"), Pattern.compile("\n"), }
 Patterns that must be encoded. More...
 
static final String [] REPLACEMENTS_DECODE = { Matcher.quoteReplacement("\n"), Matcher.quoteReplacement("\r"), Matcher.quoteReplacement("\\"), }
 The replacement strings for PATTERNS_DECODE. More...
 
static final String [] REPLACEMENTS_ENCODE = { Matcher.quoteReplacement("\\\\"), Matcher.quoteReplacement("\\r"), Matcher.quoteReplacement("\\n"), }
 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
characters and

s.equals(decode(encode(s)))

holds.

Author
Andreas Kirschbaum

Definition at line 32 of file Codec.java.

Constructor & Destructor Documentation

◆ Codec()

net.sf.gridarta.preferences.Codec.Codec ( )
private

Private constructor to prevent instantiation.

Definition at line 63 of file Codec.java.

Member Function Documentation

◆ decode()

static String net.sf.gridarta.preferences.Codec.decode ( @NotNull final String  str)
static

Decode 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 89 of file Codec.java.

Referenced by net.sf.gridarta.preferences.Storage.loadValues().

+ Here is the caller graph for this function:

◆ encode()

static String net.sf.gridarta.preferences.Codec.encode ( @NotNull final String  str)
static

Encode 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 73 of file Codec.java.

Referenced by net.sf.gridarta.preferences.Storage.saveNode().

+ Here is the caller graph for this function:

Member Data Documentation

◆ PATTERNS_DECODE

final Pattern [] net.sf.gridarta.preferences.Codec.PATTERNS_DECODE = { Pattern.compile("\\\\n"), Pattern.compile("\\\\r"), Pattern.compile("\\\\\\\\"), }
staticprivate

Patterns that must be decoded.

The corresponding replacement strings are REPLACEMENTS_DECODE.

Definition at line 52 of file Codec.java.

◆ PATTERNS_ENCODE

final Pattern [] net.sf.gridarta.preferences.Codec.PATTERNS_ENCODE = { Pattern.compile("\\\\"), Pattern.compile("\r"), Pattern.compile("\n"), }
staticprivate

Patterns that must be encoded.

The corresponding replacement strings are REPLACEMENTS_ENCODE.

Definition at line 39 of file Codec.java.

◆ REPLACEMENTS_DECODE

final String [] net.sf.gridarta.preferences.Codec.REPLACEMENTS_DECODE = { Matcher.quoteReplacement("\n"), Matcher.quoteReplacement("\r"), Matcher.quoteReplacement("\\"), }
staticprivate

The replacement strings for PATTERNS_DECODE.

Definition at line 58 of file Codec.java.

◆ REPLACEMENTS_ENCODE

final String [] net.sf.gridarta.preferences.Codec.REPLACEMENTS_ENCODE = { Matcher.quoteReplacement("\\\\"), Matcher.quoteReplacement("\\r"), Matcher.quoteReplacement("\\n"), }
staticprivate

The replacement strings for PATTERNS_ENCODE.

Definition at line 45 of file Codec.java.


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