Package org.exist.xquery.value

Examples of org.exist.xquery.value.ComputableValue


                throw new XPathException(this, ErrorCodes.FORG0006,
                    Type.getTypeName(value.getType()) + "(" + value + ") " +
                    "can not be an operand in a sum", value);
            }
            //Set the first value
            ComputableValue sum = (ComputableValue) value;
            while (iter.hasNext()) {
                item = iter.nextItem();
                value = item.atomize();
                //Any value of type xdt:untypedAtomic are cast to xs:double
                if (value.getType() == Type.UNTYPED_ATOMIC)
                    {value = value.convertTo(Type.DOUBLE);}
                if (!(value instanceof ComputableValue)) {
                    throw new XPathException(this, ErrorCodes.FORG0006, "" +
                        Type.getTypeName(value.getType()) + "(" + value +
                        ") can not be an operand in a sum", value);
                }
                if (Type.subTypeOf(value.getType(), Type.NUMBER)) {
                    if (((NumericValue)value).isInfinite())
                        {gotInfinity = true;}
                    if (((NumericValue)value).isNaN()) {
                        sum = DoubleValue.NaN;
                        break;
                    }
                }
                try {
                    sum = (ComputableValue) sum.promote(value);
                    //Aggregate next values 
                    sum = sum.plus((ComputableValue) value);
                } catch(final XPathException e) {
                    throw new XPathException(this, ErrorCodes.FORG0006, e.getMessage());
                }
            }
            result = sum.div(new IntegerValue(inner.getItemCount()));
        }
        if (!gotInfinity) {
            if (Type.subTypeOf(result.getItemType(), Type.NUMBER) &&
                ((NumericValue)result).isInfinite()) {
                //Throw an overflow exception here since we get an infinity
View Full Code Here


        AtomicValue value = item.atomize();

          value = check(value, null);
       
        //Set the first value
        ComputableValue sum = (ComputableValue) value;
        while (iter.hasNext()) {
          item = iter.nextItem();
          value = item.atomize();

              value = check(value, sum);
         
            if (Type.subTypeOf(value.getType(), Type.NUMBER)) {
            if (((NumericValue)value).isInfinite())
              {gotInfinity = true;}             
            if (((NumericValue)value).isNaN()) {
              sum = DoubleValue.NaN;
              break;
            }
          }
          sum = (ComputableValue)sum.promote(value);
          //Aggregate next values
          sum = sum.plus((ComputableValue) value);
        }
        result = sum;
        }
       
    if (!gotInfinity) {
View Full Code Here

TOP

Related Classes of org.exist.xquery.value.ComputableValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.