Class PropertiesEscape


  • public final class PropertiesEscape
    extends java.lang.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 operations

    Escape operations can be (optionally) configured by means of:

    • Level, which defines how deep the escape operation must be (what chars are to be considered eligible for escaping, depending on the specific needs of the scenario). Its values are defined by the 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.

    Features

    Specific features of the .properties key/value escape/unescape operations performed by means of this class:

    • The Java Properties basic escape set is supported. This basic set consists of:
      • The Single Escape Characters: \t (U+0009), \n (U+000A), \f (U+000C), \r (U+000D) and \\ (U+005C). Besides, (U+0020), \: (U+003A) and \= (U+003D) will be used in Properties keys (not values).
      • Two ranges of non-displayable, control characters (some of which are already part of the single escape characters list): U+0000 to U+001F and U+007F to U+009F.
    • U-based hexadecimal escapes (a.k.a. unicode escapes) are supported both in escape and unescape operations: \u00E1.
    • Full set of escape syntax rules supported, both for .properties keys and .properties values.
    • Support for the whole Unicode character set: \u0000 to \u10FFFF, including characters not representable by only one char in Java (>\uFFFF).
    Input/Output

    There are four different input/output modes that can be used in escape/unescape operations:

    • String input, String output: Input is specified as a String object and output is returned as another. In order to improve memory performance, all escape and unescape operations will return the exact same input object as output if no escape/unescape modifications are required.
    • String input, java.io.Writer output: Input will be read from a String and output will be written into the specified java.io.Writer.
    • java.io.Reader input, java.io.Writer output: Input will be read from a Reader and output will be written into the specified java.io.Writer.
    • char[] input, java.io.Writer output: Input will be read from a char array (char[]) and output will be written into the specified java.io.Writer. Two int arguments called offset and len will be used for specifying the part of the char[] that should be escaped/unescaped. These methods should be called with offset = 0 and len = text.length in order to process the whole char[].
    Glossary
    SEC
    Single Escape Character: \t (U+0009), \n (U+000A), \f (U+000C), \r (U+000D) and \\ (U+005C). Besides, (U+0020), \: (U+003A) and \= (U+003D) will be used in Properties keys (not values).
    UHEXA escapes
    Also called u-based hexadecimal escapes or simply unicode escapes: complete representation of unicode codepoints up to U+FFFF, with \u followed by exactly four hexadecimal figures: \u00E1. Unicode codepoints > U+FFFF can be represented in Java by mean of two UHEXA escapes (a surrogate pair).
    Unicode Codepoint
    Each of the int values conforming the Unicode code space. Normally corresponding to a Java char primitive value (codepoint <= \uFFFF), but might be two chars for codepoints \u10000 to \u10FFFF if the first char is a high surrogate (\uD800 to \uDBFF) and the second is a low surrogate (\uDC00 to \uDFFF).
    References

    The following references apply:

    Since:
    1.0.0
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private PropertiesEscape()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void escapePropertiesKey​(char[] text, int offset, int len, java.io.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, java.io.Writer writer, PropertiesKeyEscapeLevel level)
      Perform a (configurable) Java Properties Key escape operation on a char[] input.
      static void escapePropertiesKey​(java.io.Reader reader, java.io.Writer writer)
      Perform a Java Properties Key level 2 (basic set and all non-ASCII chars) escape operation on a Reader input, writing results to a Writer.
      static void escapePropertiesKey​(java.io.Reader reader, java.io.Writer writer, PropertiesKeyEscapeLevel level)
      Perform a (configurable) Java Properties Key escape operation on a Reader input, writing results to a Writer.
      static java.lang.String escapePropertiesKey​(java.lang.String text)
      Perform a Java Properties Key level 2 (basic set and all non-ASCII chars) escape operation on a String input.
      static void escapePropertiesKey​(java.lang.String text, java.io.Writer writer)
      Perform a Java Properties Key level 2 (basic set and all non-ASCII chars) escape operation on a String input, writing results to a Writer.
      static void escapePropertiesKey​(java.lang.String text, java.io.Writer writer, PropertiesKeyEscapeLevel level)
      Perform a (configurable) Java Properties Key escape operation on a String input, writing results to a Writer.
      static java.lang.String escapePropertiesKey​(java.lang.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, java.io.Writer writer)
      Perform a Java Properties Key level 1 (only basic set) escape operation on a char[] input.
      static void escapePropertiesKeyMinimal​(java.io.Reader reader, java.io.Writer writer)
      Perform a Java Properties Key level 1 (only basic set) escape operation on a Reader input, writing results to a Writer.
      static java.lang.String escapePropertiesKeyMinimal​(java.lang.String text)
      Perform a Java Properties Key level 1 (only basic set) escape operation on a String input.
      static void escapePropertiesKeyMinimal​(java.lang.String text, java.io.Writer writer)
      Perform a Java Properties Key level 1 (only basic set) escape operation on a String input, writing results to a Writer.
      static void escapePropertiesValue​(char[] text, int offset, int len, java.io.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, java.io.Writer writer, PropertiesValueEscapeLevel level)
      Perform a (configurable) Java Properties Value escape operation on a String input.
      static void escapePropertiesValue​(java.io.Reader reader, java.io.Writer writer)
      Perform a Java Properties Value level 2 (basic set and all non-ASCII chars) escape operation on a Reader input, writing results to a Writer.
      static void escapePropertiesValue​(java.io.Reader reader, java.io.Writer writer, PropertiesValueEscapeLevel level)
      Perform a (configurable) Java Properties Value escape operation on a Reader input, writing results to a Writer.
      static java.lang.String escapePropertiesValue​(java.lang.String text)
      Perform a Java Properties Value level 2 (basic set and all non-ASCII chars) escape operation on a String input.
      static void escapePropertiesValue​(java.lang.String text, java.io.Writer writer)
      Perform a Java Properties Value level 2 (basic set and all non-ASCII chars) escape operation on a String input, writing results to a Writer.
      static void escapePropertiesValue​(java.lang.String text, java.io.Writer writer, PropertiesValueEscapeLevel level)
      Perform a (configurable) Java Properties Value escape operation on a String input, writing results to a Writer.
      static java.lang.String escapePropertiesValue​(java.lang.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, java.io.Writer writer)
      Perform a Java Properties Value level 1 (only basic set) escape operation on a char[] input.
      static void escapePropertiesValueMinimal​(java.io.Reader reader, java.io.Writer writer)
      Perform a Java Properties Value level 1 (only basic set) escape operation on a Reader input, writing results to a Writer.
      static java.lang.String escapePropertiesValueMinimal​(java.lang.String text)
      Perform a Java Properties Value level 1 (only basic set) escape operation on a String input.
      static void escapePropertiesValueMinimal​(java.lang.String text, java.io.Writer writer)
      Perform a Java Properties Value level 1 (only basic set) escape operation on a String input, writing results to a Writer.
      static void unescapeProperties​(char[] text, int offset, int len, java.io.Writer writer)
      Perform a Java Properties (key or value) unescape operation on a char[] input.
      static void unescapeProperties​(java.io.Reader reader, java.io.Writer writer)
      Perform a Java Properties (key or value) unescape operation on a Reader input, writing results to a Writer.
      static java.lang.String unescapeProperties​(java.lang.String text)
      Perform a Java Properties (key or value) unescape operation on a String input.
      static void unescapeProperties​(java.lang.String text, java.io.Writer writer)
      Perform a Java Properties (key or value) unescape operation on a String input, writing results to a Writer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PropertiesEscape

        private PropertiesEscape()
    • Method Detail

      • escapePropertiesValueMinimal

        public static java.lang.String escapePropertiesValueMinimal​(java.lang.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:

        • The Single Escape Characters: \t (U+0009), \n (U+000A), \f (U+000C), \r (U+000D) and \\ (U+005C).
        • Two ranges of non-displayable, control characters (some of which are already part of the single escape characters list): U+0000 to U+001F and U+007F to U+009F.

        This method calls escapePropertiesValue(String, PropertiesValueEscapeLevel) with the following preconfigured values:

        This method is thread-safe.

        Parameters:
        text - the String to be escaped.
        Returns:
        The escaped result String. As a memory-performance improvement, will return the exact same object as the text input argument if no escaping modifications were required (and no additional String objects will be created during processing). Will return null if input is null.
      • escapePropertiesValue

        public static java.lang.String escapePropertiesValue​(java.lang.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:

        • The Java Properties basic escape set:
          • The Single Escape Characters: \t (U+0009), \n (U+000A), \f (U+000C), \r (U+000D) and \\ (U+005C).
          • Two ranges of non-displayable, control characters (some of which are already part of the single escape characters list): U+0000 to U+001F and U+007F to U+009F.
        • All non ASCII characters.

        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.

        Parameters:
        text - the String to be escaped.
        Returns:
        The escaped result String. As a memory-performance improvement, will return the exact same object as the text input argument if no escaping modifications were required (and no additional String objects will be created during processing). Will return null if input is null.
      • escapePropertiesValue

        public static java.lang.String escapePropertiesValue​(java.lang.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.

        Parameters:
        text - the String to be escaped.
        level - the escape level to be applied, see PropertiesValueEscapeLevel.
        Returns:
        The escaped result String. As a memory-performance improvement, will return the exact same object as the text input argument if no escaping modifications were required (and no additional String objects will be created during processing). Will return null if input is null.
      • escapePropertiesValueMinimal

        public static void escapePropertiesValueMinimal​(java.lang.String text,
                                                        java.io.Writer writer)
                                                 throws java.io.IOException

        Perform a Java Properties Value level 1 (only basic set) escape operation on a String input, writing results to a Writer.

        Level 1 means this method will only escape the Java Properties basic escape set:

        • The Single Escape Characters: \t (U+0009), \n (U+000A), \f (U+000C), \r (U+000D) and \\ (U+005C).
        • Two ranges of non-displayable, control characters (some of which are already part of the single escape characters list): U+0000 to U+001F and U+007F to U+009F.

        This method calls escapePropertiesValue(String, Writer, PropertiesValueEscapeLevel) with the following preconfigured values:

        This method is thread-safe.

        Parameters:
        text - the String to 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 input is null.
        Throws:
        java.io.IOException - if an input/output exception occurs
        Since:
        1.1.2
      • escapePropertiesValue

        public static void escapePropertiesValue​(java.lang.String text,
                                                 java.io.Writer writer)
                                          throws java.io.IOException

        Perform a Java Properties Value level 2 (basic set and all non-ASCII chars) escape operation on a String input, writing results to a Writer.

        Level 2 means this method will escape:

        • The Java Properties basic escape set:
          • The Single Escape Characters: \t (U+0009), \n (U+000A), \f (U+000C), \r (U+000D) and \\ (U+005C).
          • Two ranges of non-displayable, control characters (some of which are already part of the single escape characters list): U+0000 to U+001F and U+007F to U+009F.
        • All non ASCII characters.

        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, Writer, PropertiesValueEscapeLevel) with the following preconfigured values:

        This method is thread-safe.

        Parameters:
        text - the String to 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 input is null.
        Throws:
        java.io.IOException - if an input/output exception occurs
        Since:
        1.1.2
      • escapePropertiesValue

        public static void escapePropertiesValue​(java.lang.String text,
                                                 java.io.Writer writer,
                                                 PropertiesValueEscapeLevel level)
                                          throws java.io.IOException

        Perform a (configurable) Java Properties Value escape operation on a String input, writing results to a Writer.

        This method will perform an escape operation according to the specified PropertiesValueEscapeLevel argument value.

        All other String/Writer-based escapePropertiesValue*(...) methods call this one with preconfigured level values.

        This method is thread-safe.

        Parameters:
        text - the String to 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 input is null.
        level - the escape level to be applied, see PropertiesValueEscapeLevel.
        Throws:
        java.io.IOException - if an input/output exception occurs
        Since:
        1.1.2
      • escapePropertiesValueMinimal

        public static void escapePropertiesValueMinimal​(java.io.Reader reader,
                                                        java.io.Writer writer)
                                                 throws java.io.IOException

        Perform a Java Properties Value level 1 (only basic set) escape operation on a Reader input, writing results to a Writer.

        Level 1 means this method will only escape the Java Properties basic escape set:

        • The Single Escape Characters: \t (U+0009), \n (U+000A), \f (U+000C), \r (U+000D) and \\ (U+005C).
        • Two ranges of non-displayable, control characters (some of which are already part of the single escape characters list): U+0000 to U+001F and U+007F to U+009F.

        This method calls escapePropertiesValue(Reader, Writer, PropertiesValueEscapeLevel) with the following preconfigured values:

        This method is thread-safe.

        Parameters:
        reader - the Reader reading the text to 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 input is null.
        Throws:
        java.io.IOException - if an input/output exception occurs
        Since:
        1.1.2
      • escapePropertiesValue

        public static void escapePropertiesValue​(java.io.Reader reader,
                                                 java.io.Writer writer)
                                          throws java.io.IOException

        Perform a Java Properties Value level 2 (basic set and all non-ASCII chars) escape operation on a Reader input, writing results to a Writer.

        Level 2 means this method will escape:

        • The Java Properties basic escape set:
          • The Single Escape Characters: \t (U+0009), \n (U+000A), \f (U+000C), \r (U+000D) and \\ (U+005C).
          • Two ranges of non-displayable, control characters (some of which are already part of the single escape characters list): U+0000 to U+001F and U+007F to U+009F.
        • All non ASCII characters.

        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(Reader, Writer, PropertiesValueEscapeLevel) with the following preconfigured values:

        This method is thread-safe.

        Parameters:
        reader - the Reader reading the text to 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 input is null.
        Throws:
        java.io.IOException - if an input/output exception occurs
        Since:
        1.1.2
      • escapePropertiesValue

        public static void escapePropertiesValue​(java.io.Reader reader,
                                                 java.io.Writer writer,
                                                 PropertiesValueEscapeLevel level)
                                          throws java.io.IOException

        Perform a (configurable) Java Properties Value escape operation on a Reader input, writing results to a Writer.

        This method will perform an escape operation according to the specified PropertiesValueEscapeLevel argument value.

        All other Reader/Writer-based escapePropertiesValue*(...) methods call this one with preconfigured level values.

        This method is thread-safe.

        Parameters:
        reader - the Reader reading the text to 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 input is null.
        level - the escape level to be applied, see PropertiesValueEscapeLevel.
        Throws:
        java.io.IOException - if an input/output exception occurs
        Since:
        1.1.2
      • escapePropertiesValueMinimal

        public static void escapePropertiesValueMinimal​(char[] text,
                                                        int offset,
                                                        int len,
                                                        java.io.Writer writer)
                                                 throws java.io.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:

        • The Single Escape Characters: \t (U+0009), \n (U+000A), \f (U+000C), \r (U+000D) and \\ (U+005C).
        • Two ranges of non-displayable, control characters (some of which are already part of the single escape characters list): U+0000 to U+001F and U+007F to U+009F.

        This method calls escapePropertiesValue(char[], int, int, java.io.Writer, PropertiesValueEscapeLevel) with the following preconfigured values:

        This method is thread-safe.

        Parameters:
        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 input is null.
        Throws:
        java.io.IOException - if an input/output exception occurs
      • escapePropertiesValue

        public static void escapePropertiesValue​(char[] text,
                                                 int offset,
                                                 int len,
                                                 java.io.Writer writer)
                                          throws java.io.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:

        • The Java Properties basic escape set:
          • The Single Escape Characters: \t (U+0009), \n (U+000A), \f (U+000C), \r (U+000D) and \\ (U+005C).
          • Two ranges of non-displayable, control characters (some of which are already part of the single escape characters list): U+0000 to U+001F and U+007F to U+009F.
        • All non ASCII characters.

        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.

        Parameters:
        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 input is null.
        Throws:
        java.io.IOException - if an input/output exception occurs
      • escapePropertiesValue

        public static void escapePropertiesValue​(char[] text,
                                                 int offset,
                                                 int len,
                                                 java.io.Writer writer,
                                                 PropertiesValueEscapeLevel level)
                                          throws java.io.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.

        Parameters:
        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 input is null.
        level - the escape level to be applied, see PropertiesValueEscapeLevel.
        Throws:
        java.io.IOException - if an input/output exception occurs
      • escapePropertiesKeyMinimal

        public static java.lang.String escapePropertiesKeyMinimal​(java.lang.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:

        • The Single Escape Characters: \t (U+0009), \n (U+000A), \f (U+000C), \r (U+000D), (U+0020), \: (U+003A), \= (U+003D) and \\ (U+005C).
        • Two ranges of non-displayable, control characters (some of which are already part of the single escape characters list): U+0000 to U+001F and U+007F to U+009F.

        This method calls escapePropertiesKey(String, PropertiesKeyEscapeLevel) with the following preconfigured values:

        This method is thread-safe.

        Parameters:
        text - the String to be escaped.
        Returns:
        The escaped result String. As a memory-performance improvement, will return the exact same object as the text input argument if no escaping modifications were required (and no additional String objects will be created during processing). Will return null if input is null.
      • escapePropertiesKey

        public static java.lang.String escapePropertiesKey​(java.lang.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:

        • The Java Properties Key basic escape set:
          • The Single Escape Characters: \t (U+0009), \n (U+000A), \f (U+000C), \r (U+000D), (U+0020), \: (U+003A), \= (U+003D) and \\ (U+005C).
          • Two ranges of non-displayable, control characters (some of which are already part of the single escape characters list): U+0000 to U+001F and U+007F to U+009F.
        • All non ASCII characters.

        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.

        Parameters:
        text - the String to be escaped.
        Returns:
        The escaped result String. As a memory-performance improvement, will return the exact same object as the text input argument if no escaping modifications were required (and no additional String objects will be created during processing). Will return null if input is null.
      • escapePropertiesKey

        public static java.lang.String escapePropertiesKey​(java.lang.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.

        Parameters:
        text - the String to be escaped.
        level - the escape level to be applied, see PropertiesKeyEscapeLevel.
        Returns:
        The escaped result String. As a memory-performance improvement, will return the exact same object as the text input argument if no escaping modifications were required (and no additional String objects will be created during processing). Will return null if input is null.
      • escapePropertiesKeyMinimal

        public static void escapePropertiesKeyMinimal​(java.lang.String text,
                                                      java.io.Writer writer)
                                               throws java.io.IOException

        Perform a Java Properties Key level 1 (only basic set) escape operation on a String input, writing results to a Writer.

        Level 1 means this method will only escape the Java Properties Key basic escape set:

        • The Single Escape Characters: \t (U+0009), \n (U+000A), \f (U+000C), \r (U+000D), (U+0020), \: (U+003A), \= (U+003D) and \\ (U+005C).
        • Two ranges of non-displayable, control characters (some of which are already part of the single escape characters list): U+0000 to U+001F and U+007F to U+009F.

        This method calls escapePropertiesKey(String, Writer, PropertiesKeyEscapeLevel) with the following preconfigured values:

        This method is thread-safe.

        Parameters:
        text - the String to 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 input is null.
        Throws:
        java.io.IOException - if an input/output exception occurs
      • escapePropertiesKey

        public static void escapePropertiesKey​(java.lang.String text,
                                               java.io.Writer writer)
                                        throws java.io.IOException

        Perform a Java Properties Key level 2 (basic set and all non-ASCII chars) escape operation on a String input, writing results to a Writer.

        Level 2 means this method will escape:

        • The Java Properties Key basic escape set:
          • The Single Escape Characters: \t (U+0009), \n (U+000A), \f (U+000C), \r (U+000D), (U+0020), \: (U+003A), \= (U+003D) and \\ (U+005C).
          • Two ranges of non-displayable, control characters (some of which are already part of the single escape characters list): U+0000 to U+001F and U+007F to U+009F.
        • All non ASCII characters.

        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, Writer, PropertiesKeyEscapeLevel) with the following preconfigured values:

        This method is thread-safe.

        Parameters:
        text - the String to 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 input is null.
        Throws:
        java.io.IOException - if an input/output exception occurs
      • escapePropertiesKey

        public static void escapePropertiesKey​(java.lang.String text,
                                               java.io.Writer writer,
                                               PropertiesKeyEscapeLevel level)
                                        throws java.io.IOException

        Perform a (configurable) Java Properties Key escape operation on a String input, writing results to a Writer.

        This method will perform an escape operation according to the specified PropertiesKeyEscapeLevel argument value.

        All other String/Writer-based escapePropertiesKey*(...) methods call this one with preconfigured level values.

        This method is thread-safe.

        Parameters:
        text - the String to 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 input is null.
        level - the escape level to be applied, see PropertiesKeyEscapeLevel.
        Throws:
        java.io.IOException - if an input/output exception occurs
      • escapePropertiesKeyMinimal

        public static void escapePropertiesKeyMinimal​(java.io.Reader reader,
                                                      java.io.Writer writer)
                                               throws java.io.IOException

        Perform a Java Properties Key level 1 (only basic set) escape operation on a Reader input, writing results to a Writer.

        Level 1 means this method will only escape the Java Properties Key basic escape set:

        • The Single Escape Characters: \t (U+0009), \n (U+000A), \f (U+000C), \r (U+000D), (U+0020), \: (U+003A), \= (U+003D) and \\ (U+005C).
        • Two ranges of non-displayable, control characters (some of which are already part of the single escape characters list): U+0000 to U+001F and U+007F to U+009F.

        This method calls escapePropertiesKey(Reader, Writer, PropertiesKeyEscapeLevel) with the following preconfigured values:

        This method is thread-safe.

        Parameters:
        reader - the Reader reading the text to 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 input is null.
        Throws:
        java.io.IOException - if an input/output exception occurs
      • escapePropertiesKey

        public static void escapePropertiesKey​(java.io.Reader reader,
                                               java.io.Writer writer)
                                        throws java.io.IOException

        Perform a Java Properties Key level 2 (basic set and all non-ASCII chars) escape operation on a Reader input, writing results to a Writer.

        Level 2 means this method will escape:

        • The Java Properties Key basic escape set:
          • The Single Escape Characters: \t (U+0009), \n (U+000A), \f (U+000C), \r (U+000D), (U+0020), \: (U+003A), \= (U+003D) and \\ (U+005C).
          • Two ranges of non-displayable, control characters (some of which are already part of the single escape characters list): U+0000 to U+001F and U+007F to U+009F.
        • All non ASCII characters.

        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(Reader, Writer, PropertiesKeyEscapeLevel) with the following preconfigured values:

        This method is thread-safe.

        Parameters:
        reader - the Reader reading the text to 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 input is null.
        Throws:
        java.io.IOException - if an input/output exception occurs
      • escapePropertiesKey

        public static void escapePropertiesKey​(java.io.Reader reader,
                                               java.io.Writer writer,
                                               PropertiesKeyEscapeLevel level)
                                        throws java.io.IOException

        Perform a (configurable) Java Properties Key escape operation on a Reader input, writing results to a Writer.

        This method will perform an escape operation according to the specified PropertiesKeyEscapeLevel argument value.

        All other Reader/Writer-based escapePropertiesKey*(...) methods call this one with preconfigured level values.

        This method is thread-safe.

        Parameters:
        reader - the Reader reading the text to 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 input is null.
        level - the escape level to be applied, see PropertiesKeyEscapeLevel.
        Throws:
        java.io.IOException - if an input/output exception occurs
      • escapePropertiesKeyMinimal

        public static void escapePropertiesKeyMinimal​(char[] text,
                                                      int offset,
                                                      int len,
                                                      java.io.Writer writer)
                                               throws java.io.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:

        • The Single Escape Characters: \t (U+0009), \n (U+000A), \f (U+000C), \r (U+000D), (U+0020), \: (U+003A), \= (U+003D) and \\ (U+005C).
        • Two ranges of non-displayable, control characters (some of which are already part of the single escape characters list): U+0000 to U+001F and U+007F to U+009F.

        This method calls escapePropertiesKey(char[], int, int, java.io.Writer, PropertiesKeyEscapeLevel) with the following preconfigured values:

        This method is thread-safe.

        Parameters:
        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 input is null.
        Throws:
        java.io.IOException - if an input/output exception occurs
      • escapePropertiesKey

        public static void escapePropertiesKey​(char[] text,
                                               int offset,
                                               int len,
                                               java.io.Writer writer)
                                        throws java.io.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:

        • The Java Properties Key basic escape set:
          • The Single Escape Characters: \t (U+0009), \n (U+000A), \f (U+000C), \r (U+000D), (U+0020), \: (U+003A), \= (U+003D) and \\ (U+005C).
          • Two ranges of non-displayable, control characters (some of which are already part of the single escape characters list): U+0000 to U+001F and U+007F to U+009F.
        • All non ASCII characters.

        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.

        Parameters:
        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 input is null.
        Throws:
        java.io.IOException - if an input/output exception occurs
      • escapePropertiesKey

        public static void escapePropertiesKey​(char[] text,
                                               int offset,
                                               int len,
                                               java.io.Writer writer,
                                               PropertiesKeyEscapeLevel level)
                                        throws java.io.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.

        Parameters:
        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 input is null.
        level - the escape level to be applied, see PropertiesKeyEscapeLevel.
        Throws:
        java.io.IOException - if an input/output exception occurs
      • unescapeProperties

        public static java.lang.String unescapeProperties​(java.lang.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.

        Parameters:
        text - the String to be unescaped.
        Returns:
        The unescaped result String. As a memory-performance improvement, will return the exact same object as the text input argument if no unescaping modifications were required (and no additional String objects will be created during processing). Will return null if input is null.
      • unescapeProperties

        public static void unescapeProperties​(java.lang.String text,
                                              java.io.Writer writer)
                                       throws java.io.IOException

        Perform a Java Properties (key or value) unescape operation on a String input, writing results to a Writer.

        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.

        Parameters:
        text - the String to 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 input is null.
        Throws:
        java.io.IOException - if an input/output exception occurs
        Since:
        1.1.2
      • unescapeProperties

        public static void unescapeProperties​(java.io.Reader reader,
                                              java.io.Writer writer)
                                       throws java.io.IOException

        Perform a Java Properties (key or value) unescape operation on a Reader input, writing results to a Writer.

        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.

        Parameters:
        reader - the Reader reading the text to 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 input is null.
        Throws:
        java.io.IOException - if an input/output exception occurs
        Since:
        1.1.2
      • unescapeProperties

        public static void unescapeProperties​(char[] text,
                                              int offset,
                                              int len,
                                              java.io.Writer writer)
                                       throws java.io.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.

        Parameters:
        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 input is null.
        Throws:
        java.io.IOException - if an input/output exception occurs