diff options
Diffstat (limited to 'bundles/org.eclipse.wst.xml.xpath2.processor/src/org/eclipse/wst/xml/xpath2/processor/internal/function/FnSecondsFromDuration.java')
-rw-r--r-- | bundles/org.eclipse.wst.xml.xpath2.processor/src/org/eclipse/wst/xml/xpath2/processor/internal/function/FnSecondsFromDuration.java | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/bundles/org.eclipse.wst.xml.xpath2.processor/src/org/eclipse/wst/xml/xpath2/processor/internal/function/FnSecondsFromDuration.java b/bundles/org.eclipse.wst.xml.xpath2.processor/src/org/eclipse/wst/xml/xpath2/processor/internal/function/FnSecondsFromDuration.java deleted file mode 100644 index 7727678..0000000 --- a/bundles/org.eclipse.wst.xml.xpath2.processor/src/org/eclipse/wst/xml/xpath2/processor/internal/function/FnSecondsFromDuration.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * 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 - * Mukul Gandhi - bug 273760 - wrong namespace for functions and data types - * David Carver - bug 277774 - XSDecimal returning wrong values. - * David Carver - bug 282223 - implementation of xs:duration - * David Carver (STAR) - bug 262765 - fixed xs:duration expected argument. - *******************************************************************************/ - -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.math.BigDecimal; -import java.util.*; - -/** - * Returns an xs:decimal representing the seconds component in the canonical - * lexical representation of the value of $arg. The result may be negative. If - * $arg is the empty sequence, returns the empty sequence. - */ -public class FnSecondsFromDuration extends Function { - private static Collection _expected_args = null; - - /** - * Constructor for FnSecondsFromDuration. - */ - public FnSecondsFromDuration() { - super(new QName("seconds-from-duration"), 1); - } - - /** - * Evaluate arguments. - * - * @param args - * argument expressions. - * @throws DynamicError - * Dynamic error. - * @return Result of evaluation. - */ - @Override - public ResultSequence evaluate(Collection args) throws DynamicError { - return seconds_from_duration(args); - } - - /** - * Seconds-from-Duration operation. - * - * @param args - * Result from the expressions evaluation. - * @throws DynamicError - * Dynamic error. - * @return Result of fn:seconds-from-duration operation. - */ - public static ResultSequence seconds_from_duration(Collection args) - throws DynamicError { - Collection cargs = Function.convert_arguments(args, expected_args()); - - ResultSequence arg1 = (ResultSequence) cargs.iterator().next(); - - ResultSequence rs = ResultSequenceFactory.create_new(); - - if (arg1.empty()) { - return rs; - } - - XSDuration dtd = (XSDuration) arg1.first(); - - double res = dtd.seconds(); - - if (dtd.negative()) - res *= -1; - - rs.add(new XSDecimal(BigDecimal.valueOf(res))); - - return rs; - } - - /** - * Obtain a list of expected arguments. - * - * @return Result of operation. - */ - public synchronized static Collection expected_args() { - if (_expected_args == null) { - _expected_args = new ArrayList(); - _expected_args.add(new SeqType(new XSDuration(), - SeqType.OCC_QMARK)); - } - - return _expected_args; - } -} |