xdoclet.modules.util

Class CollectionTagsHandler

public class CollectionTagsHandler extends XDocletTagSupport

This taghandler puts together some utility tags useful during template processing. For now, contains only a mechanism to manage collections of strings

Version: $Revision: 1.2 $

Author: Marcus Brito (pazu@animegaiden.com.br)

UNKNOWN: 25 Jun 2002 namespace = "Collection"

Method Summary
voidcreate(Properties attributes)
Creates a new utility collection that will store template data.
voiddestroy(Properties attributes)
Destroys the specified collection.
Stringget(Properties attributes)
Obtains one value contained in the collection.
voidifContains(String template, Properties attributes)
Generates the contained template code if the specified collection contains the key or value passed as attributes.
voidifDoesntContain(String template, Properties attributes)
Generates the contained template code if the specified collection doesn't contain the key or value passed as attributes.
voidput(Properties attributes)
Puts a new element into the specified collection.
voidremove(Properties attributes)
Removes an element from the specified collection.

Method Detail

create

public void create(Properties attributes)
Creates a new utility collection that will store template data. If a collection with the specified name already exists, an XDocletException will be thrown.

Parameters: attributes The attributes of the template tag

Throws: XDocletException if something goes wrong

UNKNOWN: type = "content" name = "name" optional = "false" description = "The name for the newly created collection" name = "type" optional = "true" values = "map,set" description = "The type of the collection to * create. Default value is set"

destroy

public void destroy(Properties attributes)
Destroys the specified collection. The collection must exists or an exception will be thrown.

Parameters: attributes The attributes of the tag template

Throws: XDocletException if something goes wrong

UNKNOWN: type = "content" name = "name" description = "The collection to destroy."

get

public String get(Properties attributes)
Obtains one value contained in the collection. This tag only apply to map valued collections, and an xdoclet exception will be throw if the specified collection is not a map.

Parameters: attributes The attributes of the template tag

Returns: The requested value or null if no such value exists.

Throws: XDocletException if something goes wrong

UNKNOWN: type = "content" name = "key" optional = "false" description = "The collection to operate on." name = "name" optional = "false" description = "The key to retrive."

ifContains

public void ifContains(String template, Properties attributes)
Generates the contained template code if the specified collection contains the key or value passed as attributes. If the collection is a set, only the 'value' attribute should be specified. If the collection is a map, the 'key' attribute should be specifed and if the 'value' attribute is also specified, an additional check for equality will be made.

Parameters: template The block tag contents attributes The attributes of the tag template

Throws: XDocletException

UNKNOWN: type = "block" name = "name" optional = "false" description = "The collection to operate on." name = "key" optional = "true" description = "The key to check, if the collection is a * map." name = "value" optional = "true" description = "The valu to check, if the collection is a * set. If the collection is a map, the value to check for equality."

ifDoesntContain

public void ifDoesntContain(String template, Properties attributes)
Generates the contained template code if the specified collection doesn't contain the key or value passed as attributes. If the collection is a set, only the 'value' attribute should be specified. If the collection is a map, the 'key' attribute should be specifed and if the 'value' attribute is also specified, an additional check for equality will be made.

Parameters: template The block tag contents attributes The attributes of the tag template

Throws: XDocletException

UNKNOWN: type = "block" name = "name" optional = "false" description = "The collection to operate on." name = "key" optional = "true" description = "The key to check, if the collection is a * map." name = "value" optional = "true" description = "The valu to check, if the collection is a * set. If the collection is a map, the value to check for equality."

put

public void put(Properties attributes)
Puts a new element into the specified collection. If the collection is a set, only the 'name' and 'value' attributes should be specified. If the collection is a map, the 'key' value should also be specified. If the 'key' is specified and the collection is a set, or if 'key' is not specified and the collection is a map, an XDocletException will be thrown.

Parameters: attributes The attributes of the template tag

Throws: XDocletException if something goes wrong

UNKNOWN: type = "content" name = "name" optional = "false" description = "The name of the collection to operate on. If * the collection does not exists, an execption will be thrown." name = "key" optional = "true" description = "The key to the new value. Should only be * specified if the collection is a map." name = "value" optional = "false" description = "The value to put into the collection."

remove

public void remove(Properties attributes)
Removes an element from the specified collection. One of 'key' or 'value' attributes should be specified, depending if the collection is a map or a set.

Parameters: attributes The attributes of the template tag

Throws: XDocletException if something goes wrong

UNKNOWN: type = "content" name = "name" optional = "false" description = "The name of the collection to operate on. If * the collection does not exists, an execption will be thrown." name = "key" optional = "true" description = "The key to remove from the map. Invalid if the * collection is a set." name = "value" optional = "true" description = "The value to remove from the set. Invalid if * the collection is a map."