Libraries.Web.Page.Attributes Documentation

The Attributes class stores a number of attribute objects. Effectively, this class is just a wrapper for the HashTable class, adding an action related to automatically printing out the attributes.

Example Code



use Libraries.Web.Page.Attributes
Attribute attributes
Attribute attribute
attribute:SetName("src")
attribute:SetValue("http://www.google.com")
attributes:Add(attribute)

Inherits from: Libraries.Web.Page.WebGenerator, Libraries.Language.Object

Actions Documentation

Add(Libraries.Web.Page.Attribute attribute)

This action adds an Attribute to the object. If an attribute already exists for a given key, that attribute is replaced with the current one.

Parameters

Example


use Libraries.Web.Page.Attributes
use Libraries.Web.Page.Attribute

Attributes attributes
Attribute attribute
attribute:SetName("src")
attribute:SetValue("http://www.google.com")
attributes:Add(attribute)

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

Generate()

Return

text

GetAttribute(text name)

This action returns an attribute. If no attribute exists for a given key, this action returns undefined.

Parameters

  • text name: The name value in this case is described in more detail in the documentation for this class's Add actions.

Return

Libraries.Web.Page.Attribute:

Example


use Libraries.Web.Page.Attributes
use Libraries.Web.Page.Attribute

Attributes attributes
//as we have not set any attribute, this would
//return undefined
Attribute attribute = attributes:GetAttribute("src")

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

GetIterator()

This action returns an iterator of all attributes stored in this object.

Return

Libraries.Containers.Iterator:

Example


use Libraries.Web.Page.Attributes
use Libraries.Web.Page.Attribute
use Libraries.Containers.Iterator

Attributes attributes
Attribute attribute
attribute:SetName("src")
attribute:SetValue("http://www.google.com")
attributes:Add(attribute)

//output out all of the attributes
Iterator<Attribute> it =  attributes:GetIterator()
repeat while it:HasNext()
    Attribute at = it:Next()
    output at:Generate()
end

GetSize()

This action returns the number of attributes that are currently stored in this object.

Return

integer:

Example


use Libraries.Web.Page.Attributes

Attributes attributes
//this would return zero
integer num = attributes:GetSize()

HasAttribute(text name)

This action returns whether or not an attribute exists for the key passed in as a parameter.

Parameters

  • text name: The key value in this case is described in more detail in the documentation for this class's Add actions.

Return

boolean:

Example


use Libraries.Web.Page.Attributes

Attributes attributes
//this would return false
boolean exists = attributes:HasAttribute("src")

Remove(text name)

This action removes an attribute with a particular key. If that attribute does not exist, then this action returns undefined.

Parameters

  • text name: The name of the attribute that should be removed.

Return

Libraries.Web.Page.Attribute:

Example


use Libraries.Web.Page.Attributes
use Libraries.Web.Page.Attribute

Attributes attributes
Attribute attribute
attribute:SetName("src")
attribute:SetValue("http://www.google.com")
attributes:Add(attribute)
Attribute value = attributes:Remove("src")