Package org.exist.xquery

Examples of org.exist.xquery.XPathException


    if (other.getType() != getType()) {throw new XPathException("cannot obtain maximum across different non-numeric data types");}
    return compareTo(null, other) > 0 ? this : other;
  }

  public AtomicValue min(Collator collator, AtomicValue other) throws XPathException {
    if (other.getType() != getType()) {throw new XPathException("cannot obtain minimum across different non-numeric data types");}
    return compareTo(null, other) < 0 ? this : other;
  }
View Full Code Here


        //Shift one year
        if (gc.getYear() <0)
          {gc.setYear(gc.getYear() - 1);}
        return date.createSameKind(gc);
      default:
        throw new XPathException(ErrorCodes.XPTY0004, "cannot add " +
            Type.getTypeName(other.getType()) + "('" + other.getStringValue() + "') from " +
            Type.getTypeName(getType()) + "('" + getStringValue() + "')");    }
  }
View Full Code Here

  public ComputableValue minus(ComputableValue other) throws XPathException {
    switch(other.getType()) {
    case Type.DAY_TIME_DURATION: {
      if (getType() != other.getType())
        {throw new XPathException(ErrorCodes.XPTY0004, "Tried to substract " +
            Type.getTypeName(other.getType()) + "('" + other.getStringValue() + "') from " +
            Type.getTypeName(getType()) + "('" + getStringValue() + "')");}
      final Duration a = getCanonicalDuration();
      final Duration b = ((OrderedDurationValue) other).getCanonicalDuration()
      final Duration result = createSameKind(a.subtract(b)).getCanonicalDuration();
      return new DayTimeDurationValue(result); }       
    case Type.YEAR_MONTH_DURATION: {
      if (getType() != other.getType())
        {throw new XPathException(ErrorCodes.XPTY0004, "Tried to substract " +
            Type.getTypeName(other.getType()) + "('" + other.getStringValue() + "') from " +
            Type.getTypeName(getType()) + "('" + getStringValue() + "')");}
      final Duration a = getCanonicalDuration();
      final Duration b = ((OrderedDurationValue) other).getCanonicalDuration()
      final Duration result = createSameKind(a.subtract(b)).getCanonicalDuration();
      return new YearMonthDurationValue(result); }
    /*
    case Type.TIME:
    case Type.DATE_TIME:
    case Type.DATE:
      AbstractDateTimeValue date = (AbstractDateTimeValue) other;
      XMLGregorianCalendar gc = (XMLGregorianCalendar) date.calendar.clone();
      gc.substract(duration);
      return date.createSameKind(gc);
    */
    default:
      throw new XPathException("err:XPTY0004: cannot substract " +
          Type.getTypeName(other.getType()) + "('" + other.getStringValue() + "') from " +
          Type.getTypeName(getType()) + "('" + getStringValue() + "')");
    }
    /*
    if(other.getType() == getType()) {
View Full Code Here

   * @return the big decimal equivalent of the value
   * @throws XPathException if the value is not of a numeric type
   */
  protected BigDecimal numberToBigDecimal(ComputableValue x, String exceptionMessagePrefix) throws XPathException {
    if (!Type.subTypeOf(x.getType(), Type.NUMBER)) {
                    throw new XPathException(exceptionMessagePrefix + Type.getTypeName(x.getType()));
   
    if (((NumericValue) x).isInfinite() || ((NumericValue) x).isNaN()) {
                    throw new XPathException(ErrorCodes.XPTY0004, "Tried to convert '" + (NumericValue) x + "' to BigDecimal")
                }
               
    if (x.conversionPreference(BigDecimal.class) < Integer.MAX_VALUE) {
                    return x.toJavaObject(BigDecimal.class);
                } else {
View Full Code Here

                result = getHeader(request, headerName, null);
            } else if(getSignature().getArgumentCount() == 2) {
                final Sequence defaultValues = args[1];
                result = getHeader(request, headerName, defaultValues);
            } else {
                throw new XPathException(this, "Unknown function call: " + getSignature());
            }  
        } else {
            throw new XPathException(this, "Unknown function call: " + getSignature());
        }
       
        return result;
    }
View Full Code Here

        //lexicalValue = normalizeDate(lexicalValue);
        //lexicalValue = normalizeTime(getType(), lexicalValue);
    try {
      calendar = parse(lexicalValue);
    } catch (final IllegalArgumentException e) {
      throw new XPathException(ErrorCodes.FORG0001, "illegal lexical form for date-time-like value '" + lexicalValue + "' " + e.getMessage(), e);
    }
  }
View Full Code Here

   
    return r;
  }

  public boolean effectiveBooleanValue() throws XPathException {
    throw new XPathException(ErrorCodes.FORG0006, "effective boolean value invalid operand type: " + Type.getTypeName(getType()));
  }
View Full Code Here

  private static final Duration tzUpperBound = tzLowerBound.negate();
  protected void validateTimezone(DayTimeDurationValue offset) throws XPathException {
    final Duration tz = offset.duration;
    final Number secs = tz.getField(DatatypeConstants.SECONDS);
    if (secs != null && ((BigDecimal) secs).compareTo(BigDecimal.valueOf(0)) != 0)
      {throw new XPathException(ErrorCodes.FODT0003, "duration " + offset + " has fractional minutes so cannot be used as a timezone offset");}
    if (! (
        tz.equals(tzLowerBound) ||
        tz.equals(tzUpperBound) ||
        (tz.isLongerThan(tzLowerBound) && tz.isShorterThan(tzUpperBound))
      ))
      {throw new XPathException(ErrorCodes.FODT0003, "duration " + offset + " outside valid timezone offset range");}
  }
View Full Code Here

      xgc.add(offset.duration);
    }
    try {
      xgc.setTimezone((int) (offset.getValue()/60));
    } catch (final IllegalArgumentException e) {
      throw new XPathException(ErrorCodes.FORG0001, "illegal timezone offset " + offset, e);
    }
    return createSameKind(xgc);
  }
View Full Code Here

      case Constants.LT: return cmp < 0;
      case Constants.LTEQ: return cmp <= 0;
      case Constants.GT: return cmp > 0;
      case Constants.GTEQ: return cmp >= 0;
      default :
        throw new XPathException("Unknown operator type in comparison");
    }
  }
View Full Code Here

TOP

Related Classes of org.exist.xquery.XPathException

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.