scala.runtime

class RichString

[source: scala/runtime/RichString.scala]

final class RichString(val self : java.lang.String)
extends Proxy with RandomAccessSeq[Char] with Ordered[java.lang.String]
Method Summary
def * (n : Int) : java.lang.String
return n times the current string
override def ++ [B >: Char](that : Iterable[B]) : RandomAccessSeq[B]
Appends two iterable objects.
override def apply (n : Int) : Char
def capitalize : java.lang.String
Returns this string with first character converted to upper case
override def compare (other : java.lang.String) : Int
Result of comparing this with operand that. returns x where x < 0 iff this < that x == 0 iff this == that x > 0 iff this > that
override def containsSlice [B](that : Seq[B]) : Boolean
Is that a slice in this?
override def drop (from : Int) : RichString
Returns this sequence without its n first elements If this sequence has less than n elements, the empty sequence is returned. (non-strict)
override def endsWith [B](that : Seq[B]) : Boolean
def format (args : Any*) : java.lang.String
override def indexOf [B](that : Seq[B]) : Int
Searches for the argument sequence in the receiver object, returning the smallest index where a match occurs. If the receiver object, this, is an infinite sequence this method will not terminate if there is no match. Similarly, if the both the receiver object and the argument, that are infinite sequences this method will not terminate. Because both the receiver object and the argument can both potentially be an infinite sequences, we do not attempt to use an optimized searching algorithm. Therefore, the running time will be proportional to the length of the receiver object and the argument. Subclasses and traits can potentially provide an optimized implementation.
override def length : Int
Returns the length of the sequence.
def lines : Iterator[java.lang.String]
Return all lines in this string in an iterator, excluding trailing line end characters, i.e. apply .stripLineEnd to all lines returned by linesWithSeparators.
def linesWithSeparators : Iterator[java.lang.String]
override def mkString : java.lang.String
Converts a collection into a flat String by each element's toString method.
def r : Regex
You can follow a string with `.r', turning it into a Regex. E.g. """A\w*""".r is the regular expression for identifiers starting with `A'.
override def reverse : RichString
A sequence consisting of all elements of this sequence in reverse order.
override def slice (from : Int, until : Int) : RichString
A sub-sequence starting at index from and ending (non-inclusive) at index until (non-strict)
def split (separator : Char) : Array[java.lang.String]
def split (separators : Array[Char]) : Array[java.lang.String]
override def startsWith [B](that : Seq[B]) : Boolean
Check whether the receiver object starts with the argument sequence.
def stripLineEnd : java.lang.String
def stripMargin (marginChar : Char) : java.lang.String
def stripMargin : java.lang.String
override def take (until : Int) : RichString
Returns a sequence consisting only over the first n elements of this sequence, or else the whole sequence, if it has less than n elements. (non-strict)
def toArray : Array[Char]
def toBoolean : Boolean
def toByte : Byte
def toDouble : Double
def toFloat : Float
def toInt : Int
def toLong : Long
def toShort : Short
override def toString : java.lang.String
Returns a string representation of the object.
Methods inherited from Ordered
<, >, <=, >=, compareTo
Methods inherited from RandomAccessSeq
projection, elements, partition, patch, toStream, safeIs
Methods inherited from Seq
lengthCompare, size, isEmpty, concat, last, lastOption, first, firstOption, headOption, isDefinedAt, lastIndexOf, findIndexOf, indexOf, map, flatMap, filter, slice, takeWhile, dropWhile, contains, subseq, toArray, toSeq, equalsWith, startsWith
Methods inherited from Collection
stringPrefix
Methods inherited from Iterable
foreach, forall, exists, find, foldLeft, foldRight, /:, :\, reduceLeft, reduceRight, copyToBuffer, sameElements, toList, mkString, mkString, addString, addString, addString, copyToArray, hasDefiniteSize
Methods inherited from PartialFunction
orElse, andThen
Methods inherited from Function1
compose
Methods inherited from Proxy
hashCode, equals
Methods inherited from AnyRef
getClass, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Method Details
override def apply(n : Int) : Char

override def length : Int
Returns the length of the sequence.
Returns
the sequence length.

override def toString : java.lang.String
Returns a string representation of the object.

The default representation is platform dependent.

Returns
a string representation of the object.

Overrides
Proxy.toString

override def mkString : java.lang.String
Converts a collection into a flat String by each element's toString method.
Notes
Will not terminate for infinite-sized collections.

