class

Ref

@Js
const class Ref : Obj

Ref is used to model an entity identifier and optional display string.

constructors fromStr

Make with simple id

make

Construct with id string and optional display string

makeUri

Construct a Ref that encodes a URI

makeWithDis

Construct with Ref id string and optional display string

fields defVal

Default is nullRef

nullRef

Null ref is "@null"

methods dis

Return display value of target if available, otherwise id

equals

Equality is based on id only (not dis)

gen

Generate a unique Ref

hash

Hash id

id

Identifier which does not include the leading @

isId

Return if the string is a valid Ref identifier

isIdChar

Is the given character a valid id char

isNull

Null ref has id value of "null"?

isSpec

Is this a spec ref with double colons

isUri

Is this a ref that encodes a URI via makeUri

toCode

Return "@id"

toId

Take an arbitrary string and convert into a safe Ref identifier

toStr

String format is id which does not include the leading @

toUri

If this is a URI encoded ref, decode back to the URI

defVal const static Ref : defVal

Default is nullRef

dis Str dis()

Return display value of target if available, otherwise id

equals virtual Bool equals(Obj? that)

Equality is based on id only (not dis).

fromStr static new fromStr(Str id, Bool checked := true)

Make with simple id

gen static Ref gen()

Generate a unique Ref.

hash virtual Int hash()

Hash id

id Str id()

Identifier which does not include the leading @

isId static Bool isId(Str n)

Return if the string is a valid Ref identifier. See isIdChar

isIdChar static Bool isIdChar(Int char)

Is the given character a valid id char:

  • A - Z
  • a - z
  • 0 - 9
  • _ : - . ~

isNull Bool isNull()

Null ref has id value of "null"?

isSpec Bool isSpec()

Is this a spec ref with double colons

isUri Bool isUri()

Is this a ref that encodes a URI via makeUri

make static new make(Str id, Str? dis)

Construct with id string and optional display string.

makeUri 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.

makeWithDis static new makeWithDis(Ref ref, Str? dis := null)

Construct with Ref id string and optional display string.

nullRef const static Ref : nullRef

Null ref is "@null"

toCode Str toCode()

Return "@id"

toId static Str toId(Str n)

Take an arbitrary string and convert into a safe Ref identifier.

toStr virtual Str toStr()

String format is id which does not include the leading @. Use toCode to include leading @.

toUri 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.

Haxall 4.0.6 ∙ 21-Jul-2026 09:48 EDT