public PutFunction(XQueryContext context, FunctionSignature signature) {
super(context, signature);
}
public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
Item item = args[0].itemAt(0);
Sequence value = args[2];
try {
String key = serialize(args[1]);
if (item.getType()==Type.STRING){
if( logger.isTraceEnabled() ) {
logger.trace("putting cache value [" + item.getStringValue() + ", " + key +"]");
}
return Cache.put(item.getStringValue(), key, value);
} else {
if( logger.isTraceEnabled() ) {
logger.trace("putting cache value [" + item.toJavaObject(Cache.class).toString() + ", " + key +"]");
}
return ((Cache)item.toJavaObject(Cache.class)).put(key, value);
}
} catch (SAXException e) {
logger.error("Error putting cache value", e);
}
return Sequence.EMPTY_SEQUENCE;