use of org.eclipse.wst.xml.xpath2.api.ResultBuffer in project webtools.sourceediting by eclipse.
the class OpIntersect method op_intersect.
/**
* Op-Intersect operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of operation.
*/
public static ResultSequence op_intersect(Collection args) throws DynamicError {
ResultBuffer rs = new ResultBuffer();
// convert arguments
Collection cargs = Function.convert_arguments(args, expected_args());
// get arguments
Iterator iter = cargs.iterator();
ResultSequence one = (ResultSequence) iter.next();
ResultSequence two = (ResultSequence) iter.next();
// XXX lame
for (Iterator i = one.iterator(); i.hasNext(); ) {
NodeType node = (NodeType) i.next();
boolean found = false;
// death
for (Iterator j = two.iterator(); j.hasNext(); ) {
NodeType node2 = (NodeType) j.next();
if (node.node_value() == node2.node_value()) {
found = true;
break;
}
}
if (found)
rs.add(node);
}
rs = NodeType.linarize(rs);
return rs.getSequence();
}
use of org.eclipse.wst.xml.xpath2.api.ResultBuffer in project webtools.sourceediting by eclipse.
the class FsConvertOperand method convert_operand.
/**
* Convert-Operand operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fs: operation.
*/
public static ResultSequence convert_operand(Collection args) throws DynamicError {
assert args.size() == 2;
Iterator iter = args.iterator();
ResultSequence actual = (ResultSequence) iter.next();
ResultSequence expected = (ResultSequence) iter.next();
if (expected.size() != 1)
DynamicError.throw_type_error();
Item at = expected.first();
if (!(at instanceof AnyAtomicType))
DynamicError.throw_type_error();
AnyAtomicType exp_aat = (AnyAtomicType) at;
ResultBuffer result = new ResultBuffer();
// 1
if (actual.empty())
return result.getSequence();
// convert sequence
for (Iterator i = actual.iterator(); i.hasNext(); ) {
AnyType item = (AnyType) i.next();
// 2
if (item instanceof XSUntypedAtomic) {
// a
if (exp_aat instanceof XSUntypedAtomic)
result.add(new XSString(item.getStringValue()));
else // b
if (exp_aat instanceof NumericType)
result.add(new XSDouble(item.getStringValue()));
else // c
{
assert exp_aat instanceof CtrType;
CtrType cons = (CtrType) exp_aat;
result.concat(cons.constructor(new XSString(item.getStringValue())));
}
} else
// 4
result.add(item);
}
return result.getSequence();
}
Aggregations