override def slice(from : Int, until : Int) : RichString
A sub-sequence starting at index from and ending (non-inclusive) at index until (non-strict)
Parameters
from - The index of the first element of the slice
until - The index of the element following the slice
Throws
IndexOutOfBoundsException - if from < 0 or length < from + len
Overrides
RandomAccessSeq.slice

override def ++[B >: Char](that : Iterable[B]) : RandomAccessSeq[B]
Appends two iterable objects.
Overrides
RandomAccessSeq.++

override def take(until : Int) : RichString
Returns a sequence consisting only over the first n elements of this sequence, or else the whole sequence, if it has less than n elements. (non-strict)
Parameters
n - the number of elements to take
Returns
a possibly projected sequence
Overrides
RandomAccessSeq.take

override def drop(from : Int) : RichString
Returns this sequence without its n first elements If this sequence has less than n elements, the empty sequence is returned. (non-strict)
Parameters
n - the number of elements to drop
Returns
the new sequence
Overrides
RandomAccessSeq.drop

override def startsWith[B](that : Seq[B]) : Boolean
Check whether the receiver object starts with the argument sequence.
Returns
true if that is a prefix of this, otherwise false
See Also
Seq.startsWith

override def endsWith[B](that : Seq[B]) : Boolean
Returns
true if this sequence end with that sequence
See Also
String.endsWith

override def indexOf[B](that : Seq[B]) : Int
Searches for the argument sequence in the receiver object, returning the smallest index where a match occurs. If the receiver object, this, is an infinite sequence this method will not terminate if there is no match. Similarly, if the both the receiver object and the argument, that are infinite sequences this method will not terminate. Because both the receiver object and the argument can both potentially be an infinite sequences, we do not attempt to use an optimized searching algorithm. Therefore, the running time will be proportional to the length of the receiver object and the argument. Subclasses and traits can potentially provide an optimized implementation.
Returns
-1 if that not contained in this, otherwise the smallest index where that is found.
See Also
String.indexOf

override def containsSlice[B](that : Seq[B]) : Boolean
Is that a slice in this?

override def reverse : RichString
A sequence consisting of all elements of this sequence in reverse order.
Overrides
RandomAccessSeq.reverse

def *(n : Int) : java.lang.String
return n times the current string

override def compare(other : java.lang.String) : Int
Result of comparing this with operand that. returns x where x < 0 iff this < that x == 0 iff this == that x > 0 iff this > that
Overrides
Ordered.compare

def stripLineEnd : java.lang.String

Strip trailing line end character from this string if it has one. A line end character is one of

  • LF - line feed (0x0A hex)
  • FF - form feed (0x0C hex)

If a line feed character LF is preceded by a carriage return CR (0x0D hex), the CR character is also stripped (Windows convention).


def linesWithSeparators : Iterator[java.lang.String]

Return all lines in this string in an iterator, including trailing line end characters.

The number of strings returned is one greater than the number of line end characters in this string. For an empty string, a single empty line is returned. A line end character is one of

  • LF - line feed (0x0A hex)
  • FF - form feed (0x0C hex)

def lines : Iterator[java.lang.String]
Return all lines in this string in an iterator, excluding trailing line end characters, i.e. apply .stripLineEnd to all lines returned by linesWithSeparators.

def capitalize : java.lang.String
Returns this string with first character converted to upper case

def stripMargin(marginChar : Char) : java.lang.String

For every line in this string:

Strip a leading prefix consisting of blanks or control characters followed by marginChar from the line.

def stripMargin : java.lang.String

For every line in this string:

Strip a leading prefix consisting of blanks or control characters followed by | from the line.

@throws(classOf[java.util.regex.PatternSyntaxException])

def split(separator : Char) : Array[java.lang.String]

@throws(classOf[java.util.regex.PatternSyntaxException])

def split(separators : Array[Char]) : Array[java.lang.String]

def r : Regex
You can follow a string with `.r', turning it into a Regex. E.g. """A\w*""".r is the regular expression for identifiers starting with `A'.

def toBoolean : Boolean

def toByte : Byte

def toShort : Short

def toInt : Int

def toLong : Long

def toFloat : Float

def toDouble : Double

def toArray : Array[Char]

def format(args : Any*) : java.lang.String

Uses the underlying string as a pattern (in a fashion similar to printf in C), and uses the supplied arguments to fill in the holes. Only works on Java 1.5 or higher!

The interpretation of the formatting patterns is described in java.util.Formatter.

Parameters
args - the arguments used to instantiating the pattern.
Throws
java.lang.IllegalArgumentException -