Package com.google.googlejavaformat
Class Newlines
- java.lang.Object
-
- com.google.googlejavaformat.Newlines
-
public class Newlines extends java.lang.ObjectPlatform-independent newline handling.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classNewlines.LineIteratorprivate static classNewlines.LineOffsetIterator
-
Field Summary
Fields Modifier and Type Field Description private static com.google.common.collect.ImmutableSet<java.lang.String>BREAKS
-
Constructor Summary
Constructors Constructor Description Newlines()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancontainsBreaks(java.lang.String text)Returns true if the input contains any line breaks.static intcount(java.lang.String input)Returns the number of line breaks in the input.static intfirstBreak(java.lang.String input)Returns the index of the first break in the input, or-1.static java.lang.StringgetLineEnding(java.lang.String input)Returns the terminating line break in the input, ornullif the input does not end in a break.static java.lang.StringguessLineSeparator(java.lang.String text)Returns the first line separator in the text, or"\n"if the text does not contain a single line separator.static inthasNewlineAt(java.lang.String input, int idx)Returns the length of the newline sequence at the current offset, or-1.static booleanisNewline(java.lang.String input)Returns true if the entire input string is a recognized line break.static java.util.Iterator<java.lang.String>lineIterator(java.lang.String input)Returns an iterator over lines in the input, including trailing whitespace.static java.util.Iterator<java.lang.Integer>lineOffsetIterator(java.lang.String input)Returns an iterator over the start offsets of lines in the input.
-
-
-
Method Detail
-
count
public static int count(java.lang.String input)
Returns the number of line breaks in the input.
-
firstBreak
public static int firstBreak(java.lang.String input)
Returns the index of the first break in the input, or-1.
-
isNewline
public static boolean isNewline(java.lang.String input)
Returns true if the entire input string is a recognized line break.
-
hasNewlineAt
public static int hasNewlineAt(java.lang.String input, int idx)Returns the length of the newline sequence at the current offset, or-1.
-
getLineEnding
public static java.lang.String getLineEnding(java.lang.String input)
Returns the terminating line break in the input, ornullif the input does not end in a break.
-
guessLineSeparator
public static java.lang.String guessLineSeparator(java.lang.String text)
Returns the first line separator in the text, or"\n"if the text does not contain a single line separator.
-
containsBreaks
public static boolean containsBreaks(java.lang.String text)
Returns true if the input contains any line breaks.
-
lineOffsetIterator
public static java.util.Iterator<java.lang.Integer> lineOffsetIterator(java.lang.String input)
Returns an iterator over the start offsets of lines in the input.
-
lineIterator
public static java.util.Iterator<java.lang.String> lineIterator(java.lang.String input)
Returns an iterator over lines in the input, including trailing whitespace.
-
-