📄 basefunctionfactory.java
字号:
*/
public void addAbstractFunction(FunctionProxy proxy,
URI identity)
throws IllegalArgumentException
{
String id = identity.toString();
// make sure this doesn't already exist
if (functionMap.containsKey(id))
throw new IllegalArgumentException("function already exists");
// add to the superset factory
if (superset != null)
superset.addAbstractFunction(proxy, identity);
// finally, add to this factory
functionMap.put(id, proxy);
}
/**
* Returns the function identifiers supported by this factory.
*
* @return a <code>Set</code> of <code>String</code>s
*/
public Set getSupportedFunctions() {
Set set = new HashSet(functionMap.keySet());
if (superset != null)
set.addAll(superset.getSupportedFunctions());
return set;
}
/**
* Tries to get an instance of the specified function.
*
* @param identity the name of the function
*
* @throws UnknownIdentifierException if the name isn't known
* @throws FunctionTypeException if the name is known to map to an
* abstract function, and should therefore
* be created through createAbstractFunction
*/
public Function createFunction(URI identity)
throws UnknownIdentifierException, FunctionTypeException
{
return createFunction(identity.toString());
}
/**
* Tries to get an instance of the specified function.
*
* @param identity the name of the function
*
* @throws UnknownIdentifierException if the name isn't known
* @throws FunctionTypeException if the name is known to map to an
* abstract function, and should therefore
* be created through createAbstractFunction
*/
public Function createFunction(String identity)
throws UnknownIdentifierException, FunctionTypeException
{
Object entry = functionMap.get(identity);
if (entry != null) {
if (entry instanceof Function) {
return (Function)entry;
} else {
// this is actually a proxy, which means the other create
// method should have been called
throw new FunctionTypeException("function is abstract");
}
} else {
// we couldn't find a match
throw new UnknownIdentifierException("functions of type " +
identity + " are not "+
"supported by this factory");
}
}
/**
* Tries to get an instance of the specified abstract function.
*
* @param identity the name of the function
* @param root the DOM root containing info used to create the function
*
* @throws UnknownIdentifierException if the name isn't known
* @throws FunctionTypeException if the name is known to map to a
* concrete function, and should therefore
* be created through createFunction
* @throws ParsingException if the function can't be created with the
* given inputs
*/
public Function createAbstractFunction(URI identity, Node root)
throws UnknownIdentifierException, ParsingException,
FunctionTypeException
{
return createAbstractFunction(identity.toString(), root, null);
}
/**
* Tries to get an instance of the specified abstract function.
*
* @param identity the name of the function
* @param root the DOM root containing info used to create the function
* @param xpathVersion the version specified in the contianing policy, or
* null if no version was specified
*
* @throws UnknownIdentifierException if the name isn't known
* @throws FunctionTypeException if the name is known to map to a
* concrete function, and should therefore
* be created through createFunction
* @throws ParsingException if the function can't be created with the
* given inputs
*/
public Function createAbstractFunction(URI identity, Node root,
String xpathVersion)
throws UnknownIdentifierException, ParsingException,
FunctionTypeException
{
return createAbstractFunction(identity.toString(), root, xpathVersion);
}
/**
* Tries to get an instance of the specified abstract function.
*
* @param identity the name of the function
* @param root the DOM root containing info used to create the function
*
* @throws UnknownIdentifierException if the name isn't known
* @throws FunctionTypeException if the name is known to map to a
* concrete function, and should therefore
* be created through createFunction
* @throws ParsingException if the function can't be created with the
* given inputs
*/
public Function createAbstractFunction(String identity, Node root)
throws UnknownIdentifierException, ParsingException,
FunctionTypeException
{
return createAbstractFunction(identity, root, null);
}
/**
* Tries to get an instance of the specified abstract function.
*
* @param identity the name of the function
* @param root the DOM root containing info used to create the function
* @param xpathVersion the version specified in the contianing policy, or
* null if no version was specified
*
* @throws UnknownIdentifierException if the name isn't known
* @throws FunctionTypeException if the name is known to map to a
* concrete function, and should therefore
* be created through createFunction
* @throws ParsingException if the function can't be created with the
* given inputs
*/
public Function createAbstractFunction(String identity, Node root,
String xpathVersion)
throws UnknownIdentifierException, ParsingException,
FunctionTypeException
{
Object entry = functionMap.get(identity);
if (entry != null) {
if (entry instanceof FunctionProxy) {
try {
return ((FunctionProxy)entry).getInstance(root,
xpathVersion);
} catch (Exception e) {
throw new ParsingException("couldn't create abstract" +
" function " + identity, e);
}
} else {
// this is actually a concrete function, which means that
// the other create method should have been called
throw new FunctionTypeException("function is concrete");
}
} else {
// we couldn't find a match
throw new UnknownIdentifierException("abstract functions of " +
"type " + identity +
" are not supported by " +
"this factory");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -