type
methods
addArg | |
---|---|
compareDis |
Given two display strings, return 1, 0, or -1 if a is less than, equal to, or greater than b. |
dict0 |
Empty dict singleton |
dict1 |
Create a Dict with one name/value pair |
dict2 |
Create a Dict with two name/value pairs |
dict3 |
Create a Dict with three name/value pairs |
dict4 |
Create a Dict with four name/value pairs |
dict5 |
Create a Dict with five name/value pairs |
dict6 |
Create a Dict with six name/value pairs |
dictAll |
Return if all of the tag name/value pairs match the given function. |
dictAny |
Return if any of the tag name/value pairs match the given function. |
dictEq |
Return if two dicts are equal with same name/value pairs. |
dictFindAll |
Return a new Dict containing the name/value pairs for which f returns true. |
dictHashKey |
Construct an object which wraps a dict and is suitable to use for a hash key in a |
dictMap |
Apply the given map function to each name/value pair to construct a new Dict. |
dictMerge |
Add/set all the name/value pairs in a with those defined in b. |
dictNames |
Get a read/write list of the dict's name keys. |
dictRemove |
Remove a name/val pair from an exisiting dict, or if the name isn't found then return original dict. |
dictRemoveAll |
Remove all names from the given dict. |
dictRename |
Rename given name if its defined in the dict, otherwise return original. |
dictSet |
Set a name/val pair in an existing dict or d is null then create a new dict with given name/val pair. |
dictToDis |
Given a dict, attempt to find the best display string |
dictToHaystack |
Coerce dict to Haystack types, see |
dictToMap |
Convert a Dict to a read/write map. |
dictVals |
Get all the non-null values mapped by a dictionary. |
dictsNames |
Given a list of dictionaries, find all the common names used. |
discretePeriods |
Iterate a |
emptyDict |
Get the emtpy Dict instance. |
escapeTagName |
Escape tag name into "__{utf-8 hex}" format |
gridFlatten |
Flatten a list of grids into a single grid. |
isEscapedTagName |
Return if tag name starts with "__" as escaped name |
isKindName |
Return if the given string is a legal kind name |
isTagName |
Return if the given string is a legal tag name |
macro |
Process macro pattern with given scope of variable name/value pairs. |
macroVars |
Return the list of variable tag names used in the given |
makeDict |
Make a Dict instance where |
makeDict1 |
Make a Dict with one name/value pair. |
makeDict2 |
Make a Dict with two name/value pairs. |
makeDict3 |
Make a Dict with three name/value pairs. |
makeDict4 |
Make a Dict with four name/value pairs. |
makeDict5 |
Make a Dict with five name/value pairs. |
makeDict6 |
Make a Dict with six name/value pairs. |
makeDictGrid |
Construct a grid for a Dict row. |
makeDicts |
Make a list of Dict instances using |
makeDictsGrid |
Construct a grid for a list of Dict rows. |
makeEmptyGrid |
Construct an empty grid with just the given grid level meta-data. |
makeErrGrid |
Construct a grid for an error response. |
makeListGrid |
Construct a grid with one column for a list. |
makeListsGrid |
Construct a grid for a list of rows, where each row is a list of cells. |
makeMapGrid |
Convenience for |
makeMapsGrid |
Convenience for |
relDis |
Get a relative display name. |
tagToLocale |
Get the localized string for the given tag name for the current locale. |
toDateSpan |
Coerce an object to a DateSpan |
toErrMeta |
Map an exception to its standard tags |
toGrid |
Coerce a value to a Grid |
toHaystack |
Coerce a value to one of the Haystack types. |
toId |
Coerce a value to a Ref identifier |
toIds |
Coerce a value to a list of Ref identifiers |
toRec |
Coerce a value to a record Dict |
toRecs |
Coerce a value to a list of record Dicts |
toSpan |
Coerce an object to a |
toTagName |
Take an arbitrary string and convert into a safe tag name. |
unescapeTagName |
Unescape tag name from "__{utf-8 hex}" format |
Slot Details
addArg
compareDis
dict0
static Dict dict0()
Empty dict singleton
dict1
dict2
dict3
dict4
dict5
dict6
dictAll
dictAny
dictEq
static Bool dictEq(Dict a, Dict b)
Return if two dicts are equal with same name/value pairs. Value are compared via the Obj.equals
method. Ordering of the dict tags is not considered.
dictFindAll
dictHashKey
static Obj dictHashKey(Dict d)
Construct an object which wraps a dict and is suitable to use for a hash key in a Map
. The key provides implementations of Obj.hash
and Obj.equals
based on the the name/value pairs in the dict. Hash keys do not support Dicts which contain anything but scalar values (nested lists, dicts, and grids are silently ignored for hash/equality purposes).
dictMap
dictMerge
dictNames
dictRemove
dictRemoveAll
dictRename
dictSet
dictToDis
dictToHaystack
static Dict dictToHaystack(Dict dict, Dict? opts := null)
Coerce dict to Haystack types, see toHaystack
.
dictToMap
dictVals
dictsNames
discretePeriods
static Void discretePeriods(Str str, |Int,Int| f)
Iterate a discrete period
string formatted in base64. Call the iterator function for each period where time
is offset in minutes from base timestamp and dur
is duration of period in minutes (assuming a minutely interval). This method may also be used discreteEnumPeriods()
in which case the dur
parameter will be the enum ordinal.
emptyDict
static Dict emptyDict()
Get the emtpy Dict instance.
escapeTagName
gridFlatten
isEscapedTagName
isKindName
isTagName
Return if the given string is a legal tag name:
- first char must be ASCII lower case letter or underbar:
a
-z
or_
- rest of chars must be ASCII letter,digit, or underbar:
a
-z
,A
-Z
,0
-9
, or_
- if first char is underbar, then it must have a at least one additional alpha-num character
- or if first two chars are underbar, then must be followed by a hexdecimal characters for a UTF-8 encoded string
macro
static Str macro(Str pattern, Dict scope)
Process macro pattern with given scope of variable name/value pairs. The pattern is a Unicode string with embedded expressions:
$tag
: resolve tag name from scope, variable name ends with first non-tag character, seeEtc.isTagName
${tag}
: resolve tag name from scope$<pod::key>
: localization key
Any variables which cannot be resolved in the scope are returned as-is (such $name
) in the result string.
If a tag resolves to Ref, then we use Ref.dis for string.
macroVars
makeDict
makeDict1
makeDict2
makeDict3
makeDict4
makeDict5
makeDict6
makeDictGrid
makeDicts
makeDictsGrid
static Grid makeDictsGrid(Obj? meta, Dict?[] rows)
Construct a grid for a list of Dict rows. The meta parameter can be any makeDict
value. Any null dicts result in an empty row of all nulls. If no non-null rows, then return makeEmptyGrid
.
makeEmptyGrid
makeErrGrid
makeListGrid
makeListsGrid
makeMapGrid
static Grid makeMapGrid(Obj? meta, Str:Obj? row)
Convenience for makeDictGrid
makeMapsGrid
static Grid makeMapsGrid(Obj? meta, Str:Obj?[] rows)
Convenience for makeDictsGrid
relDis
tagToLocale
static Str tagToLocale(Str name)
Get the localized string for the given tag name for the current locale. See Localization
.
toDateSpan
static DateSpan toDateSpan(Obj? val, HaystackContext? cx := null)
Coerce an object to a DateSpan:
Func
: function which evaluates to date range (must be run in a context)DateSpan
: return itselfDate
: one day rangeSpan
: returnSpan.toDateSpan
Str
: evaluates toDateSpan.fromStr
Date..Date
: starting and ending date (inclusive)Date..Number
: starting date and num of days (day unit required)DateTime..DateTime
: use starting/ending dates; if end is midnight, then use previous dateNumber
: convert as year
toErrMeta
toGrid
static Grid toGrid(Obj? val, Dict? meta := null)
Coerce a value to a Grid:
- if grid just return it
- if row in grid of size, return row.grid
- if scalar return 1x1 grid
- if dict return grid where dict is only
- if list of dict return grid where each dict is row
- if list of non-dicts, return one col grid with rows for each item
- if non-zinc type return grid with cols val, type
toHaystack
toId
toIds
toRec
static Dict toRec(Obj? val, HaystackContext? cx := null)
Coerce a value to a record Dict:
- Row or Dict returns itself
- Grid returns first row (must have at least one row)
- List returns first item (must have at least one item which is Ref or Dict)
- Ref will make a call to read database (must be run in a context)
toRecs
static Dict[] toRecs(Obj? val, HaystackContext? cx := null)
Coerce a value to a list of record Dicts:
- null return empty list
- Ref or Ref[] will read database (must be run in a context)
- Row or Row[] returns itself
- Dict or Dict[] returns itself
- Grid is mapped to list of rows
toSpan
static Span toSpan(Obj? val, TimeZone? tz := null, HaystackContext? cx := null)
Coerce an object to a Span
with optional timezone:
Span
: return itselfSpan+tz
: update timezone using same dates only if aligned to midnightStr
: returnSpan.fromStr
using current timezoneStr+tz
: returnSpan.fromStr
using given timezoneDateTime..DateTime
: range of two DateTimesDate..DateTime
: start day for date until the end timestampDateTime..Date
: start timestamp to end of day for end dateDateTime
: span of a single timestampDateSpan
: anything accepted bytoDateSpan
in current timezoneDateSpan+tz
: anything accepted bytoDateSpan
using given timezone