public class BaseAttributeFactory extends AttributeFactory
AttributeFactory
. It
implements the insertion and retrieval methods, but doesn't actually
setup the factory with any datatypes.
Note that while this class is thread-safe on all creation methods, it is not safe to add support for a new datatype while creating an instance of a value. This follows from the assumption that most people will initialize these factories up-front, and then start processing without ever modifying the factories. If you need these mutual operations to be thread-safe, then you should write a wrapper class that implements the right synchronization.
Constructor and Description |
---|
BaseAttributeFactory()
Default constructor.
|
BaseAttributeFactory(Map attributes)
Constructor that configures this factory with an initial set of
supported datatypes.
|
Modifier and Type | Method and Description |
---|---|
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.
|
AttributeValue |
createValue(Node root)
Creates a value based on the given DOM root node.
|
AttributeValue |
createValue(Node root,
String type)
Creates a value based on the given DOM root node and data type.
|
AttributeValue |
createValue(Node root,
URI dataType)
Creates a value based on the given DOM root node and data type.
|
AttributeValue |
createValue(URI dataType,
String value)
Creates a value based on the given data type and text-encoded value.
|
Set |
getSupportedDatatypes()
Returns the datatype identifiers supported by this factory.
|
addAttributeProxy, createAttribute, createAttribute, createAttribute, createAttribute, getInstance, getInstance, registerFactory, setDefaultFactory
public BaseAttributeFactory()
public BaseAttributeFactory(Map attributes)
attributes
- a Map
of String
s to
AttributeProxysIllegalArgumentException
- if any elements of the Map are not
AttributeProxyspublic void addDatatype(String id, AttributeProxy proxy)
AttributeValue
class.addDatatype
in class AttributeFactory
id
- the name of the attribute typeproxy
- the proxy used to create new attributes of the given typepublic Set getSupportedDatatypes()
getSupportedDatatypes
in class AttributeFactory
Set
of String
spublic AttributeValue createValue(Node root) throws UnknownIdentifierException, ParsingException
DataType
, as is the case with the
AttributeValueType in the policy schema. The value is assumed to be
the first child of this node.createValue
in class AttributeFactory
root
- the DOM root of an attribute valueAttributeValue
UnknownIdentifierException
- if the type in the node isn't
known to the factoryParsingException
- if the node is invalid or can't be parsed
by the appropriate proxypublic AttributeValue createValue(Node root, URI dataType) throws UnknownIdentifierException, ParsingException
createValue
in class AttributeFactory
root
- the DOM root of an attribute valuedataType
- the type of the attributeAttributeValue
UnknownIdentifierException
- if the data type isn't known to
the factoryParsingException
- if the node is invalid or can't be parsed
by the appropriate proxypublic AttributeValue createValue(Node root, String type) throws UnknownIdentifierException, ParsingException
createValue
in class AttributeFactory
root
- the DOM root of an attribute valuetype
- the type of the attributeAttributeValue
UnknownIdentifierException
- if the type isn't known to
the factoryParsingException
- if the node is invalid or can't be parsed
by the appropriate proxypublic AttributeValue createValue(URI dataType, String value) throws UnknownIdentifierException, ParsingException
createValue
in class AttributeFactory
dataType
- the type of the attributevalue
- the text-encoded representation of an attribute's valueAttributeValue
UnknownIdentifierException
- if the data type isn't known to
the factoryParsingException
- if the text is invalid or can't be parsed
by the appropriate proxyCopyright © 2023 JBoss by Red Hat. All rights reserved.