public final class PropertiesEscape extends Object
Utility class for performing Java Properties (.properties files) escape/unescape operations.
This class supports both escaping of properties keys and properties values.
Configuration of escape/unescape operationsEscape operations can be (optionally) configured by means of:
PropertiesKeyEscapeLevel
and PropertiesValueEscapeLevel
enums.Unescape operations need no configuration parameters. Unescape operations will always perform complete Java Properties unescape of SECs and u-based escapes.
FeaturesSpecific features of the .properties key/value escape/unescape operations performed by means of this class:
There are two different input/output modes that can be used in escape/unescape operations:
The following references apply:
Modifier and Type | Method and Description |
---|---|
static void |
escapePropertiesKey(char[] text,
int offset,
int len,
Writer writer)
Perform a Java Properties Key level 2 (basic set and all non-ASCII chars) escape operation
on a char[] input.
|
static void |
escapePropertiesKey(char[] text,
int offset,
int len,
Writer writer,
PropertiesKeyEscapeLevel level)
Perform a (configurable) Java Properties Key escape operation on a char[] input.
|
static String |
escapePropertiesKey(String text)
Perform a Java Properties Key level 2 (basic set and all non-ASCII chars) escape operation
on a String input.
|
static String |
escapePropertiesKey(String text,
PropertiesKeyEscapeLevel level)
Perform a (configurable) Java Properties Key escape operation on a String input.
|
static void |
escapePropertiesKeyMinimal(char[] text,
int offset,
int len,
Writer writer)
Perform a Java Properties Key level 1 (only basic set) escape operation
on a char[] input.
|
static String |
escapePropertiesKeyMinimal(String text)
Perform a Java Properties Key level 1 (only basic set) escape operation
on a String input.
|
static void |
escapePropertiesValue(char[] text,
int offset,
int len,
Writer writer)
Perform a Java Properties Value level 2 (basic set and all non-ASCII chars) escape operation
on a char[] input.
|
static void |
escapePropertiesValue(char[] text,
int offset,
int len,
Writer writer,
PropertiesValueEscapeLevel level)
Perform a (configurable) Java Properties Value escape operation on a String input.
|
static String |
escapePropertiesValue(String text)
Perform a Java Properties Value level 2 (basic set and all non-ASCII chars) escape operation
on a String input.
|
static String |
escapePropertiesValue(String text,
PropertiesValueEscapeLevel level)
Perform a (configurable) Java Properties Value escape operation on a String input.
|
static void |
escapePropertiesValueMinimal(char[] text,
int offset,
int len,
Writer writer)
Perform a Java Properties Value level 1 (only basic set) escape operation
on a char[] input.
|
static String |
escapePropertiesValueMinimal(String text)
Perform a Java Properties Value level 1 (only basic set) escape operation
on a String input.
|
static void |
unescapeProperties(char[] text,
int offset,
int len,
Writer writer)
Perform a Java Properties (key or value) unescape operation on a char[] input.
|
static String |
unescapeProperties(String text)
Perform a Java Properties (key or value) unescape operation on a String input.
|
public static String escapePropertiesValueMinimal(String text)
Perform a Java Properties Value level 1 (only basic set) escape operation on a String input.
Level 1 means this method will only escape the Java Properties basic escape set:
This method calls escapePropertiesValue(String, PropertiesValueEscapeLevel)
with the following preconfigured values:
This method is thread-safe.
text
- the String to be escaped.public static String escapePropertiesValue(String text)
Perform a Java Properties Value level 2 (basic set and all non-ASCII chars) escape operation on a String input.
Level 2 means this method will escape:
This escape will be performed by using the Single Escape Chars whenever possible. For escaped characters that do not have an associated SEC, default to \uFFFF Hexadecimal Escapes.
This method calls escapePropertiesValue(String, PropertiesValueEscapeLevel)
with the following preconfigured values:
This method is thread-safe.
text
- the String to be escaped.public static String escapePropertiesValue(String text, PropertiesValueEscapeLevel level)
Perform a (configurable) Java Properties Value escape operation on a String input.
This method will perform an escape operation according to the specified
PropertiesValueEscapeLevel
argument value.
All other String-based escapePropertiesValue*(...) methods call this one with preconfigured level values.
This method is thread-safe.
text
- the String to be escaped.level
- the escape level to be applied, see PropertiesValueEscapeLevel
.public static void escapePropertiesValueMinimal(char[] text, int offset, int len, Writer writer) throws IOException
Perform a Java Properties Value level 1 (only basic set) escape operation on a char[] input.
Level 1 means this method will only escape the Java Properties basic escape set:
This method calls escapePropertiesValue(char[], int, int, java.io.Writer, PropertiesValueEscapeLevel)
with the following preconfigured values:
This method is thread-safe.
text
- the char[] to be escaped.offset
- the position in text at which the escape operation should start.len
- the number of characters in text that should be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if text is null.IOException
- if an input/output exception occurspublic static void escapePropertiesValue(char[] text, int offset, int len, Writer writer) throws IOException
Perform a Java Properties Value level 2 (basic set and all non-ASCII chars) escape operation on a char[] input.
Level 2 means this method will escape:
This escape will be performed by using the Single Escape Chars whenever possible. For escaped characters that do not have an associated SEC, default to \uFFFF Hexadecimal Escapes.
This method calls escapePropertiesValue(char[], int, int, java.io.Writer, PropertiesValueEscapeLevel)
with the following preconfigured values:
This method is thread-safe.
text
- the char[] to be escaped.offset
- the position in text at which the escape operation should start.len
- the number of characters in text that should be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if text is null.IOException
- if an input/output exception occurspublic static void escapePropertiesValue(char[] text, int offset, int len, Writer writer, PropertiesValueEscapeLevel level) throws IOException
Perform a (configurable) Java Properties Value escape operation on a String input.
This method will perform an escape operation according to the specified
PropertiesValueEscapeLevel
argument value.
All other String-based escapePropertiesValue*(...) methods call this one with preconfigured level values.
This method is thread-safe.
text
- the char[] to be escaped.offset
- the position in text at which the escape operation should start.len
- the number of characters in text that should be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if text is null.level
- the escape level to be applied, see PropertiesValueEscapeLevel
.IOException
- if an input/output exception occurspublic static String escapePropertiesKeyMinimal(String text)
Perform a Java Properties Key level 1 (only basic set) escape operation on a String input.
Level 1 means this method will only escape the Java Properties Key basic escape set:
This method calls escapePropertiesKey(String, PropertiesKeyEscapeLevel)
with the following preconfigured values:
This method is thread-safe.
text
- the String to be escaped.public static String escapePropertiesKey(String text)
Perform a Java Properties Key level 2 (basic set and all non-ASCII chars) escape operation on a String input.
Level 2 means this method will escape:
This escape will be performed by using the Single Escape Chars whenever possible. For escaped characters that do not have an associated SEC, default to \uFFFF Hexadecimal Escapes.
This method calls escapePropertiesKey(String, PropertiesKeyEscapeLevel)
with the following preconfigured values:
This method is thread-safe.
text
- the String to be escaped.public static String escapePropertiesKey(String text, PropertiesKeyEscapeLevel level)
Perform a (configurable) Java Properties Key escape operation on a String input.
This method will perform an escape operation according to the specified
PropertiesKeyEscapeLevel
argument value.
All other String-based escapePropertiesKey*(...) methods call this one with preconfigured level values.
This method is thread-safe.
text
- the String to be escaped.level
- the escape level to be applied, see PropertiesKeyEscapeLevel
.public static void escapePropertiesKeyMinimal(char[] text, int offset, int len, Writer writer) throws IOException
Perform a Java Properties Key level 1 (only basic set) escape operation on a char[] input.
Level 1 means this method will only escape the Java Properties Key basic escape set:
This method calls escapePropertiesKey(char[], int, int, java.io.Writer, PropertiesKeyEscapeLevel)
with the following preconfigured values:
This method is thread-safe.
text
- the char[] to be escaped.offset
- the position in text at which the escape operation should start.len
- the number of characters in text that should be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if text is null.IOException
- if an input/output exception occurspublic static void escapePropertiesKey(char[] text, int offset, int len, Writer writer) throws IOException
Perform a Java Properties Key level 2 (basic set and all non-ASCII chars) escape operation on a char[] input.
Level 2 means this method will escape:
This escape will be performed by using the Single Escape Chars whenever possible. For escaped characters that do not have an associated SEC, default to \uFFFF Hexadecimal Escapes.
This method calls escapePropertiesKey(char[], int, int, java.io.Writer, PropertiesKeyEscapeLevel)
with the following preconfigured values:
This method is thread-safe.
text
- the char[] to be escaped.offset
- the position in text at which the escape operation should start.len
- the number of characters in text that should be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if text is null.IOException
- if an input/output exception occurspublic static void escapePropertiesKey(char[] text, int offset, int len, Writer writer, PropertiesKeyEscapeLevel level) throws IOException
Perform a (configurable) Java Properties Key escape operation on a char[] input.
This method will perform an escape operation according to the specified
PropertiesKeyEscapeLevel
argument value.
All other String-based escapePropertiesKey*(...) methods call this one with preconfigured level values.
This method is thread-safe.
text
- the char[] to be escaped.offset
- the position in text at which the escape operation should start.len
- the number of characters in text that should be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if text is null.level
- the escape level to be applied, see PropertiesKeyEscapeLevel
.IOException
- if an input/output exception occurspublic static String unescapeProperties(String text)
Perform a Java Properties (key or value) unescape operation on a String input.
No additional configuration arguments are required. Unescape operations will always perform complete Java Properties unescape of SECs and u-based escapes.
This method is thread-safe.
text
- the String to be unescaped.public static void unescapeProperties(char[] text, int offset, int len, Writer writer) throws IOException
Perform a Java Properties (key or value) unescape operation on a char[] input.
No additional configuration arguments are required. Unescape operations will always perform complete Java Properties unescape of SECs and u-based escapes.
This method is thread-safe.
text
- the char[] to be unescaped.offset
- the position in text at which the unescape operation should start.len
- the number of characters in text that should be unescaped.writer
- the java.io.Writer to which the unescaped result will be written. Nothing will
be written at all to this writer if text is null.IOException
- if an input/output exception occursCopyright © 2015 The UNBESCAPE team. All rights reserved.