/* (non-Javadoc)
* @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence)
*/
public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
Metas metas = null;
if (getSignature().getName().equals(NAME))
if (args[0] instanceof DocumentImpl) {
metas = MetaData.get().getMetas(((DocumentImpl)args[0]));
} else
throw new XPathException(this, "Unsupported type "+args[0].getItemType());
else if (getSignature().getName().equals(NAME_URL))
metas = MetaData.get().getMetas(XmldbURI.create(args[0].getStringValue()));
if (metas == null)
throw new XPathException(this, "No metadata found.");
Meta meta;
if (args[2] instanceof DocumentImpl)
meta = metas.put(args[1].getStringValue(), args[2]);
else
meta = metas.put(args[1].getStringValue(), args[2].getStringValue());
ValueSequence returnSeq = new ValueSequence();
returnSeq.add(new StringValue(meta.getUUID()));
return returnSeq;
}