- Home
- About
- Testimonials
- Demos
- Download
- Documentation
- Blogs
- Forum
- Support

Packages:
default
System
System.Caching
System.Collections
System.Data
System.Data.ActiveRecord
System.Data.ActiveRecord.Relations
System.Data.ActiveRecord.Scaffold
System.Data.ActiveReecord.Scaffold.InputBuilder
System.Data.Commom.Sqlite
System.Data.Common
System.Data.Common.Mssql
System.Data.Common.Mysql
System.Data.Common.Oracle
System.Data.Common.Pgsql
System.Data.Common.Sqlite
System.Data.DataGateway
System.Data.SqlMap
System.Data.SqlMap.Configuration
System.Data.SqlMap.Statements
System.Exceptions
System.I18N
System.IO
System.Security
System.Util
System.Web
System.Web.Services
System.Web.UI
System.Web.UI.ActiveControls
System.Web.UI.WebControls
System.Web.UI.WebControls.assets
System.Xml
Classes:
TAttributeCollection
TDummyDataSource
TDummyDataSourceIterator
TList
TListIterator
TMap
TMapIterator
TPagedDataSource
TPagedList
TPagedListFetchDataEventParameter
TPagedListIterator
TPagedListPageChangedEventParameter
TPagedMapIterator
TQueue
TQueueIterator
TStack
TStackIterator

Keyword

# Class TAttributeCollection

    TComponent
       |
       --TMap
          |
          --TAttributeCollection

TAttributeCollection class

TAttributeCollection implements a collection for storing attribute names and values.

Besides all functionalities provided by TMap, TAttributeCollection allows you to get and set attribute values like getting and setting properties. For example, the following usages are all valid for a TAttributeCollection object:

     $collection->Text='text';
     echo $collection->Text;

They are equivalent to the following:

     $collection->add('Text','text');
     echo $collection->itemAt('Text');

Note, attribute names are case-insensitive. They are converted to lower-case in the collection storage.

Since: 3.0
Author: Qiang Xue <qiang.xue@gmail.com>

Method Summary
void | add ( mixed $key, mixed $value) Adds an item into the map.
boolean | canGetProperty ( string $name) Determines whether a property can be read.
boolean | canSetProperty ( string $name) Determines whether a property can be set.
boolean | contains ( mixed $key) Returns whether the specified is in the map.
boolean | getCaseSensitive ()
boolean | hasProperty ( string $name) Determines whether a property is defined.
mixed | itemAt ( mixed $key) Returns the item with the specified key.
mixed | remove ( mixed $key) Removes an item from the map by its key.
void | setCaseSensitive ( boolean $value)
mixed | __get ( string $name) Returns a property value or an event handler list by property or event name.
void | __set ( string $name, mixed $value) Sets value of a component property.

Methods Inherited From TMap
TMap::add(), TMap::clear(), TMap::contains(), TMap::copyFrom(), TMap::count(), TMap::getCount(), TMap::getIterator(), TMap::getKeys(), TMap::getReadOnly(), TMap::itemAt(), TMap::mergeWith(), TMap::offsetExists(), TMap::offsetGet(), TMap::offsetSet(), TMap::offsetUnset(), TMap::remove(), TMap::setReadOnly(), TMap::toArray()

Methods Inherited From TComponent

TComponent::addParsedObject(), TComponent::attachEventHandler(), TComponent::canGetProperty(), TComponent::canSetProperty(), TComponent::createdOnTemplate(), TComponent::detachEventHandler(), TComponent::evaluateExpression(), TComponent::evaluateStatements(), TComponent::getEventHandlers(), TComponent::getSubProperty(), TComponent::hasEvent(), TComponent::hasEventHandler(), TComponent::hasProperty(), TComponent::raiseEvent(), TComponent::setSubProperty(), TComponent::__get(), TComponent::__set()

Method Details

## add

public void add | (mixed $key , mixed $value )

Adds an item into the map.

This overrides the parent implementation by converting the key to lower case first if CaseSensitive is false.

Input
mixed | $key | key
mixed | $value | value
Output
Exception

## canGetProperty

public boolean canGetProperty | (string $name )

Determines whether a property can be read.

This method overrides parent implementation by returning true if the collection contains the named key.

Input
string | $name | the property name
Output
boolean | whether the property can be read
Exception

## canSetProperty

public boolean canSetProperty | (string $name )

Determines whether a property can be set.

This method overrides parent implementation by always returning true because you can always add a new value to the collection.

Input
string | $name | the property name
Output
boolean | true
Exception

## contains

public boolean contains | (mixed $key )

Returns whether the specified is in the map.

This overrides the parent implementation by converting the key to lower case first if CaseSensitive is false.

Input
mixed | $key | the key
Output
boolean | whether the map contains an item with the specified key
Exception

## getCaseSensitive

public boolean getCaseSensitive | ()

Output
boolean | whether the keys are case-sensitive. Defaults to false.
Exception

## hasProperty

public boolean hasProperty | (string $name )

Determines whether a property is defined.

This method overrides parent implementation by returning true if the collection contains the named key.

Input
string | $name | the property name
Output
boolean | whether the property is defined
Exception

## itemAt

public mixed itemAt | (mixed $key )

Returns the item with the specified key.

This overrides the parent implementation by converting the key to lower case first if CaseSensitive is false.

Input
mixed | $key | the key
Output
mixed | the element at the offset, null if no element is found at the offset
Exception

## remove

public mixed remove | (mixed $key )

Removes an item from the map by its key.

This overrides the parent implementation by converting the key to lower case first if CaseSensitive is false.

Input
mixed | $key | the key of the item to be removed
Output
mixed | the removed value, null if no such key exists.
Exception

## setCaseSensitive

public void setCaseSensitive | (boolean $value )

Input
boolean | $value | whether the keys are case-sensitive.
Output
Exception

## __get

public mixed __get | (string $name )

Returns a property value or an event handler list by property or event name.

This method overrides the parent implementation by returning a key value if the key exists in the collection.

Input
string | $name | the property name or the event name
Output
mixed | the property value or the event handler list
Exception
throws | TInvalidOperationException if the property/event is not defined.

## __set

public void __set | (string $name , mixed $value )

Sets value of a component property.

This method overrides the parent implementation by adding a new key value to the collection.

Input
string | $name | the property name or event name
mixed | $value | the property value or event handler
Output
Exception
throws | TInvalidOperationException If the property is not defined or read-only.