com.unitesk.atp.dynattrs
Interface Attributed

All Known Implementing Classes:
BeanMapAttributed, BeanWrapper, IndexedAttributedImpl, MapAttributed, TreeClass.NodeClass

public interface Attributed

Attributed object is a Java object decorated by attributes. Each attribute has a name and value. A name of an attribute is a string.

There are two kinds of attributes: simple and indexed attributes. Simple attribute has a single value that may be retrieved or modified. Indexed attribute is a list of values that can be accessed by integer index. Indexed attribute can be considered as simple. In this case a value of an attribute is an entire list.

For example, this interface can be implemented:

TODO: add mapped attributes as in org.apache.commons.beanutils

Version:
$Id: Attributed.java,v 1.1 2004/10/09 06:19:04 all-x Exp $
Author:
Alexey Demakov

Method Summary
 void addAttribute(String name, Object value)
          Adds an attribute with the specified name and value.
 Object getAttribute(String name)
          Retrieves the value of a simple attribute with the specified name.
 Object getAttribute(String name, int index)
          Retrieves the value of the specified element of an indexed attribute with the specified name.
 Set getAttributeNames()
          Returns the names of all attributes.
 boolean hasAttribute(String name)
          Checks existence of an attribute with the specified name.
 boolean isAttrCreatable()
          Checks whether attributes may be created dynamically.
 boolean isIndexed(String name)
          Checks whether an attribute with the specified name may be indexed.
 boolean isRemovable(String name)
          Checks whether an attribute with the specified name may be removed dynamically.
 boolean isWritable(String name)
          Checks whether a value of an attribute with the specified name may be changed.
 void removeAttribute(String name)
          Removes an attribute with the specified name.
 void setAttribute(String name, int index, Object elem)
          Changes the value of the specified element of an indexed attribute with the specified name.
 void setAttribute(String name, Object value)
          Changes the value of a simple attribute with the specified name.
 int sizeAttribute(String name)
          Returns the size of an indexed attribute with the specified name.
 

Method Detail

hasAttribute

boolean hasAttribute(String name)
Checks existence of an attribute with the specified name.

Parameters:
name - The name of an attribute.
Returns:
true if there exists an attribute with the specified name, false otherwise.
Throws:
NullPointerException - If name is null.

isAttrCreatable

boolean isAttrCreatable()
Checks whether attributes may be created dynamically. The value of this property doesn't change during object life.

Returns:
true if attributes may be created dynamically, false otherwise.

isRemovable

boolean isRemovable(String name)
Checks whether an attribute with the specified name may be removed dynamically.

Parameters:
name - The name of an attribute.
Returns:
true if an attribute with the specified name may be removed dynamically, false otherwise.
Throws:
AttributeException - Some possible reasons:
  • name == null
  • there is no attribute with the specified name
  • there was an underlying exception
(analyze exception parameters).
See Also:
hasAttribute(String)

isWritable

boolean isWritable(String name)
Checks whether a value of an attribute with the specified name may be changed.

Parameters:
name - The name of an attribute.
Returns:
true if a value of an attribute with the specified name may be changed, false otherwise.
Throws:
AttributeException - Some possible reasons:
  • name == null
  • there is no attribute with the specified name
  • there was an underlying exception
(analyze exception parameters).
See Also:
hasAttribute(String)

isIndexed

boolean isIndexed(String name)
Checks whether an attribute with the specified name may be indexed.

Parameters:
name - The name of an attribute
Returns:
true if a value of an attribute with the specified name may be indexed, false otherwise.
Throws:
AttributeException - Some possible reasons:
  • name == null
  • there is no attribute with the specified name
  • there was an underlying exception
(analyze exception parameters).
See Also:
hasAttribute(String)

addAttribute

void addAttribute(String name,
                  Object value)
Adds an attribute with the specified name and value.

Parameters:
name - The name of new attribute.
value - The value of new attribute.
Throws:
UnsupportedOperationException - if {link #isAttrCreatable()} returns false
AttributeException - Some possible reasons:
  • name == null
  • there is attribute with the specified name already
  • there was an underlying exception
(analyze exception parameters).
See Also:
hasAttribute(String)

removeAttribute

void removeAttribute(String name)
Removes an attribute with the specified name. If there is no attribute with the specified name nothing happens.

Parameters:
name - The name of an attribute.
Throws:
UnsupportedOperationException - if operation is not supported
AttributeException - Some possible reasons:
  • name == null
  • the specified attribute is not removable
  • there was an underlying exception
(analyze exception parameters).
See Also:
hasAttribute(String), isRemovable(String)

getAttribute

Object getAttribute(String name)
Retrieves the value of a simple attribute with the specified name.

Parameters:
name - The name of an attribute.
Returns:
The value of an attribute.
Throws:
AttributeException - Some possible reasons:
  • name == null
  • there is no attribute with the specified name
  • there was an underlying exception
(analyze exception parameters).
See Also:
hasAttribute(String)

setAttribute

void setAttribute(String name,
                  Object value)
Changes the value of a simple attribute with the specified name.

Parameters:
name - The name of an attribute.
value - The new value of an attribute.
Throws:
AttributeException - Some possible reasons:
  • name == null
  • there is no attribute with the specified name
  • attribute type is not compatible with value
  • there was an underlying exception
(analyze exception parameters).
See Also:
hasAttribute(String), isWritable(String)

sizeAttribute

int sizeAttribute(String name)
Returns the size of an indexed attribute with the specified name.

Parameters:
name - The name of an indexed attribute.
Returns:
The size of an indexed attribute.
Throws:
AttributeException - Some possible reasons:
  • name == null
  • there is no attribute with the specified name
  • attribute value is not indexed
  • there was an underlying exception
(analyze exception parameters).
See Also:
hasAttribute(String), isIndexed(String)

getAttribute

Object getAttribute(String name,
                    int index)
Retrieves the value of the specified element of an indexed attribute with the specified name.

Parameters:
name - The name of an indexed attribute.
index - The index of an indexed attribute.
Returns:
The value of an attribute.
Throws:
AttributeException - Some possible reasons:
  • name == null
  • there is no attribute with the specified name
  • attribute value is not indexed
  • attribute index is out of bounds
  • there was an underlying exception
(analyze exception parameters).
See Also:
hasAttribute(String), isIndexed(String), sizeAttribute(String)

setAttribute

void setAttribute(String name,
                  int index,
                  Object elem)
Changes the value of the specified element of an indexed attribute with the specified name.

Parameters:
name - The name of an indexed attribute.
index - The index of an indexed attribute.
elem - The new value of an element with the specified index.
Throws:
AttributeException - Some possible reasons:
  • name == null
  • there is no attribute with the specified name
  • attribute is not writable
  • attribute is not indexed
  • attribute index is out of bounds
  • attribute element type is not compatible with elem
  • there was an underlying exception
(analyze exception parameters).
See Also:
hasAttribute(String), isWritable(String), isIndexed(String), sizeAttribute(String)

getAttributeNames

Set getAttributeNames()
Returns the names of all attributes.

Returns:
The set containing the names of all attributes.
See Also:
Map.keySet()


Copyright © 2001-2006 ISP RAS, RedVerst Group. All Rights Reserved.