Package org.exist.xquery

Examples of org.exist.xquery.XPathException$FunctionStackElement


  public DecimalValue(String str) throws XPathException {
        str = StringValue.trimWhitespace(str);
    try {
      if (!decimalPattern.matcher(str).matches()) {
        throw new XPathException(ErrorCodes.FORG0001, "cannot construct " + Type.getTypeName(this.getItemType()) +
            " from \"" + str + "\"");           
      }
      value = stripTrailingZeros(new BigDecimal(str));
    } catch (final NumberFormatException e) {
      throw new XPathException(ErrorCodes.FORG0001, "cannot construct " + Type.getTypeName(this.getItemType()) +
          " from \"" + getStringValue() + "\"");         
    }
  }
View Full Code Here


      case Type.POSITIVE_INTEGER :
        return new IntegerValue(value.longValue(), requiredType);
      case Type.BOOLEAN :
        return value.signum() == 0 ? BooleanValue.FALSE : BooleanValue.TRUE;
      default :
        throw new XPathException(ErrorCodes.FORG0001,
          "cannot convert  '"
                    +  Type.getTypeName(this.getType())
                    + " ("
                    + value
                    + ")' into "
View Full Code Here

        if (!(other instanceof DecimalValue)) {
                final ComputableValue n = (ComputableValue)this.convertTo(other.getType());
                return ((ComputableValue)n).div(other);
        }
        if (((DecimalValue)other).isZero())
          {throw new XPathException(ErrorCodes.FOAR0001, "division by zero");}

        //Copied from Saxon 8.6.1 
            final int scale = Math.max(DIVIDE_PRECISION, Math.max(value.scale(), ((DecimalValue)other).value.scale()));
        final BigDecimal result = value.divide(((DecimalValue)other).value, scale, BigDecimal.ROUND_HALF_DOWN);
        return new DecimalValue(result);
View Full Code Here

    }   
  }

  public IntegerValue idiv(NumericValue other) throws XPathException {
    if (other.isZero())
      {throw new XPathException(ErrorCodes.FOAR0001, "division by zero");}

    final DecimalValue dv = (DecimalValue)other.convertTo(Type.DECIMAL);
        final BigInteger quot = value.divide(dv.value, 0, BigDecimal.ROUND_DOWN).toBigInteger();
        return new IntegerValue(quot);
  }
View Full Code Here

   * @see org.exist.xquery.value.NumericValue#mod(org.exist.xquery.value.NumericValue)
   */
  public NumericValue mod(NumericValue other) throws XPathException {
    if (other.getType() == Type.DECIMAL) {
      if (other.isZero())
        {throw new XPathException(ErrorCodes.FOAR0001, "division by zero");}

      final BigDecimal quotient = value.divide(((DecimalValue)other).value, 0, BigDecimal.ROUND_DOWN);
            final BigDecimal remainder = value.subtract(quotient.setScale(0, BigDecimal.ROUND_DOWN).multiply(((DecimalValue) other).value));
            return new DecimalValue(remainder);
    } else
View Full Code Here

          case Constants.LT:
            return compareTo(otherValue) == Constants.INFERIOR;
          case Constants.LTEQ:
            return compareTo(otherValue) != Constants.SUPERIOR;
          default:
            throw new XPathException("Type error: cannot apply operator to numeric value");
        }
      }
    }
    //Default to the standard numeric comparison
    return super.compareTo(collator, operator, other);
View Full Code Here

    } else if(target == String.class)
      {return (T)getStringValue();}
    else if(target == Boolean.class)
      {return (T)Boolean.valueOf(effectiveBooleanValue());}

    throw new XPathException(
      "cannot convert value of type "
        + Type.getTypeName(getType())
        + " to Java object of type "
        + target.getName());
  }
View Full Code Here

                                    NodeImpl node = (NodeImpl) v;
                                    if (node.getDocument() == doc) {
                                        node = expandedDoc.getNode(node.getNodeNumber());
                                        NodeId nodeId = node.getNodeId();
                                        if (nodeId == null)
                                            {throw new XPathException("Internal error: nodeId == null");}
                                        if (node.getNodeType() == Node.DOCUMENT_NODE)
                                            {nodeId = rootId;}
                                        else
                                            {nodeId = rootId.append(nodeId);}
                                        NodeProxy p = new NodeProxy(newDoc, nodeId, node.getNodeType());
                                        if (p != null) {
                                            // replace the node by the NodeProxy
                                            items[j].item = p;
                                        }
                                    }
                                }
                            }
                        }
                        set.add((NodeProxy) items[i].item);
          } else {
            set.add((NodeProxy)v);
          }
        }
      }     
      return set;
    } else
      {throw new XPathException("Type error: the sequence cannot be converted into" +
        " a node set. Item type is " + Type.getTypeName(itemType));}
  }
View Full Code Here

    public MemoryNodeSet toMemNodeSet() throws XPathException {
        if(count == 0)
            {return MemoryNodeSet.EMPTY;}
        if(itemType == Type.ANY_TYPE || !Type.subTypeOf(itemType, Type.NODE)) {
            throw new XPathException("Type error: the sequence cannot be converted into" +
        " a node set. Item type is " + Type.getTypeName(itemType));
        }
        NodeValue v;
        for (int i = 0; i < count; i++) {
            v = (NodeValue)items[i].item;
View Full Code Here

        final Sequence seq = orderSpecs[i].getSortExpression().eval(null);
        values[i] = AtomicValue.EMPTY_VALUE;
        if(seq.hasOne()) {
          values[i] = seq.itemAt(0).atomize();
        } else if(seq.hasMany())
          {throw new XPathException("expected a single value for order expression " +
            ExpressionDumper.dump(orderSpecs[i].getSortExpression()) +
            " ; found: " + seq.getItemCount());}
      }
    }
View Full Code Here

TOP

Related Classes of org.exist.xquery.XPathException$FunctionStackElement

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.