Ref
@Js
const class Ref : Obj
Ref is used to model an entity identifier and optional display string.
Make with simple id
Construct with id string and optional display string
Construct a Ref that encodes a URI
Construct with Ref id string and optional display string
Default is nullRef
Null ref is "@null"
Return display value of target if available, otherwise id
Equality is based on id only (not dis)
Generate a unique Ref
Hash id
Identifier which does not include the leading @
Return if the string is a valid Ref identifier
Is the given character a valid id char
Null ref has id value of "null"?
Is this a spec ref with double colons
Is this a ref that encodes a URI via makeUri
Return "@id"
Take an arbitrary string and convert into a safe Ref identifier
String format is id which does not include
the leading @
If this is a URI encoded ref, decode back to the URI
const static Ref : defVal
Default is nullRef
Str dis()
Return display value of target if available, otherwise id
virtual Bool equals(Obj? that)
Equality is based on id only (not dis).
static new fromStr(Str id, Bool checked := true)
Make with simple id
static Ref gen()
Generate a unique Ref.
virtual Int hash()
Hash id
Str id()
Identifier which does not include the leading @
static Bool isId(Str n)
Return if the string is a valid Ref identifier. See isIdChar
static Bool isIdChar(Int char)
Is the given character a valid id char:
A-Za-z0-9_ : - . ~
Bool isNull()
Null ref has id value of "null"?
Bool isSpec()
Is this a spec ref with double colons
Bool isUri()
Is this a ref that encodes a URI via makeUri
static new make(Str id, Str? dis)
Construct with id string and optional display string.
static new makeUri(Uri uri, Str? dis := null)
Construct a Ref that encodes a URI. The URI is percent encoded then tilde encoded into a valid Ref id with the "uri" scheme prefix.
static new makeWithDis(Ref ref, Str? dis := null)
Construct with Ref id string and optional display string.
const static Ref : nullRef
Null ref is "@null"
Str toCode()
Return "@id"
static Str toId(Str n)
Take an arbitrary string and convert into a safe Ref identifier.
virtual Str toStr()
String format is id which does not include
the leading @. Use toCode to include leading @.
Uri? toUri(Bool checked := true)
If this is a URI encoded ref, decode back to the URI. Raise error or return null null if this ref was not created via makeUri.