Package com.github.javaparser.utils
Enum LineSeparator
- All Implemented Interfaces:
Serializable
,Comparable<LineSeparator>
,java.lang.constant.Constable
A representation of line endings, that can be used throughout the codebase.
This is to replace
It also exposes helper methods for, e.g., detection of the line ending of a given string.
This is to replace
Utils.EOL
which is not explicit in representing the system's EOL character.
It also exposes helper methods for, e.g., detection of the line ending of a given string.
- Author:
- Roger Howell
- See Also:
- https://github.com/javaparser/javaparser/issues/2647
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionThe ARBITRARY line ending can be used where we do not care about the line separator, only that we use the same one consistentlyThe CR\r
line ending is the default line separator for classic MacOSThe CRLF\r\n
line ending is the default line separator for WindowsThe LF\n
line ending is the default line separator for Unix and modern MacOSThe MIXED line ending is used where strings appear to have multiple different line separators e.g.The NONE line ending is used where there are precisely zero line endings e.g.This line ending is set to whatever the host system's line separator isThe UNKNOWN line ending can be used in the case where the given string has not yet been analysed to determine its line separator -
Method Summary
Modifier and TypeMethodDescriptiondescribe()
static LineSeparator
boolean
equalsString(LineSeparator lineSeparator)
static LineSeparator
getLineEnding(int countCr, int countLf, int countCrLf)
boolean
static Optional<LineSeparator>
static Optional<LineSeparator>
lookupEscaped(String ending)
toString()
static LineSeparator
Returns the enum constant of this type with the specified name.static LineSeparator[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
CR
The CR\r
line ending is the default line separator for classic MacOS -
LF
The LF\n
line ending is the default line separator for Unix and modern MacOS -
CRLF
The CRLF\r\n
line ending is the default line separator for Windows -
SYSTEM
This line ending is set to whatever the host system's line separator is -
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
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
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
The NONE line ending is used where there are precisely zero line endings e.g. a simple one-line string
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
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 nameNullPointerException
- if the argument is null
-
detect
-
getLineEnding
-
lookup
- 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.
-
lookupEscaped
-
describe
-
equalsString
-
isStandardEol
public boolean isStandardEol() -
asEscapedString
-
asRawString
-
toString
- Overrides:
toString
in classEnum<LineSeparator>
-