SunTM's XACML Implementation for JavaTM

com.sun.xacml.attr
Class AttributeFactory

java.lang.Object
  extended bycom.sun.xacml.attr.AttributeFactory
Direct Known Subclasses:
BaseAttributeFactory

public abstract class AttributeFactory
extends Object

This is an abstract factory class for creating XACML attribute values. There may be any number of factories available in the system, though there is always one default factory used by the core code.

Since:
1.0

Constructor Summary
protected AttributeFactory()
          Default constructor.
 
Method Summary
static void addAttributeProxy(String id, AttributeProxy proxy)
          Deprecated. As of version 1.2, replaced by addDatatype(String,AttributeProxy). The new factory system requires you to get a factory instance and then call the non-static methods on that factory. The static versions of these methods have been left in for now, but are slower and will be removed in a future version.
abstract  void addDatatype(String id, AttributeProxy proxy)
          Adds a proxy to the factory, which in turn will allow new attribute types to be created using the factory.
static AttributeValue createAttribute(Node root)
          Deprecated. As of version 1.2, replaced by createValue(Node). The new factory system requires you to get a factory instance and then call the non-static methods on that factory. The static versions of these methods have been left in for now, but are slower and will be removed in a future version.
static AttributeValue createAttribute(Node root, String type)
          Deprecated. As of version 1.2, replaced by createValue(Node,String). The new factory system requires you to get a factory instance and then call the non-static methods on that factory. The static versions of these methods have been left in for now, but are slower and will be removed in a future version.
static AttributeValue createAttribute(Node root, URI dataType)
          Deprecated. As of version 1.2, replaced by createValue(Node,URI). The new factory system requires you to get a factory instance and then call the non-static methods on that factory. The static versions of these methods have been left in for now, but are slower and will be removed in a future version.
static AttributeValue createAttribute(URI dataType, String value)
          Deprecated. As of version 1.2, replaced by createValue(URI,String). The new factory system requires you to get a factory instance and then call the non-static methods on that factory. The static versions of these methods have been left in for now, but are slower and will be removed in a future version.
abstract  AttributeValue createValue(Node root)
          Creates a value based on the given DOM root node.
abstract  AttributeValue createValue(Node root, String type)
          Creates a value based on the given DOM root node and data type.
abstract  AttributeValue createValue(Node root, URI dataType)
          Creates a value based on the given DOM root node and data type.
abstract  AttributeValue createValue(URI dataType, String value)
          Creates a value based on the given data type and text-encoded value.
static AttributeFactory getInstance()
          Returns the default factory.
abstract  Set getSupportedDatatypes()
          Returns the datatype identifiers supported by this factory.
static void setDefaultFactory(AttributeFactoryProxy proxy)
          Sets the default factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttributeFactory

protected AttributeFactory()
Default constructor. Used only by subclasses.

Method Detail

getInstance

public static final AttributeFactory getInstance()
Returns the default factory. Depending on the default factory's implementation, this may return a singleton instance or new instances with each invokation.

Returns:
the default AttributeFactory

setDefaultFactory

public static final void setDefaultFactory(AttributeFactoryProxy proxy)
Sets the default factory. Note that this is just a placeholder for now, and will be replaced with a more useful mechanism soon.


addDatatype

public abstract void addDatatype(String id,
                                 AttributeProxy proxy)
Adds a proxy to the factory, which in turn will allow new attribute types to be created using the factory. Typically the proxy is provided as an anonymous class that simply calls the getInstance methods (or something similar) of some AttributeValue class.

Parameters:
id - the name of the attribute type
proxy - the proxy used to create new attributes of the given type
Throws:
IllegalArgumentException - if the given id is already in use

addAttributeProxy

public static void addAttributeProxy(String id,
                                     AttributeProxy proxy)
Deprecated. As of version 1.2, replaced by addDatatype(String,AttributeProxy). The new factory system requires you to get a factory instance and then call the non-static methods on that factory. The static versions of these methods have been left in for now, but are slower and will be removed in a future version.

Adds a proxy to the default factory, which in turn will allow new attribute types to be created using the factory. Typically the proxy is provided as an anonymous class that simply calls the getInstance methods (or something similar) of some AttributeValue class.

Parameters:
id - the name of the attribute type
proxy - the proxy used to create new attributes of the given type
Throws:
IllegalArgumentException - if the given id is already in use

getSupportedDatatypes

public abstract Set getSupportedDatatypes()
Returns the datatype identifiers supported by this factory.

Returns:
a Set of Strings

createValue

public abstract AttributeValue createValue(Node root)
                                    throws UnknownIdentifierException,
                                           ParsingException
Creates a value based on the given DOM root node. The type of the attribute is assumed to be present in the node as an XAML attribute named DataType, as is the case with the AttributeValueType in the policy schema. The value is assumed to be the first child of this node.

