|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Text
ATText is the public interface to a native AmbientTalk string (a string of characters). Extends the ATExpression interface since a Text can also be output by the parser as a literal.
Method Summary | |
---|---|
Number |
<=>(Text other)
Returns the value of evaluating the generalized equality between this text and a given one. |
Text |
+(Object other)
Concatenation infix operator. |
Boolean |
~=(Text other)
Attempts to match this text against a given regular expression. |
Table |
explode()
Explodes a text into a table of constituent characters. |
Nil |
find:do:(Text regexp,
Closure consumer)
Evaluates a given closure on those elements of this text that match a given regular expression. |
Number |
length()
Returns the length of this text. |
Numeric |
parseNumeric()
Tries to convert the text into a numeric object (a number or a fraction). |
Text |
replace:by:(Text regexp,
Closure transformer)
Returns a new text replacing those elements of this text that match a given regular expression with the value resulting of the evaluation of a given closure. |
Table |
split(Text regexpr)
Splits a text according to the given regular expression. |
Text |
toLowerCase()
Converts all of the characters in this text to lower case. |
Number |
toNumber()
Converts a single AmbientTalk character (i.e. a text of length 1) into its corresponding numeric Unicode value. |
Text |
toUpperCase()
Converts all of the characters in this text to upper case. |
Methods inherited from interface edu.vub.at.objects.AbstractGrammar |
---|
freeVariables |
Methods inherited from interface edu.vub.at.objects.Object |
---|
super |
Method Detail |
---|
Table explode()
Usage example:
"ambienttalk".explode()
returns [a, m, b, i, e, n, t, t, a, l, k]
Table
resulting of exploding the receiver text into a table of constituent characters.Table split(Text regexpr)
For regular expression syntax, see the Java regular-expression constructs in java.util.regex.Pattern. For regular expression syntax, see the Apache Regexp API of class RE.
Usage example:
"one, two, three".split(", ")
returns [ "one", "two", "three" ]
regexpr
- a text representing the regular expression to apply in the split.
Table
resulting of splitting the receiver text into a table according to the given regular expression.
edu.vub.at.exceptions.XIllegalArgument
- if regular expression's syntax is invalid.Nil find:do:(Text regexp, Closure consumer)
For regular expression syntax, see the Apache Regexp API of class RE.
Usage example:
"ambienttalk".find: "[aeiou]" do: { |vowel| buff << vowel; nil }
returns buff = "aiea"
regexp
- a text representing the regular expression to be found in the text.consumer
- the closure code that is applied each time the regular expression is matched in the text.
edu.vub.at.exceptions.XIllegalArgument
- if regular expression's syntax is invalid.
edu.vub.at.exceptions.InterpreterException
- if raised inside the code closure.Text replace:by:(Text regexp, Closure transformer)
For regular expression syntax, see the Apache Regexp API of class RE.
Usage example:
"ambienttalk".replace: "[aeiou]" by: { |vowel| vowel.toUpperCase() }
returns AmbIEnttAlk
regexp
- a text representing the regular expression to be found in the text.transformer
- the closure code that is applied each time the regular expression matches.
Text
replacing those elements of the table that match the regexpr pattern with the value resulting of the evaluation of the transformer closure.
edu.vub.at.exceptions.XIllegalArgument
- if regular expression's syntax is invalid.
edu.vub.at.exceptions.InterpreterException
- if raised inside the code closure.Text toUpperCase()
Text
resulting of the conversion.Text toLowerCase()
Text
resulting of the conversion.Number length()
Number
representing the length of the sequence of characters of this text.Text +(Object other)
Usage example:
"ambient" + "talk"
returns "ambienttalk"
other
- an object whose text representation is concatenated to the receiver text.
Number <=>(Text other)
The generalized equality returns:
Usage example:
"ambienttalk" <=> "ambienttalk"
returns 0
other
- a text.
Number
resulting of applying the generalized equality between the receiver and other.Boolean ~=(Text other)
For regular expression syntax, see the Apache Regexp API of class RE.
Usage example:
"ambienttalk" ~= ".*tt.*"
returns true
other
- a text representing the regular expression to be found in the text.
edu.vub.at.exceptions.XIllegalArgument
- if regular expression's syntax is invalid.Numeric parseNumeric()
"1.0".parseNumeric() => 1.0
edu.vub.at.exceptions.XIllegalArgument
- if the text cannot be converted into a number or a fractionNumber toNumber()
Character.getNumericValue(char)
.
XTypeMismatch
- if the receiver text is not a character (i.e. if it has length() > 1)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |