SunTM's XACML Implementation for JavaTM

com.sun.xacml.attr
Class BagAttribute

java.lang.Object
  extended bycom.sun.xacml.attr.AttributeValue
      extended bycom.sun.xacml.attr.BagAttribute
All Implemented Interfaces:
Evaluatable

public class BagAttribute
extends AttributeValue

Represents a bag used in the XACML spec as return values from functions and designators/selectors that provide more than one value. All values in the bag are of the same type, and the bag may be empty. The bag is immutable, although its contents may not be.

NOTE: This is the one standard attribute type that can't be created from the factory, since you can't have this in an XML block (it is used only in return values & dynamic inputs). I think this is right, but we may need to add some functionality to let this go into the factory.

Since:
1.0

Constructor Summary
BagAttribute(URI type, Collection bag)
          Creates a new BagAttribute that represents the Collection of AttributeValues supplied.
 
Method Summary
 boolean contains(AttributeValue value)
          Returns true if this set contains the specified value.
 boolean containsAll(BagAttribute bag)
          Returns true if this bag contains all of the values of the specified bag.
static BagAttribute createEmptyBag(URI type)
          Convenience function that returns a bag with no elements
 String encode()
          Because a bag cannot be included in a request/response or a policy, this will always throw an UnsupportedOperationException.
 boolean isBag()
          Overrides the default method to always return true.
 boolean isEmpty()
          A convenience function that returns whether or not the bag is empty (ie, whether or not the size of the bag is zero)
 Iterator iterator()
          Returns an iterator over te
 int size()
          Returns the number of elements in this bag
 
Methods inherited from class com.sun.xacml.attr.AttributeValue
encode, encode, encodeWithTags, evaluate, evaluatesToBag, getChildren, getType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BagAttribute

public BagAttribute(URI type,
                    Collection bag)
Creates a new BagAttribute that represents the Collection of AttributeValues supplied. If the set is null or empty, then the new bag is empty.

Parameters:
type - the data type of all the attributes in the set
bag - a Collection of AttributeValues
Method Detail

isBag

public boolean isBag()
Overrides the default method to always return true.

Overrides:
isBag in class AttributeValue
Returns:
a value of true

createEmptyBag

public static BagAttribute createEmptyBag(URI type)
Convenience function that returns a bag with no elements

Parameters:
type - the types contained in the bag
Returns:
a new empty bag

isEmpty

public boolean isEmpty()
A convenience function that returns whether or not the bag is empty (ie, whether or not the size of the bag is zero)

Returns:
whether or not the bag is empty

size

public int size()
Returns the number of elements in this bag

Returns:
the number of elements in this bag

contains

public boolean contains(AttributeValue value)
Returns true if this set contains the specified value. More formally, returns true if and only if this bag contains a value v such that (value==null ? v==null : value.equals(v)). Note that this will only work correctly if the AttributeValue has overridden the equals method.

Parameters:
value - the value to look for
Returns:
true if the value is in the bag

containsAll

public boolean containsAll(BagAttribute bag)
Returns true if this bag contains all of the values of the specified bag. Note that this will only work correctly if the AttributeValue type contained in the bag has overridden the equals method.

Parameters:
bag - the bag to compare
Returns:
true if the input is a subset of this bag

iterator

public Iterator iterator()
Returns an iterator over te


encode

public String encode()
Because a bag cannot be included in a request/response or a policy, this will always throw an UnsupportedOperationException.

Specified by:
encode in class AttributeValue
Returns:
a String form of the value

Sun's XACML Implementation Version 1.2

Copyright 2003-2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

Sun, Sun Microsystems, the Sun Logo, and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.