Fantom

 

class

obix::ObixObj

sys::Obj
  obix::ObixObj

ObixObj models an obix:obj element.

Slots

addSource

This add(ObixObj kid)

Add a child object. Throw ArgErr if this child is already parented or has a duplicate name. Return this.

clearSource

This clear()

Remove all children objects. Return this.

contractSource

Contract contract := Contract.empty

The list of contract URIs this object implemented as specified by is attribute.

displaySource

Str? display

Localized human readable string summary of the object.

displayNameSource

Str? displayName

Localized human readable version of the name attribute.

eachSource

Void each(|ObixObj| f)

Iterate each of the children objects.

elemNameSource

Str elemName := "obj"

The XML element name to use for this object. If not one of the valid oBIX element names then throw ArgErr. Valid element names are:

obj, bool, int, real, str, enum, uri, abstime,
reltime, date, time, list, op, feed, ref, err
firstSource

ObixObj? first()

Get the first child returned by list or null.

getSource

ObixObj? get(Str name, Bool checked := true)

Get a child by name. If not found and checked is true then throw NameErr, otherwise null.

hasSource

Bool has(Str name)

Return if there is child object by the specified name.

hrefSource

Uri? href

URI of this object. The root object of a document must have an absolute URI, other objects may have a URI relative to the document root. See normalizedHref to get this href normalized against the root object.

iconSource

Uri? icon

Reference to the graphical icon.

inSource

Contract? in

The in contract for operations and feeds.

isEmptySource

Bool isEmpty()

Return is size is zero.

isNullSource

Bool isNull

The null flag indicates the absense of a value.

lastSource

ObixObj? last()

Get the last child returned by list or null.

listSource

ObixObj[] list()

Get a readonly list of the children objects or empty list if no children. If iterating the children it is more efficient to use each.

maxSource

Obj? max

Inclusive maximum for value.

minSource

Obj? min

Inclusive minium for value.

nameSource

Str? name

Programatic name of the object which defines role of this object in its parent. Throw UnsupportedErr if an attempt is made to set the name once mounted under a parent.

normalizedHrefSource

Uri? normalizedHref()

Get this objects href normalized against the root object's URI. Return null no href defined.

ofSource

Contract? of

The of contract for lists and feeds.

outSource

Contract? out

The out contract for operations.

parentSource

readonly ObixObj? parent

Parent object or null if unparented.

precisionSource

Int? precision

Number of decimal places to use for a real value.

rangeSource

Uri? range

Reference to the range definition of an enum or bool value.

readXmlSource

static ObixObj readXml(InStream in, Bool close := true)

Parse an XML document into memory as a tree of ObixObj. If close is true, then the input stream is guaranteed to be closed.

removeSource

This remove(ObixObj kid)

Remove the specified child object by reference. Throw ArgErr if not my child. Return this

rootSource

ObixObj root()

Get the root ancestor of this object, or return this if no parent.

sizeSource

Int size()

Return number of child objects.

statusSource

Status status := Status.ok

Status facet indicates quality and state.

toStrSource

override Str toStr()

Overrides sys::Obj.toStr

Return string representation.

trapSource

override Obj? trap(Str name, Obj?[]? args)

Overrides sys::Obj.trap

If the name maps to a child object, then return that child's value. Otherwise route to Obj.trap.

tzSource

TimeZone? tz

TimeZone facet assocaited with abstime, date, and time objects. This field is automatically updated when val is assigned a DateTime unless its timezone is UTC or starts with "Etc/". After decoding this field is set only if an explicit "tz" attribute was specified.

unitSource

Unit? unit

Unit of measurement for int and real values. We only support units which are predefind in the oBIX unit database and specified using the URI "obix:units/". These units are mapped to the sys::Unit API. If an unknown unit URI is decoded, then it is silently ignored and this field will be null.

valSource

Obj? val

Object value for value object types:

  • obix:bool => sys::Bool
  • obix:int => sys::Int
  • obix:real => sys::Float
  • obix:str => sys::Str
  • obix:enum => sys::Str
  • obix:uri => sys::Uri
  • obix:abstime => sys::DateTime
  • obix:reltime => sys::Duration
  • obix:date => sys::Date
  • obix:time => sys::Time

If the value is not one of the types listed above, then ArgErr is thrown. If the value is set to non-null, then the elemName is automatically updated.

valToStrSource

Str valToStr()

Get the value encoded as a string. The string is not XML escaped. If value is null return "null".

writableSource

Bool writable

Specifies is this object can be written, or false if readonly.

writeXmlSource

virtual Void writeXml(OutStream out, Int indent := 0)

Write this ObixObj as an XML document to the specified stream. No XML prolog is specified so that this method can used to write a snippet of the overall document.