Package org.apache.xpath.objects

Examples of org.apache.xpath.objects.XNumber


      if (val instanceof XObject)
      {
        switch (op)
        {
          case OpCodes.OP_NEG :
            return new XNumber(- ((XObject) val).num());
          case OpCodes.OP_STRING :
            return new XString(((XObject) val).str());
          case OpCodes.OP_BOOL :
            return new XBoolean(((XObject) val).bool());
          case OpCodes.OP_NUMBER :
            return new XNumber(((XObject) val).num());
          default :
            return null; // Won't happen
        }
      }
      if (val instanceof NamedKeys)
View Full Code Here


      if (args.size() == 1)
      {
        Object o = args.get(0);
        if (o instanceof XObject)
        {
          return new XNumber(Math.ceil(((XObject) o).num()));
        }
      }
      return null;
    }
View Full Code Here

      if (args.size() == 1)
      {
        Object o = args.get(0);
        if (o instanceof XObject)
        {
          return new XNumber(Math.floor(((XObject) o).num()));
        }
      }
      return null;
    }
View Full Code Here

      if (args.size() == 1)
      {
        Object o = args.get(0);
        if (o instanceof XObject)
        {
          return new XNumber(((XObject) o).num());
        }
      }
      return null;
    }
View Full Code Here

      if (args.size() == 1)
      {
        Object o = args.get(0);
        if (o instanceof XObject)
        {
          return new XNumber(Math.round(((XObject) o).num()));
        }
      }
      return null;
    }
View Full Code Here

      if (args.size() == 1)
      {
        Object o = args.get(0);
        if (o instanceof XObject)
        {
          return new XNumber(((XObject) o).str().length());
        }
      }
      return null;
    }
View Full Code Here

      {
        value = new XBoolean(((Boolean) obj).booleanValue());
      }
      else if (obj instanceof Double)
      {
        value = new XNumber(((Double) obj).doubleValue());
      }
      else if (obj instanceof DocumentFragment)
      {
        int handle = xctxt.getDTMHandleFromNode((DocumentFragment)obj);
       
View Full Code Here

          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

    {
      String[] edz = getEraDatetimeZone(datetimeIn);
      boolean ad = edz[0].length() == 0; // AD (Common Era -- empty leader)
      String datetime = edz[1];
      if (datetime == null)
        return new XNumber(Double.NaN);
     
      String[] formats = {dt, d, gym, gy};
      double yr = getNumber(datetime, formats, Calendar.YEAR);
      if (ad || yr == Double.NaN)
        return new XNumber(yr);
      else
        return new XNumber(-yr);
    }
View Full Code Here

     * See above.
     */
    public static XNumber year()
    {
      Calendar cal = Calendar.getInstance();
      return new XNumber(cal.get(Calendar.YEAR));
    }
View Full Code Here

TOP

Related Classes of org.apache.xpath.objects.XNumber

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.