Functions of ballerina.builtin package
public function <blob b> toString(string encoding) (string)
Converts blob to a string
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
b | blob | The blob value to be converted |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
encoding | string | Encoding to used in blob conversion to string |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | String representation of the given blob |
public function createTime(int year, int month, int date, int hour, int minute, int second, int milliSecond, string zoneId) (Time)
Returns the Time struct correspoding to the given time components and timezone.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
year | int | The year representation |
month | int | The month-of-year to represent, from 1 (January) to 12 (December) |
date | int | The day-of-month to represent, from 1 to 31 |
hour | int | The hour-of-day to represent, from 0 to 23 |
minute | int | The minute-of-hour to represent, from 0 to 59 |
second | int | The second-of-minute to represent, from 0 to 59 |
milliSecond | int | The milli-of-second to represent, from 0 to 999 |
zoneId | string | The zone id of the required timezone.If empty the system local timezone will be used |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
Time | Time struct containing time and zone information. |
public function currentTime() (Time)
Returns the current time value with the system default timezone.
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
Time | Time struct containing the time and zone information. |
public function <datatable dt> close()
Releases the database connection.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
dt | datatable | The datatable object |
public function <datatable dt> getNext() (any)
Retrives the current row and return a struct with the data in the columns
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
dt | datatable | The datatable object |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
any | The resulting row as a struct |
public function <datatable dt> hasNext() (boolean)
Checks for a new row in the given datatable. If a new row is found, moves the cursor to it.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
dt | datatable | The datatable object |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
boolean | True if there is a new row; false otherwise |
public function <json j> getKeys() (string[])
Returns an array of keys contained in the specified JSON.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
j | json | A JSON object |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string[] | A string array of keys contained in the specified JSON |
public function <json j> remove(string key)
Removes each element that matches the given key.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
j | json | A JSON object |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
key | string | Key of the field to remove |
public function <json j> toString() (string)
Converts a JSON object to a string representation
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
j | json | A JSON object |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | String value of the converted JSON |
public function <json j> toXML(jsonOptions options) (xml, TypeConversionError)
Converts a JSON object to a XML representation
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
j | json | A JSON object |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
options | jsonOptions | jsonOptions struct for JSON to XML conversion properties |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
xml | The XML representation of the JSON | |
TypeConversionError |
public function <string mainString> contains(string subString) (boolean)
Returns a Boolean value indicating whether a string contains the specified substring
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
subString | string | The substring to be compared |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
boolean | True if the string contains the substring; false otherwise |
public function <string mainString> equalsIgnoreCase(string anotherString) (boolean)
Compares two strings, ignoring the case of the strings
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
anotherString | string | The string to be compared |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
boolean | True if the strings are equal; false otherwise |
public function <string mainString> findAllWithRegex(Regex reg) (string[], error)
Finds all the strings matching the regular expression
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
reg | Regex | Regular expression |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string[] | The matching string array | |
error | error: Error will be returned if there exist a syntax error in pattern |
public function <string mainString> hasPrefix(string prefix) (boolean)
Returns a Boolean value indicating whether a string starts with the specified prefix
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
prefix | string | The prefix to be compared |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
boolean | True if the string starts with the prefix; false otherwise |
public function <string mainString> hasSuffix(string suffix) (boolean)
Returns a Boolean value indicating whether the string ends with specified suffix
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
suffix | string | The suffix to be compared |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
boolean | True if the string ends with the suffix; false otherwise |
public function <string mainString> indexOf(string subString) (int)
Returns the first index of the first occurence of the substring within the specified string
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
subString | string | The substring to search for |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
int | The index of the first occurence of the substring |
public function <string mainString> lastIndexOf(string subString) (int)
Returns the first index of the last occurence of the substring within the specified string
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
subString | string | The substring to search for |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
int | The index of the last occurence of the substring |
public function <string mainString> length() (int)
Returns the length of the specified string
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
int | The length of the specified string |
public function <string mainString> matchesWithRegex(Regex reg) (boolean, error)
Returns a Boolean value indicating whether the string matches the regular expression
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
reg | Regex | Regular expression |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
boolean | True if the string matches the regex; false otherwise | |
error | error: Error will be returned if there exist a syntax error in pattern |
public function <string mainString> replace(string replacePattern, string replaceWith) (string)
Replaces all instances of the replacePattern string with the replaceWith string and returns the result
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
replacePattern | string | The pattern to search for |
replaceWith | string | The replacement string |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | The derived string |
public function <string mainString> replaceAll(string replacePattern, string replaceWith) (string)
Replaces each substring of the mainString that matches the given regular expression with the given replacement
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
replacePattern | string | The regular expression to search for |
replaceWith | string | The replacement string |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | The derived string |
public function <string mainString> replaceAllWithRegex(Regex reg, string replaceWith) (string, error)
Replaces the mainString with the replacement of occurrences that matches the given regular expression
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
reg | Regex | Regular expression |
replaceWith | string | The replacement string |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | The derived string | |
error | error: Error will be returned if there exist a syntax error in pattern |
public function <string mainString> replaceFirst(string replacePattern, string replaceWith) (string)
Replaces the first instance of the replacePattern with the replaceWith string and returns the result
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
replacePattern | string | The pattern to search for |
replaceWith | string | The replacement string |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | The derived string |
public function <string mainString> replaceFirstWithRegex(Regex reg, string replaceWith) (string, error)
Replaces the first instance of the regular expression matching area with the replaceWith string and returns the result
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
reg | Regex | Regular expression |
replaceWith | string | The replacement string |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | The derived string | |
error | error: Error will be returned if there exist a syntax error in pattern |
public function <string mainString> split(string regex) (string[])
Splits the string with the given regular expression to produce a string array.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
regex | string | The regex to split the string |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string[] | The split string array |
public function <string mainString> subString(int from, int to) (string)
Returns a new string that is the substring of the specified string
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
from | int | The starting index |
to | int | The ending index |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | The derived sub string |
public function <string mainString> toBlob(string encoding) (blob)
Converts string to a blob
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
mainString | string | string value to be converted |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
encoding | string | Encoding to used in the conversion |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
blob | The blob representation of the given String |
public function <string mainString> toLowerCase() (string)
Returns a string with all the characters converted to lowercase
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | The string converted to lowercase |
public function <string mainString> toUpperCase() (string)
Returns a string with all the characters converted to uppercase
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | The string converted to uppercase |
public function <string mainString> trim() (string)
Returns a trimmed string by omitting the leading and trailing whitespaces of the original string
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | The derived string |
public function <string mainString> unescape() (string)
Returns an unescaped string by omitting the escape characters of the original string
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | The derived string |
public function <map m> clear()
Clear the items from given map
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
m | map | The map object |
public function <map m> hasKey(string key) (boolean)
Check whether specific key exists from the given map
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
m | map | The map object |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
key | string | The key to be find existence |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
boolean |
public function <map m> keys() (string[])
Returns an array of keys contained in the specified map
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
m | map | The map object |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string[] | A string array of keys contained in the specified map |
public function <map m> remove(string key)
Removes the specified element from the map
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
m | map | The map object |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
key | string | The key to be removed |
public function <map m> values() (any[])
Returns an array of values contained in the specified map
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
m | map | The map object |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
any[] | An any array of values contained in the specified map |
public function parse(string data, string format) (Time)
Returns the time for the given string representation based on the given format string.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
data | string | The time text to parse |
format | string | The format which is used to parse the given text |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
Time | Time struct containing time and zone information. |
public function print(any a)
Prints a 'any' value to the STDOUT
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
a | any | any value to be printed |
public function println(any a)
Prints an any value to the STDOUT in a new line
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
a | any | any value to be printed |
public function sleep(int t)
Halt the current thread for the specified time period
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
t | int | int: Sleep time in milliseconds |
public function <Time time> addDuration(int years, int months, int days, int hours, int minutes, int seconds, int milliSeconds) (Time)
Add specified durations to the given time value.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
time | Time | The time struct which needs to add the given duration |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
years | int | The year representation |
months | int | The month-of-year to represent, from 1 (January) to 12 (December) |
days | int | The day-of-month to represent, from 1 to 31 |
hours | int | The hour-of-day to represent, from 0 to 23 |
minutes | int | The minute-of-hour to represent, from 0 to 59 |
seconds | int | The second-of-minute to represent, from 0 to 59 |
milliSeconds | int | The milli-of-second to represent, from 0 to 999 |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
Time | Time struct containing time and zone information after the addition. |
public function <Time time> day() (int)
Returns the date representation of the given time.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
time | Time | The time struct which needs to get the date representation |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
int | The day-of-month, from 1 to 31. |
public function <Time time> format(string format) (string)
Returns formatted string representation of the given time.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
time | Time | The time struct for which needs to get the string representation |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
format | string | The format which is used to format the given text |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | The formatted string of the given time. |
public function <Time time> getDate() (int, int, int)
Returns the date representation of the given time.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
time | Time | The time struct which needs to get the date representation |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
int | The year representation. | |
int | The month-of-year, from 1 (January) to 12 (December). | |
int | The day-of-month, from 1 to 31. |
public function <Time time> getTime() (int, int, int, int)
Returns the time representation of the given time.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
time | Time | The time struct which needs to get the time representation |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
int | The hour-of-day, from 0 to 23. | |
int | The minute-of-hour to represent, from 0 to 59. | |
int | The second-of-minute, from 0 to 59. | |
int | The milli-of-second, from 0 to 999. |
public function <Time time> hour() (int)
Returns the hour representation of the given time.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
time | Time | The time struct which needs to get the hour representation |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
int | The hour-of-day, from 0 to 23. |
public function <Time time> milliSecond() (int)
Returns the millisecond representation of the given time.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
time | Time | The time struct which needs to get the millisecond representation |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
int | The milli-of-second, from 0 to 999. |
public function <Time time> minute() (int)
Returns the minute representation of the given time.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
time | Time | The time struct which needs to get the minute representation |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
int | The minute-of-hour to represent, from 0 to 59. |
public function <Time time> month() (int)
Returns the month representation of the given time.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
time | Time | The time struct which needs to get the month representation |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
int | The month-of-year, from 1 (January) to 12 (December). |
public function <Time time> second() (int)
Returns the second representation of the given time.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
time | Time | The time struct which needs to get the second representation |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
int | The second-of-minute, from 0 to 59. |
public function <Time time> subtractDuration(int years, int months, int days, int hours, int minutes, int seconds, int milliSeconds) (Time)
Subtract specified durations from the given time value.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
time | Time | years: The year representation |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
years | int | The year representation |
months | int | The month-of-year to represent, from 1 (January) to 12 (December) |
days | int | The day-of-month to represent, from 1 to 31 |
hours | int | The hour-of-day to represent, from 0 to 23 |
minutes | int | The minute-of-hour to represent, from 0 to 59 |
seconds | int | The second-of-minute to represent, from 0 to 59 |
milliSeconds | int | The milli-of-second to represent, from 0 to 999 |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
Time | Time struct containing time and zone information after the subtraction. |
public function <Time time> toString() (string)
Returns ISO 8601 string representation of the given time.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
time | Time | The time struct for which needs to get the string representation |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | The ISO 8601 formatted string of the given time. |
public function <Time time> toTimezone(string zoneId) (Time)
Change the timezone of the given time.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
time | Time | The time struct which needs to change the timezone information |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
zoneId | string | The new timezone id |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
Time | Time struct containing time and zone information after the conversion. |
public function <Time time> weekday() (string)
Returns the weekday representation of the given time.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
time | Time | The time struct which needs to get the weekday representation |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | The weekday representation from SUNDAY to SATURDAY. |
public function <Time time> year() (int)
Returns the year representation of the given time.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
time | Time | The time struct which needs to get the year representation |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
int | The year representation. |
public function <xml x> children() (xml)
Selects all the children of the elements in an XML, and return as a sequence.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
x | xml | An XML object |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
xml | All the children of the elements in the xml |
public function <xml x> copy() (xml)
Make a deep copy of an XML.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
x | xml | An XML object |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
xml | A Copy of the XML |
public function <xml x> elements() (xml)
Get all the items that are of element type in an XML sequence.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
x | xml | An XML object |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
xml | All the elements-type items in the given XML sequence |
public function <xml x> getElementName() (string)
Get the fully qualified name of the element as a string. Returns an empty string if the XML is not a singleton.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
x | xml | An XML object |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | Qualified name of the XML as a string |
public function <xml x> getItemType() (string)
Get the type of a XML as a string. If the XML is singleton, type can be one of 'element', 'text', 'comment' or 'pi'. Returns an empty string if the XML is not a singleton.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
x | xml | An XML object |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | Type of the XML as a string |
public function <xml x> getTextValue() (string)
Get the text value of a XML. If the XML is a sequence, concatenation of the text values of the members of the sequence is returned. If the XML is an element, then the text value of the sequence of children is returned. If the XML is a text item, then the text is returned. Otherwise, an empty string is returned.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
x | xml | An XML object |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | Text value of the xml |
public function <xml x> isEmpty() (boolean)
Check whether the XML sequence is empty.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
x | xml | An XML object |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
boolean | Boolean flag indicating whether the XML sequence is empty |
public function <xml x> isSingleton() (boolean)
Check whether the XML sequence contains only a single element.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
x | xml | An XML object |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
boolean | Boolean flag indicating whether the XML sequence contains only a single element |
public function <xml x> removeAttribute(string qname)
Remove an attribute from an XML.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
x | xml | An XML object |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
qname | string | Qualified name of the attribute |
public function <xml x> select(string qname) (xml)
Get all the items that are of element type, and matches the given qualified name, in an XML sequence.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
x | xml | An XML object |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
qname | string | Qualified name of the element |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
xml | All the elements-type items in the given XML sequence, that matches the qualified name |
public function <xml x> selectChildren(string qname) (xml)
Selects all the children of the elements in this sequence that matches the given qualified name.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
x | xml | An XML object |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
qname | string | Qualified name of the element |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
xml | All the children of the elements in this sequence that matches the given qualified name |
public function <xml x> selectDescendants(string qname) (xml)
Searches in children recursively for elements matching the qualified name and returns a sequence containing them all. Does not search within a matched result.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
x | xml | An XML object |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
qname | string | Qualified name of the element |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
xml | All the descendants that matches the given qualified name, as a sequence |
public function <xml x> setAttributes(map attributes)
Sets the attributes to the provided attributes map.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
x | xml | An XML object |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
attributes | map | Attributes map |
public function <xml x> setChildren(xml children)
Set the children of an XML if its a singleton. An Error otherwise. Any existing children will be removed.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
x | xml | An XML object |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
children | xml | x: An XML object |
public function <xml x> slice(int startIndex, int endIndex) (xml)
Slice and return a subsequence of the an XML sequence.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
x | xml | An XML object |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
startIndex | int | Start index, inclusive |
endIndex | int | End index, exclusive |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
xml | Sliced sequence |
public function <xml x> strip() (xml)
Strips any text items from an XML sequence that are all whitespace.
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
x | xml | An XML object |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
xml | Striped sequence |
public function <xml x> toJSON(xmlOptions options) (json)
Converts a XML object to a JSON representation
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
x | xml | A XML object |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
options | xmlOptions | xmlOptions struct for XML to JSON conversion properties |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
json | JSON representation of the given XML |
Structs of ballerina.builtin package
public struct IllegalStateException
Fields:
Field Name | Data Type | Description |
---|---|---|
msg | string | |
cause | error | |
stackTrace | StackFrame[] |
public struct NullReferenceException
Fields:
Field Name | Data Type | Description |
---|---|---|
msg | string | |
cause | error | |
stackTrace | StackFrame[] |
public struct Regex
Represents a Regular expression in ballerina and can perform various Regular expression methods.
Fields:
Field Name | Data Type | Description |
---|---|---|
pattern | string | regex:Pattern as a String |
public struct StackFrame
Fields:
Field Name | Data Type | Description |
---|---|---|
caller | string | |
packageName | string | |
fileName | string | |
lineNumber | int |
public struct Time
Ballerina Time struct represents a particular time with its associated timezone.
Fields:
Field Name | Data Type | Description |
---|---|---|
time | int | Time value as milliseconds since epoch. |
zone | Timezone | The time zone of the time. |
public struct Timezone
Ballerina Timezone struct represents the timezone information associated with a particular time.
Fields:
Field Name | Data Type | Description |
---|---|---|
zoneId | string | Zone short ID or offset string. |
zoneOffset | int | The offset in seconds. |
public struct TypeCastError
Fields:
Field Name | Data Type | Description |
---|---|---|
msg | string | |
cause | error | |
stackTrace | StackFrame[] | |
sourceType | string | |
targetType | string |
public struct TypeConversionError
Fields:
Field Name | Data Type | Description |
---|---|---|
msg | string | |
cause | error | |
stackTrace | StackFrame[] | |
sourceType | string | |
targetType | string |
public struct error
Fields:
Field Name | Data Type | Description |
---|---|---|
msg | string | |
cause | error | |
stackTrace | StackFrame[] |
public struct jsonOptions
Options struct for JSON to XML conversion
Fields:
Field Name | Data Type | Description |
---|---|---|
attributePrefix | string | Prefix to identify XML attribute,default value is '@'. |
arrayEntryTag | string | The name of the tag to be added to each entry of JSON array. |
public struct xmlOptions
Options struct for XML to JSON conversion
Fields:
Field Name | Data Type | Description |
---|---|---|
attributePrefix | string | prefix to add to the key to identify a XML attribute and namespaces, default value is '@'. |
preserveNamespaces | boolean | Indicate whether to preserve namespace prefixes when converting or not. |