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

Summary

Actions Summary Table

ActionsDescription
Add(Libraries.Web.Page.Attribute attribute)This action adds an Attribute to the object.
Compare(Libraries.Language.Object object)This action compares two object hash codes and returns a CompareResult.
Equals(Libraries.Language.Object object)This action determines if two objects are equal based on their hash code values.
Generate()
GetAttribute(text name)This action returns an attribute.
GetHashCode()This action gets the hash code for an object.
GetIterator()This action returns an iterator of all attributes stored in this object.
GetSize()This action returns the number of attributes that are currently stored in this object.
HasAttribute(text name)This action returns whether or not an attribute exists for the key passed in as a parameter.
Remove(text name)This action removes an attribute with a particular key.

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.

Example Code

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)

Parameters

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns a CompareResult. The compare result is either larger if this hash code is larger than the object passed as a parameter, smaller, or equal.

Example Code

use Libraries.Language.Support.CompareResult
        Object o
        Object t
        CompareResult result = o:Compare(t)

Parameters

Return

Libraries.Language.Support.CompareResult: The Compare result, Smaller, Equal, or Larger.

Equals(Libraries.Language.Object object)

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

Example Code

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

Parameters

Return

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

Generate()

Return

text

GetAttribute(text name)

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

Example Code

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")

Parameters

Return

Libraries.Web.Page.Attribute:

GetHashCode()

This action gets the hash code for an object.

Example Code

Object o
        integer hash = o:GetHashCode()

Return

integer: The integer hash code of the object.

GetIterator()

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

Example Code

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

Return

Libraries.Containers.Iterator:

GetSize()

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

Example Code

use Libraries.Web.Page.Attributes

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

Return

integer:

HasAttribute(text name)

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

Example Code

use Libraries.Web.Page.Attributes

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

Parameters

Return

boolean:

Remove(text name)

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

Example Code

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")

Parameters

Return

Libraries.Web.Page.Attribute: