Enum NewLinePatternConverter

  • All Implemented Interfaces:
    Serializable, Comparable<NewLinePatternConverter>

    public enum NewLinePatternConverter
    extends Enum<NewLinePatternConverter>
    Handles converting newline patterns into different newline patterns. This means it will convert patterns matching "\n" to a pattern that matches Windows newlines "\r\n", unix newlines "\n", system dependent (currently only windows or unix types), or do no conversion.

    This is NOT for doing "\n" -> "\r\n" type conversions, but is for converting regular expressions that match newline characters from matching "\n" to matching some other type.

    Author:
    Jerry Vos
    • Enum Constant Detail

      • SYSTEM

        public static final NewLinePatternConverter SYSTEM
        If the system's line separator is "\r\n" it will do the same as a WINDOWS converter, if the pattern is "\n" it will return a UNIX one, otherwise it will just return the string.
      • UNIX

        public static final NewLinePatternConverter UNIX
        Returns the string as it is. This does NOT convert "\r\n" matchers to "\n".
    • Method Detail

      • values

        public static NewLinePatternConverter[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (NewLinePatternConverter c : NewLinePatternConverter.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static NewLinePatternConverter valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • getNewLineConverter

        public static NewLinePatternConverter getNewLineConverter​(String handleType)
        Returns the converter that has the specified type as it type.
        Parameters:
        handleType - the type to find a converter for.
        Returns:
        a NewLinePatternConverter or NewLinePatternConverter.NONE if no matching one can be found
      • getType

        public String getType()
      • convert

        public abstract String convert​(String string)
        Converts the newline patterns to those specified by its type.
        Parameters:
        string - a string with newline matching patterns
        Returns:
        a converted string