Set of elementary functions and classes.
Entities at anvil.lang are accessible directly without a need
to import or use anvil.lang prefix.
Namespaces
Set of functions which behave same as the
corresponding operators.
Classes
Array is collections of keys mapped to values. Array
has capabilities of list as it also retains doubly linked
list of its elements.
Binary is an efficient implemtation of variable length array of bytes.
Boolean is a base class for true and false.
Buffer is a mutable variable length sequence of characters.
False is constant indicating boolean false value.
Float is a double precision 64 bit floating point number.
Inf is a constant for (semi-)infinite value.
Int is a 64 bit signed integer.
Iterator generates ordered series of (keys and) values.
These keys and values can be retrived one at a time.
List is a mutable sequence of values.
Map represents mapping of key to value.
Null is constant indicating empty value.
Abstract base class for integers and floats.
Object is a root of the class hiearchy: every class has
a object as a superclass.
Pattern represents compiled regular expression.
Range represents range of values from start to end,
where start is inclusive and end is exclusive.
Sequence represents list of elements, that may
be accessed with index. Some of sequences (such
as string and tuple) are immutable and mutating
operations always return copy of original sequence
modified.
The string class represents character strings.
String is a sequence of characters.
True is a constant indicating boolean true value.
Tuple is an immutable sequence of values.
undefined is constant indicating non existent value.
Exceptions
Throwable is a carrier for exceptions, capable of holding of
message and stack trace.
Functions
Returns memory address of parameters. Returned value for
same value is not guaranteed to be same between calls.
Checks if two objects share the same memory address.
Serializes data.
| Returns |
Data serialized to binary. |
Checks if given tool permission exists, against
current security policy
Converts given character code into character (to string
which has the length of one).
Creates shallow copy from given value.
| Parameters |
value -
Value to be cloned.
|
| Returns |
Cloned value |
Returns list containing 'a' and 'b' converted
to similar types according to same rules
applied to arithmetic operations.
If second parameter is omitted tries to convert
string to int or float, if conversion fails
returns self.
Returns context of current custom tag.
Creates deep copy from 'value'.
| Parameters |
value -
Value to be copied.
|
| Returns |
Copied value |
createArray(
range dimensions...)
Creates multidimensional rectangular array with given dimensions.
| Parameters |
dimension -
Integer for upper bound or list as (lobound, hibound).
|
| Returns |
Array created |
createMatrix(
range dimensions...)
Creates multidimensional rectangular array with default values.
| Parameters |
defaultValue -
Default value for each leaf element.
dimension -
Integer for upper bound or list as (lobound, hibound).
|
| Returns |
Array created |
Decodes URL encoded string.
| Parameters |
str -
URL encoded string
encoding -
Character encoding to use
|
| Returns |
Decoded string |
| Throws |
BadParameter -
if charset encoding is not supported
|
Returns the value referred by this given ref.
| Parameters |
ref -
Ref to variable
derefAll -
If true, all references are followed until
first non-ref value is encountered.
|
Iterates through given elements and executes given function for
each element.
| Parameters |
callback -
Callable receiving parameters (element, key)
|
| Returns |
elements |
Rtturns the value that was 'injected' to generator using
anvil.lang.iterator.inject().
This function may only be called inside generator function.
Encodes string.
| Parameters |
str -
String
encoding -
Character encoding to use
|
| Returns |
Encoded string |
| Throws |
BadParameter -
if charset encoding is not supported
|
Converts string to backslash escaped format.
| Parameters |
str -
String to escape
|
| Returns |
Escaped string |
Parses, evaluates and returns a result of constant anvil expression.
| Throws |
ImportError -
If parsing of constant failed
BadParameter -
If expression does not containt constant expression
|
Validates any number of arguments by checking if their are
of desired type.
Arguments are expected to be mappings containing the value candidates
on the left side and types on the right side.
| Throws |
BadArgument -
if any of candidate values didn't match the requested type
|
Finds all regions from given text mathing given regular
expression pattern.
| Parameters |
pattern -
Regular expression pattern
text -
Text to inspect
|
| Returns |
Iterator of strings |
| Throws |
MalformedPattern -
If pattern is invalid
|
Format 'sprintf' style format string with given parameters. Format
may contain fields:
|
% [-]? [+]? [0]? [width] ( [.] [precision] ) [csdifg]
|
| - |
Adjust left, instead of right.
|
| + | Numbers with sign |
| 0 | Pad numbers with zeros, instead of spaces |
| width | Width of field, if '*' width will be taken from arguments |
| precision | Width of fraction part (doubles), if '*' width will be
taken from arguments |
| c |
Character (integer or first character from string).
|
| s | String |
| d,i | Integer |
| f |
Float, follows width.precision stricly
|
| g |
Float with signicant fraction shown, if precision is zero (or not given)
shows significant digits from it.
|
Use %% to escape %.
| Parameters |
format -
Format string
|
| Returns |
Formatted string |
Returns a new list containing
all elements in given sequence
that matched given regular expression.
Creates a java.lang.reflect.Proxy that implements
all the java interfaces given as parameters.
If handler is a function it receives the name of method as first argument
followed by the parameters of original method call.
Otherwise the handler is treated as a class instance and corresponding
method is invoked with parameters of original method call.
Joins the elements together with given clue.
| Parameters |
clue -
Clue to join with, default is ", ".
|
Converts parameter to lowercase.
Loads the given java class or interface.
Logs messages.
Logs error messages.
Checks if any region on given text matches given
regular expression.
| Parameters |
pattern -
Regular expression pattern
text -
Text to inspect
|
| Returns |
Matches or boolean |
| Throws |
MalformedPattern -
If pattern is invalid
|
Converts first character of given string to its
ordinal value.
Attempts to parse given string to float.
| Parameters |
str -
String to convert
defaultValue -
Value returned if parsing failed, by default null.
|
| Returns |
Parsed float. |
Attempts to parse given string to integer.
| Parameters |
str -
String to convert
radix -
Radix of string, default is 10.
defaultValue -
Value returned if parsing failed, by default null.
|
| Returns |
Parsed integer. |
Attempts to parse given string to integer. Valid formats are
123 (decimal), 0x123 (hex) , 0b101 (binary) , 0123 (octal)
| Parameters |
str -
String to convert
defaultValue -
Value returned if parsing failed, by default null.
|
| Returns |
Integer parsed. |
Returns iterator that iterates through given elements
and pipes the return value of given function as element
on call to iterator.next.
| Parameters |
converter -
Callable converter receiving parameters element, index)
|
Same as builtin statement print. Prints all
parameters.
Same as builtin statement printbr. Prints all
parameters, <br;gt; and a newline.
Same as builtin statement println. Prints all
parameters and newline.
Converts all applicable characters in string to html-entities.
Converts all meta characters in string to html-entities.
Meta characters are ampersand, apostrophe, greater-than, less-than
non-breaking space, quotation mark and soft hyphen.
Iterates through the given elements and calls reducer function so
that the first parameter will be either the result of previous reducer
call or intialValue (if it was given), and all other parameters, up to
function's required parameter count are taken from the elements.
| Parameters |
reducer -
Callable reducer taking from count parameters
intialValue -
initial value of reduction
|
| Returns |
the return value of last call to reducer or initialValue |
Generates and returns programmable ref from given class instance.
| Parameters |
impl -
Class having _getRef (and _setRef) methods
|
Substitutes all regions from given text matching given
regular expression with given replacement
| Parameters |
pattern -
Regular expression pattern
replacement -
Replacement, either a string or function:
function replacer(list matchedGroups).
amount -
Number of occurences to replace, if omitted, all occurences are substituted.
|
| Throws |
MalformedPattern -
If pattern is invalid
|
Reveals and returns the ref implementation, encapsulated with ref().
| Parameters |
ref -
Programmable ref
|
Reverses given list of elements and returns new iterator from it.
Returns iterator of all elements for which the
given function returned true.
| Parameters |
pipe -
Callable selector receiving parameters
(element, index)
|
Serializes data.
| Returns |
Data serialized to string representation. |
Sorts the elements of sequence with given comparator.
| Parameters |
sorter -
Callable comparator receiving parameters (value1, value2)
|
Splits a string into a list of strings and returns that list.
If patter is omitted splits according to whitespaces.
Returns english numeral suffix (st, nd, th) for given value.
| Parameters |
value -
|
| Returns |
Numeral suffix. |
Converts value to valid code producing the same value.
Converts value to array. Useful with sequences, arrays, iterators
and any other values returning iterator.
Converts number to binary format.
| Parameters |
number -
Number to convert
length -
Length of resulting string
pad -
Padding character, default is '0'
|
| Returns |
Number converted to binary |
Converts sequence to binary. Useful with sequences, arrays, iterators
and any other values returning iterator.
Converts sequence to buffer. Useful with sequences, arrays, iterators
and any other values returning iterator.
Converts number to hexadecimal format.
| Parameters |
number -
Number to convert
length -
Length of resulting string
pad -
Padding character, default is '0'
|
| Returns |
Number converted to hexadecimal |
toHref(param, ...)
Creates query string.
| Parameters |
param -
Map key=>value for mapped values,
array or sequence of values or anything else for mappings with empty value.
|
| Returns |
Query string |
Converts value to binary. Useful with sequences, arrays, iterators
and any other values returning iterator.
Converts given parameter to lower case.
Converts number to octal format.
| Parameters |
number -
Number to convert
length -
Length of resulting string
pad -
Padding character, default is '0'
|
| Returns |
Number converted to octal |
Converts number to given radix format.
| Parameters |
number -
Number to convert
radix -
Radix
length -
Length of resulting string
pad -
Padding character, default is '0'
|
| Returns |
Number converted to given radix |
Converts sequence to string. Useful with sequences, arrays, iterators
and any other values returning iterator.
Converts sequence to binary. Useful with sequences, arrays, iterators
and any other values returning iterator.
Converts given parameter to upper case.
Trims whitespaces from beginning and end of string.
Converts parameter to uppercase.
Converts all applicable "entities; to their character counterparts.
| Parameters |
str -
String to unquote
|
| Returns |
Unquoted string |
Unserializes data representation.
Converts all applicable characters in string to wml supported entities.