blob: 9adf4babd8abf720ab409fc295e4eae075254cec [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2005, 2009 Andrea Bittau, University College London, and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0
* Jesper Steen Moeller - bug 285145 - implement full arity checking
*******************************************************************************/
package org.eclipse.wst.xml.xpath2.processor.internal.function;
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
import org.eclipse.wst.xml.xpath2.processor.internal.*;
import org.eclipse.wst.xml.xpath2.processor.internal.types.*;
import java.util.*;
/**
* Returns an xs:boolean indicating whether the argument node is "nilled". If
* the argument is not an element node, returns the empty sequence.
*/
public class FnNilled extends Function {
private static Collection _expected_args = null;
/**
* Constructor for FnNilled.
*/
public FnNilled() {
super(new QName("nilled"), 0, 1);
}
/**
* Evaluate arguments.
*
* @param args
* argument expressions.
* @throws DynamicError
* Dynamic error.
* @return Result of evaluation.
*/
@Override
public ResultSequence evaluate(Collection args) throws DynamicError {
return nilled(args);
}
/**
* Nilled operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:nilled operation.
*/
public static ResultSequence nilled(Collection args) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
if (arg1.empty()) {
return arg1;
}
NodeType nt = (NodeType) arg1.first();
return nt.nilled();
}
/**
* Obtain a list of expected arguments.
*
* @return Result of operation.
*/
public static Collection expected_args() {
if (_expected_args == null) {
_expected_args = new ArrayList();
_expected_args.add(new SeqType(SeqType.OCC_QMARK));
}
return _expected_args;
}
}