Parameters:
root - the DOM root of an attribute value
Returns:
a new AttributeValue
Throws:
UnknownIdentifierException - if the type in the node isn't known to the factory
ParsingException - if the node is invalid or can't be parsed by the appropriate proxy

createAttribute

public static AttributeValue createAttribute(Node root)
                                      throws UnknownIdentifierException,
                                             ParsingException
Deprecated. As of version 1.2, replaced by createValue(Node). The new factory system requires you to get a factory instance and then call the non-static methods on that factory. The static versions of these methods have been left in for now, but are slower and will be removed in a future version.

Creates a value based on the given DOM root node. The type of the attribute is assumed to be present in the node as an XAML attribute named DataType, as is the case with the AttributeValueType in the policy schema. The value is assumed to be the first child of this node. This uses the default factory.

Parameters:
root - the DOM root of an attribute value
Returns:
a new AttributeValue
Throws:
UnknownIdentifierException - if the type in the node isn't known to the factory
ParsingException - if the node is invalid or can't be parsed by the appropriate proxy

createValue

public abstract AttributeValue createValue(Node root,
                                           URI dataType)
                                    throws UnknownIdentifierException,
                                           ParsingException
Creates a value based on the given DOM root node and data type.

Parameters:
root - the DOM root of an attribute value
dataType - the type of the attribute
Returns:
a new AttributeValue
Throws:
UnknownIdentifierException - if the data type isn't known to the factory
ParsingException - if the node is invalid or can't be parsed by the appropriate proxy

createAttribute

public static AttributeValue createAttribute(Node root,
                                             URI dataType)
                                      throws UnknownIdentifierException,
                                             ParsingException
Deprecated. As of version 1.2, replaced by createValue(Node,URI). The new factory system requires you to get a factory instance and then call the non-static methods on that factory. The static versions of these methods have been left in for now, but are slower and will be removed in a future version.

Creates a value based on the given DOM root node and data type. This uses the default factory.

Parameters:
root - the DOM root of an attribute value
dataType - the type of the attribute
Returns:
a new AttributeValue
Throws:
UnknownIdentifierException - if the data type isn't known to the factory
ParsingException - if the node is invalid or can't be parsed by the appropriate proxy

createValue

public abstract AttributeValue createValue(Node root,
                                           String type)
                                    throws UnknownIdentifierException,
                                           ParsingException
Creates a value based on the given DOM root node and data type.

Parameters:
root - the DOM root of an attribute value
type - the type of the attribute
Returns:
a new AttributeValue
Throws:
UnknownIdentifierException - if the type isn't known to the factory
ParsingException - if the node is invalid or can't be parsed by the appropriate proxy

createAttribute

public static AttributeValue createAttribute(Node root,
                                             String type)
                                      throws UnknownIdentifierException,
                                             ParsingException
Deprecated. As of version 1.2, replaced by createValue(Node,String). The new factory system requires you to get a factory instance and then call the non-static methods on that factory. The static versions of these methods have been left in for now, but are slower and will be removed in a future version.

Creates a value based on the given DOM root node and data type. This uses the default factory.

Parameters:
root - the DOM root of an attribute value
type - the type of the attribute
Returns:
a new AttributeValue
Throws:
UnknownIdentifierException - if the type isn't known to the factory
ParsingException - if the node is invalid or can't be parsed by the appropriate proxy

createValue

public abstract AttributeValue createValue(URI dataType,
                                           String value)
                                    throws UnknownIdentifierException,
                                           ParsingException
Creates a value based on the given data type and text-encoded value. Used primarily by code that does an XPath query to get an attribute value, and then needs to turn the resulting value into an Attribute class.

Parameters:
dataType - the type of the attribute
value - the text-encoded representation of an attribute's value
Returns:
a new AttributeValue
Throws:
UnknownIdentifierException - if the data type isn't known to the factory
ParsingException - if the text is invalid or can't be parsed by the appropriate proxy

createAttribute

public static AttributeValue createAttribute(URI dataType,
                                             String value)
                                      throws UnknownIdentifierException,
                                             ParsingException
Deprecated. As of version 1.2, replaced by createValue(URI,String). The new factory system requires you to get a factory instance and then call the non-static methods on that factory. The static versions of these methods have been left in for now, but are slower and will be removed in a future version.

Creates a value based on the given data type and text-encoded value. Used primarily by code that does an XPath query to get an attribute value, and then needs to turn the resulting value into an Attribute class. This uses the default factory.

Parameters:
dataType - the type of the attribute
value - the text-encoded representation of an attribute's value
Returns:
a new AttributeValue
Throws:
UnknownIdentifierException - if the data type isn't known to the factory
ParsingException - if the text is invalid or can't be parsed by the appropriate proxy

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.