|
Copyright 2008 - 2009 Tony Morris, Runar Bjarnason, Tom Adams, Brad Clow, Ricky Clarkson, Nick Partridge, Jason Zaugg This software is released under an open source BSD licence. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfj.data.LazyString
public final class LazyString
A lazy (non-evaluated) immutable character string.
Field Summary | |
---|---|
static LazyString |
empty
The empty string. |
static F<Stream<Character>,LazyString> |
fromStream
First-class conversion from character streams to lazy strings. |
static F<LazyString,Stream<Character>> |
toStream
First-class conversion from lazy strings to streams. |
Method Summary | |
---|---|
LazyString |
append(LazyString cs)
Appends the given lazy string to the end of this lazy string. |
LazyString |
append(String s)
Appends the given String to the end of this lazy string. |
char |
charAt(int index)
Returns the caracter at the specified index. |
boolean |
contains(LazyString cs)
Returns true if the given lazy string is a substring of this lazy string. |
boolean |
endsWith(LazyString cs)
Returns true if the given lazy string is a suffix of this lazy string. |
static LazyString |
fromStream(Stream<Character> s)
Constructs a lazy string from a stream of characters. |
char |
head()
Returns the first character of this string. |
Option<Integer> |
indexOf(char c)
Returns the first index of the given character in this lazy string, if present. |
Option<Integer> |
indexOf(LazyString cs)
Returns the first index of the given substring in this lazy string, if present. |
boolean |
isEmpty()
Checks if this string is empty. |
int |
length()
The length of the lazy string. |
Stream<LazyString> |
lines()
Splits this lazy string into lines. |
boolean |
matches(String regex)
Regular expression pattern matching. |
LazyString |
reverse()
Returns the reverse of this string. |
Stream<LazyString> |
split(char c)
Splits this lazy string by the given delimiter character. |
Stream<LazyString> |
split(F<Character,Boolean> p)
Splits this lazy string by characters matching the given predicate. |
static F<LazyString,F<LazyString,Boolean>> |
startsWith()
First-class prefix check. |
boolean |
startsWith(LazyString cs)
Returns true if the given lazy string is a prefix of this lazy string. |
static LazyString |
str(String s)
Constructs a lazy string from a String. |
CharSequence |
subSequence(int start,
int end)
Gets the specified subsequence of this lazy string. |
LazyString |
tail()
Returns all but the first character of this string. |
Stream<Character> |
toStream()
Gives a stream representation of this lazy string. |
String |
toString()
Returns the String representation of this lazy string. |
static LazyString |
unlines(Stream<LazyString> str)
Joins the given stream of lazy strings into one, separated by newlines. |
static LazyString |
unwords(Stream<LazyString> str)
Joins the given stream of lazy strings into one, separated by spaces. |
Stream<LazyString> |
words()
Splits this lazy string into words by spaces. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final LazyString empty
public static final F<LazyString,Stream<Character>> toStream
public static final F<Stream<Character>,LazyString> fromStream
Method Detail |
---|
public static LazyString str(String s)
s
- A string from which to construct a lazy string.
public static LazyString fromStream(Stream<Character> s)
s
- A stream of characters.
public Stream<Character> toStream()
public int length()
length
in interface CharSequence
public char charAt(int index)
charAt
in interface CharSequence
index
- The index for the character to be returned.
public CharSequence subSequence(int start, int end)
subSequence
in interface CharSequence
start
- The character index of this lazy string at which to start the subsequence.end
- The character index of this lazy string at which to end the subsequence.
public String toString()
toString
in interface CharSequence
toString
in class Object
public LazyString append(LazyString cs)
cs
- A lazy string to append to this one.
public LazyString append(String s)
s
- A String to append to this lazy string.
public boolean contains(LazyString cs)
cs
- A substring to find in this lazy string.
public boolean endsWith(LazyString cs)
cs
- A string to find at the end of this lazy string.
public boolean startsWith(LazyString cs)
cs
- A string to find at the start of this lazy string.
public static F<LazyString,F<LazyString,Boolean>> startsWith()
public char head()
public LazyString tail()
public boolean isEmpty()
public LazyString reverse()
public Option<Integer> indexOf(char c)
c
- A character to find in this lazy string.
public Option<Integer> indexOf(LazyString cs)
cs
- A substring to find in this lazy string.
public boolean matches(String regex)
regex
- A regular expression to match this lazy string.
public Stream<LazyString> split(F<Character,Boolean> p)
p
- A predicate that matches characters to be considered delimiters.
public Stream<LazyString> split(char c)
c
- A delimiter character at which to split.
public Stream<LazyString> words()
public Stream<LazyString> lines()
public static LazyString unlines(Stream<LazyString> str)
str
- A stream of lazy strings to join by newlines.
public static LazyString unwords(Stream<LazyString> str)
str
- A stream of lazy strings to join by spaces.
|
Copyright 2008 - 2009 Tony Morris, Runar Bjarnason, Tom Adams, Brad Clow, Ricky Clarkson, Nick Partridge, Jason Zaugg This software is released under an open source BSD licence. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |