Groovy JDK

java.lang
Class CharSequence

Method Summary
boolean asBoolean()
Coerce a string (an instance of CharSequence) to a boolean value.
CharSequence drop(int num)
Drops the given number of chars from the head of this CharSequence if they are available.
CharSequence getAt(int index)
Support the subscript operator for CharSequence.
CharSequence getAt(Range range)
Support the range subscript operator for CharSequence
CharSequence getAt(IntRange range)
Support the range subscript operator for CharSequence or StringBuffer with IntRange
CharSequence getAt(EmptyRange range)
Support the range subscript operator for CharSequence or StringBuffer with EmptyRange
CharSequence getAt(Collection indices)
Select a List of characters from a CharSequence using a Collection to identify the indices to be selected.
CharSequence take(int num)
Returns the first num elements from this CharSequence.
 
Method Detail

asBoolean

public boolean asBoolean()
 
Coerce a string (an instance of CharSequence) to a boolean value. A string is coerced to false if it is of length 0, and to true otherwise.
Returns:
the boolean value
Since:
1.7.0

drop

public CharSequence drop(int num)
 
Drops the given number of chars from the head of this CharSequence if they are available.
    def text = "Groovy"
    assert text.drop( 0 ) == 'Groovy'
    assert text.drop( 2 ) == 'oovy'
    assert text.drop( 7 ) == ''
Parameters:
num - the number of characters to drop from this iterator.
Returns:
a CharSequence consisting of all characters except the first num ones, or else an empty String, if this CharSequence has less than num characters.
Since:
1.8.1

getAt

public CharSequence getAt(int index)
 
Support the subscript operator for CharSequence.
Parameters:
index - the index of the Character to get.
Returns:
the Character at the given index
Since:
1.0

getAt

public CharSequence getAt(Range range)
 
Support the range subscript operator for CharSequence
Parameters:
range - a Range.
Returns:
the subsequence CharSequence
Since:
1.0

getAt

public CharSequence getAt(IntRange range)
 
Support the range subscript operator for CharSequence or StringBuffer with IntRange
Parameters:
range - an IntRange.
Returns:
the subsequence CharSequence
Since:
1.0

getAt

public CharSequence getAt(EmptyRange range)
 
Support the range subscript operator for CharSequence or StringBuffer with EmptyRange
Parameters:
range - an EmptyRange.
Returns:
the subsequence CharSequence
Since:
1.5.0

getAt

public CharSequence getAt(Collection indices)
 
Select a List of characters from a CharSequence using a Collection to identify the indices to be selected.
Parameters:
indices - a Collection of indices.
Returns:
a CharSequence consisting of the characters at the given indices
Since:
1.0

take

public CharSequence take(int num)
 
Returns the first num elements from this CharSequence.
    def text = "Groovy"
    assert text.take( 0 ) == ''
    assert text.take( 2 ) == 'Gr'
    assert text.take( 7 ) == 'Groovy'
Parameters:
num - the number of chars to take from this CharSequence.
Returns:
a CharSequence consisting of the first num chars, or else the whole CharSequence if it has less then num elements.
Since:
1.8.1

Groovy JDK