public class BaseFunctionFactory extends FunctionFactory
FunctionFactory
. It
implements the insertion and retrieval methods, but it doesn't actually
setup the factory with any functions. It also assumes a certain model
with regard to the different kinds of functions (Target, Condition, and
General). For this reason, you may want to re-use this class, or you
may want to extend FunctionFactory directly, if you're writing a new
factory implementation.
Note that while this class is thread-safe on all creation methods, it is not safe to add support for a new function while creating an instance of a function. 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 |
---|
BaseFunctionFactory()
Default constructor.
|
BaseFunctionFactory(FunctionFactory superset)
Constructor that sets a "superset factory".
|
BaseFunctionFactory(FunctionFactory superset,
Set supportedFunctions,
Map supportedAbstractFunctions)
Constructor that defines the initial functions supported by this
factory and uses a superset factory.
|
BaseFunctionFactory(Set supportedFunctions,
Map supportedAbstractFunctions)
Constructor that defines the initial functions supported by this
factory but doesn't use a superset factory.
|
Modifier and Type | Method and Description |
---|---|
void |
addAbstractFunction(FunctionProxy proxy,
URI identity)
Adds the abstract function proxy to the factory.
|
void |
addFunction(Function function)
Adds the function to the factory.
|
Function |
createAbstractFunction(String identity,
Node root)
Tries to get an instance of the specified abstract function.
|
Function |
createAbstractFunction(String identity,
Node root,
String xpathVersion)
Tries to get an instance of the specified abstract function.
|
Function |
createAbstractFunction(URI identity,
Node root)
Tries to get an instance of the specified abstract function.
|
Function |
createAbstractFunction(URI identity,
Node root,
String xpathVersion)
Tries to get an instance of the specified abstract function.
|
Function |
createFunction(String identity)
Tries to get an instance of the specified function.
|
Function |
createFunction(URI identity)
Tries to get an instance of the specified function.
|
Set |
getSupportedFunctions()
Returns the function identifiers supported by this factory.
|
addAbstractConditionFunction, addAbstractGeneralFunction, addAbstractTargetFunction, addConditionFunction, addGeneralFunction, addTargetFunction, getConditionInstance, getConditionInstance, getGeneralInstance, getGeneralInstance, getInstance, getInstance, getTargetInstance, getTargetInstance, registerFactory, setDefaultFactory
public BaseFunctionFactory()
public BaseFunctionFactory(FunctionFactory superset)
superset
- the superset factory or nullpublic BaseFunctionFactory(Set supportedFunctions, Map supportedAbstractFunctions)
supportedFunctions
- a Set
of Function
ssupportedAbstractFunctions
- a mapping from URI
to
FunctionProxy
public BaseFunctionFactory(FunctionFactory superset, Set supportedFunctions, Map supportedAbstractFunctions)
BaseFunctionFactory(FunctionFactory)
and then manually add each function.superset
- the superset factory or nullsupportedFunctions
- a Set
of Function
ssupportedAbstractFunctions
- a mapping from URI
to
FunctionProxy
public void addFunction(Function function) throws IllegalArgumentException
addFunction
in class FunctionFactory
function
- the Function
to add to the factoryIllegalArgumentException
- if the function's identifier is already
used or if the function is non-boolean
(when this is a Target or Condition
factory)public void addAbstractFunction(FunctionProxy proxy, URI identity) throws IllegalArgumentException
addAbstractFunction
in class FunctionFactory
proxy
- the FunctionProxy
to add to the factoryidentity
- the function's identifierIllegalArgumentException
- if the function's identifier is already
usedpublic Set getSupportedFunctions()
getSupportedFunctions
in class FunctionFactory
Set
of String
spublic Function createFunction(URI identity) throws UnknownIdentifierException, FunctionTypeException
createFunction
in class FunctionFactory
identity
- the name of the functionUnknownIdentifierException
- if the name isn't knownFunctionTypeException
- if the name is known to map to an
abstract function, and should therefore
be created through createAbstractFunctionpublic Function createFunction(String identity) throws UnknownIdentifierException, FunctionTypeException
createFunction
in class FunctionFactory
identity
- the name of the functionUnknownIdentifierException
- if the name isn't knownFunctionTypeException
- if the name is known to map to an
abstract function, and should therefore
be created through createAbstractFunctionpublic Function createAbstractFunction(URI identity, Node root) throws UnknownIdentifierException, ParsingException, FunctionTypeException
createAbstractFunction
in class FunctionFactory
identity
- the name of the functionroot
- the DOM root containing info used to create the functionUnknownIdentifierException
- if the name isn't knownFunctionTypeException
- if the name is known to map to a
concrete function, and should therefore
be created through createFunctionParsingException
- if the function can't be created with the
given inputspublic Function createAbstractFunction(URI identity, Node root, String xpathVersion) throws UnknownIdentifierException, ParsingException, FunctionTypeException
createAbstractFunction
in class FunctionFactory
identity
- the name of the functionroot
- the DOM root containing info used to create the functionxpathVersion
- the version specified in the contianing policy, or
null if no version was specifiedUnknownIdentifierException
- if the name isn't knownFunctionTypeException
- if the name is known to map to a
concrete function, and should therefore
be created through createFunctionParsingException
- if the function can't be created with the
given inputspublic Function createAbstractFunction(String identity, Node root) throws UnknownIdentifierException, ParsingException, FunctionTypeException
createAbstractFunction
in class FunctionFactory
identity
- the name of the functionroot
- the DOM root containing info used to create the functionUnknownIdentifierException
- if the name isn't knownFunctionTypeException
- if the name is known to map to a
concrete function, and should therefore
be created through createFunctionParsingException
- if the function can't be created with the
given inputspublic Function createAbstractFunction(String identity, Node root, String xpathVersion) throws UnknownIdentifierException, ParsingException, FunctionTypeException
createAbstractFunction
in class FunctionFactory
identity
- the name of the functionroot
- the DOM root containing info used to create the functionxpathVersion
- the version specified in the contianing policy, or
null if no version was specifiedUnknownIdentifierException
- if the name isn't knownFunctionTypeException
- if the name is known to map to a
concrete function, and should therefore
be created through createFunctionParsingException
- if the function can't be created with the
given inputsCopyright © 2023 JBoss by Red Hat. All rights reserved.