Enum LineSeparator

    • Enum Constant Detail

      • CR

        public static final LineSeparator CR
        The CR \r line ending is the default line separator for classic MacOS
      • LF

        public static final LineSeparator LF
        The LF \n line ending is the default line separator for Unix and modern MacOS
      • CRLF

        public static final LineSeparator CRLF
        The CRLF \r\n line ending is the default line separator for Windows
      • SYSTEM

        public static final LineSeparator SYSTEM
        This line ending is set to whatever the host system's line separator is
      • ARBITRARY

        public static final LineSeparator ARBITRARY
        The ARBITRARY line ending can be used where we do not care about the line separator, only that we use the same one consistently
      • MIXED

        public static final LineSeparator MIXED
        The MIXED line ending is used where strings appear to have multiple different line separators e.g. "line 1\nline 2\rline 3\r\n" or "line 1\nline 2\rline 3\nline 4\n"
      • UNKNOWN

        public static final LineSeparator UNKNOWN
        The UNKNOWN line ending can be used in the case where the given string has not yet been analysed to determine its line separator
      • NONE

        public static final LineSeparator NONE
        The NONE line ending is used where there are precisely zero line endings e.g. a simple one-line string
    • Method Detail

      • values

        public static LineSeparator[] 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 (LineSeparator c : LineSeparator.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static LineSeparator 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
      • getLineEnding

        public static LineSeparator getLineEnding​(int countCr,
                                                  int countLf,
                                                  int countCrLf)
      • lookup

        public static Optional<LineSeparator> lookup​(String ending)
        Parameters:
        ending - A string containing ONLY the line separator needle (e.g. \r, \n, or \r\n)
        Returns:
        Where the given ending is a "standard" line separator (i.e. \r, \n, or \r\n), return that. Otherwise an empty optional.
      • describe

        public String describe()
      • equalsString

        public boolean equalsString​(LineSeparator lineSeparator)
      • isStandardEol

        public boolean isStandardEol()
      • asEscapedString

        public String asEscapedString()
      • asRawString

        public String asRawString()