Examples of XNumber


Examples of org.apache.xpath.objects.XNumber

      {
        textNodeValue = new XBoolean(((Boolean) rtf).booleanValue()).str();
      }
      else if (rtf instanceof Double)
      {
        textNodeValue = new XNumber(((Double) rtf).doubleValue()).str();
      }
      else
      {
        textNodeValue = rtf.toString();
      }
View Full Code Here

Examples of org.apache.xpath.objects.XNumber

          StepPattern attrPat = new StepPattern(whatToShow,
                                    pat.getNamespace(),
                                    pat.getLocalName(),
                                //newAxis, pat.getPredicateAxis);
                                                newAxis, 0); // don't care about the predicate axis
          XNumber score = pat.getStaticScore();
          pat.setNamespace(null);
          pat.setLocalName(NodeTest.WILD);
          attrPat.setPredicates(pat.getPredicates());
          pat.setPredicates(null);
          pat.setWhatToShow(DTMFilter.SHOW_ELEMENT);
          StepPattern rel = pat.getRelativePathPattern();
          pat.setRelativePathPattern(attrPat);
          attrPat.setRelativePathPattern(rel);
          attrPat.setStaticScore(score);
         
          // This is needed to inverse a following pattern, because of the
          // wacky Xalan rules for following from an attribute.  See axes108.
          // By these rules, following from an attribute is not strictly
          // inverseable.
          if(Axis.PRECEDING == pat.getAxis())
            pat.setAxis(Axis.PRECEDINGANDANCESTOR);
           
          else if(Axis.DESCENDANT == pat.getAxis())
            pat.setAxis(Axis.DESCENDANTORSELF);
         
          pat = attrPat;
        }
        else if(Axis.CHILD == pat.getAxis())
        {
          // In this case just change the axis.
          // pat.setWhatToShow(whatToShow);
          pat.setAxis(Axis.ATTRIBUTE);
        }
      }
      axis = nextAxis;
      //paxis = nextPaxis;
      tail = pat;
    }
   
    if(axis < Axis.ALL)
    {
      StepPattern selfPattern = new ContextMatchStepPattern(axis, paxis);
      // We need to keep the new nodetest from affecting the score...
      XNumber score = tail.getStaticScore();
      tail.setRelativePathPattern(selfPattern);
      tail.setStaticScore(score);
      selfPattern.setStaticScore(score);
    }       
View Full Code Here

Examples of org.apache.xpath.objects.XNumber

   *
   * @throws javax.xml.transform.TransformerException
   */
  public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
  {
    return new XNumber(getArg0AsString(xctxt).length());
  }
View Full Code Here

Examples of org.apache.xpath.objects.XNumber

    if (propName.equals("version") && result.length() > 0)
    {
      try
      {
        // Needs to return the version number of the spec we conform to.
        return new XNumber(1.0);
      }
      catch (Exception ex)
      {
        return new XString(result);
      }
View Full Code Here

Examples of xbird.xquery.dm.value.literal.XNumber

            return XString.valueOf("");
        }
        final String sourceString = firstItem.stringValue();
        final int maxSourceLen = sourceString.length();
        final Item secItem = argv.getItem(1);
        final XNumber secNum = (XNumber) secItem;
        // first character of a string is located at position 1, not position 0.
        final int startingLoc = Math.max(0, (int) Math.round(secNum.asDouble() - 1));
        final int endingLoc;
        final int arglen = argv.size();
        if(arglen == 3) {
            final Item thirdItem = argv.getItem(2);
            final XNumber thirdNum = (XNumber) thirdItem;
            final int length = (int) Math.round(thirdNum.asDouble());
            endingLoc = Math.max(0, Math.min(maxSourceLen, length));
        } else {
            endingLoc = maxSourceLen;
        }
        if(endingLoc <= startingLoc) {
View Full Code Here

Examples of xbird.xquery.dm.value.literal.XNumber

        }
        if(!argItor.hasNext()) {
            return firstItem;
        }
        if(firstItem instanceof XNumber) {
            XNumber sum = (XNumber) firstItem;
            while(argItor.hasNext()) {
                Item toadd = argItor.next();
                if(toadd instanceof UntypedAtomicValue) {
                    toadd = ((UntypedAtomicValue) toadd).castAs(DoubleType.DOUBLE, dynEnv);
                } else if(!(toadd instanceof XNumber)) {
                    throw new DynamicError("err:FORG0006", "fs:plus(" + sum.getType() + ", "
                            + toadd.getType() + ") is not defined.");
                }
                // TODO more efficient processing
                final PlusOp op = new PlusOp();
                op.staticAnalysis(dynEnv.getStaticContext(), sum, toadd);
View Full Code Here

Examples of xbird.xquery.dm.value.literal.XNumber

        if(!argItor.hasNext()) {
            return firstItem;
        }
        final Type firstType = firstItem.getType();
        if(firstItem instanceof XNumber) {
            XNumber min = (XNumber) firstItem;
            // If the converted sequence contains the value NaN, the value NaN is returned.
            if(min.isNaN()) {
                return min;
            }
            while(argItor.hasNext()) {
                Item it = argItor.next();
                if(it instanceof UntypedAtomicValue) {
                    it = ((UntypedAtomicValue) it).castAs(DoubleType.DOUBLE, dynEnv);
                } else if(!(it instanceof XNumber)) {
                    throw new DynamicError("err:FORG0006", "fs:plus(" + min.getType() + ", "
                            + it.getType() + ") is not defined.");
                }
                XNumber cmp = (XNumber) it;
                if(cmp.isNaN()) {
                    return cmp;
                }
                if(cmp.compareTo(min) < 0) {
                    min = cmp;
                }
            }
            return min;
        } else if(firstItem instanceof DurationValue) {
            // Duration values must either all be xdt:yearMonthDuration values
            // or must all be xdt:dayTimeDuration values.
            DurationValue min = (DurationValue) firstItem;
            assert (firstType != null);
            while(argItor.hasNext()) {
                Item it = argItor.next();
                if(it instanceof DurationValue) {
                    throw new DynamicError("err:FORG0006", "Duration values must all be `"
                            + firstType + "`, but found `" + it.getType() + "`");
                }
                DurationValue cmp = (DurationValue) it;
                if(cmp.compareTo(min) < 0) {
                    min = cmp;
                }
            }
            return min;
        } else if(TypeUtil.subtypeOf(firstType, StringType.STRING)) {
View Full Code Here

Examples of xbird.xquery.dm.value.literal.XNumber

        if(!argItor.hasNext()) {
            return firstItem;
        }
        final Type firstType = firstItem.getType();
        if(firstItem instanceof XNumber) {
            XNumber max = (XNumber) firstItem;
            // If the converted sequence contains the value NaN, the value NaN is returned.
            if(max.isNaN()) {
                return max;
            }
            while(argItor.hasNext()) {
                Item it = argItor.next();
                if(it instanceof UntypedAtomicValue) {
                    it = ((UntypedAtomicValue) it).castAs(DoubleType.DOUBLE, dynEnv);
                } else if(!(it instanceof XNumber)) {
                    throw new DynamicError("err:FORG0006", "fs:plus(" + max.getType() + ", "
                            + it.getType() + ") is not defined");
                }
                XNumber cmp = (XNumber) it;
                if(cmp.isNaN()) {
                    return cmp;
                }
                if(cmp.compareTo(max) > 0) {
                    max = cmp;
                }
            }
            return max;
        } else if(firstItem instanceof DurationValue) {
            // Duration values must either all be xdt:yearMonthDuration values
            // or must all be xdt:dayTimeDuration values.
            DurationValue max = (DurationValue) firstItem;
            while(argItor.hasNext()) {
                Item it = argItor.next();
                if(it instanceof DurationValue) {
                    throw new DynamicError("err:FORG0006", "Duration values must all be `"
                            + firstType + "`, but found `" + it.getType() + "`");
                }
                DurationValue cmp = (DurationValue) it;
                if(cmp.compareTo(max) > 0) {
                    max = cmp;
                }
            }
            return max;
        } else if(TypeUtil.subtypeOf(firstType, StringType.STRING)) {
View Full Code Here

Examples of xbird.xquery.dm.value.literal.XNumber

        }
        if(!argItor.hasNext()) {
            return firstItem;
        }
        if(firstItem instanceof XNumber) {
            XNumber sum = (XNumber) firstItem;
            int size;
            for(size = 1; argItor.hasNext(); size++) {
                Item toadd = argItor.next();
                if(toadd instanceof UntypedAtomicValue) {
                    toadd = ((UntypedAtomicValue) toadd).castAs(DoubleType.DOUBLE, dynEnv);
                } else if(!(toadd instanceof XNumber)) {
                    throw new DynamicError("err:FORG0006", "fs:plus(" + sum.getType() + ", "
                            + toadd.getType() + ") is not defined.");
                }
                final PlusOp op = new PlusOp();
                op.staticAnalysis(dynEnv.getStaticContext(), sum, toadd);
                sum = (XNumber) op.eval(dynEnv, sum, toadd);
View Full Code Here

Examples of xbird.xquery.dm.value.literal.XNumber

            if(e instanceof LiteralExpr) {
                AtomicValue literal = ((LiteralExpr) e).getValue();
                if(literal instanceof XNumber) {
                    DynamicContext probe = DynamicContext.PROBE;
                    probe.setStaticContext(statEnv);
                    XNumber xnum = (XNumber) literal;
                    double xdouble = xnum.asDouble();
                    long xint = xnum.asLong();
                    if(xdouble != xint) {
                        return SequenceExpression.EMPTY_SEQUENCE;
                    }
                    if(xint > Integer.MAX_VALUE) {
                        throw new IllegalStateException();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.