Package org.exist.xquery.value

Examples of org.exist.xquery.value.AtomicValue


        final Sequence seq = getArgument(0).eval(contextSequence, contextItem);
        final Collator collator = getCollator(contextSequence, contextItem, 2);   
        final TreeSet<AtomicValue> set = new TreeSet<AtomicValue>(new ValueComparator(collator));
        final ValueSequence result = new ValueSequence();
        Item item;
        AtomicValue value;
        boolean hasAlreadyNaN = false;
        for (final SequenceIterator i = seq.iterate(); i.hasNext();) {
            item = i.nextItem();
            value = item.atomize();
            if (!set.contains(value)) {
                if (Type.subTypeOf(value.getType(), Type.NUMBER)) {
                    if (((NumericValue)value).isNaN()) {
                        //although NaN does not equal itself, if $arg
                        //contains multiple NaN values a single NaN is returned.
                        if (!hasAlreadyNaN) {
                            set.add(value);
View Full Code Here


        if (inner.isEmpty()) {
            result = Sequence.EMPTY_SEQUENCE;
        } else {
            final SequenceIterator iter = inner.iterate();
            Item item = iter.nextItem();
            AtomicValue value = item.atomize();
            //Any values 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);
            }
            //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;
View Full Code Here

                            Type.getTypeName(Type.QNAME), Type.getTypeName(item.getType()) }
                    ));
        }
        final QName qname = qval.getQName();
       
        final AtomicValue comparisonCriterium = args[1].itemAt(0).atomize();
       
        Sequence result = Sequence.EMPTY_SEQUENCE;

        if (comparisonCriterium instanceof Indexable) {
            final NativeValueIndex valueIndex = context.getBroker().getValueIndex();
            result =
                valueIndex.find(context.getWatchDog(), Constants.EQ, contextSequence.getDocumentSet(), null, NodeSet.ANCESTOR,
            qname, comparisonCriterium);
        } else {
            final String message = "The comparison criterium must be an Indexable: " +
              "boolean, numeric, string; instead your criterium has type " +
              Type.getTypeName(comparisonCriterium.getType());
          throw new XPathException(this, message);
        }

        return result;
    }
View Full Code Here

        {zero = getArgument(1).eval(contextSequence, contextItem);}
      result = zero;
    } else {
        final SequenceIterator iter = inner.iterate();
        Item item = iter.nextItem();
        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;
View Full Code Here

        final MapType map = new MapType(this.context);
        for (final Mapping mapping : this.mappings) {
            final Sequence key = mapping.key.eval(contextSequence);
            if (key.getItemCount() != 1)
                {throw new XPathException(MapErrorCode.EXMPDY001, "Expected single value for key, got " + key.getItemCount());}
            final AtomicValue atomic = key.itemAt(0).atomize();
            final Sequence value = mapping.value.eval(contextSequence);
            map.add(atomic, value);
        }
        return map;
    }
View Full Code Here

        /* (non-Javadoc)
         * @see org.dbxml.core.filer.BTreeCallback#indexInfo(org.dbxml.core.data.Value, long)
         */
        public boolean indexInfo( Value key, long pointer ) throws TerminatedException
        {
            AtomicValue atomic;

            try {

                if( byQName ) {
                    atomic = ( AtomicValue )QNameValue.deserialize( key.data(), key.start(), key.getLength() );
                } else {
                    atomic = ( AtomicValue )SimpleValue.deserialize( key.data(), key.start(), key.getLength() );
                }

                if( atomic.getType() != type ) {
                    return( false );
                }
            }
            catch( final EXistException e ) {
                LOG.error( e.getMessage(), e );
View Full Code Here

        byte indexType, boolean remove) {
        if (doc.getDocId() != node.getDocId()) {
            throw( new IllegalArgumentException( "Document id ('" + doc.getDocId() +
                "') and proxy id ('" + node.getDocId() + "') differ !"));
        }
        AtomicValue atomic = convertToAtomic(xpathType, content);
        //Ignore if the value can't be successfully atomized
        //(this is logged elsewhere)
        if (atomic == null) {
            return;
        }
View Full Code Here

        if( ( doc != null ) && ( doc.getDocId() != node.getDocId() ) ) {
            throw( new IllegalArgumentException( "Document id ('" + doc.getDocId() + "') and proxy id ('" + node.getDocId() + "') differ !" ) );
        }

        AtomicValue atomic = convertToAtomic( xpathType, value );

        //Ignore if the value can't be successfully atomized
        //(this is logged elsewhere)
        if( atomic == null ) {
            return;
View Full Code Here

     *
     * @return  <code>null</null> if atomization fails or if the atomic value is not indexable. Should we throw an exception instead ? -pb
     */
    private AtomicValue convertToAtomic( int xpathType, String value )
    {
        AtomicValue atomic;

        if( Type.subTypeOf( xpathType, Type.STRING ) ) {

            try {
                atomic = new StringValue( value, xpathType, false );
View Full Code Here

          result = defaultClause.returnClause.eval(contextSequence);
        } else {
            if (opSeq.hasMany()) {
                throw new XPathException(this, ErrorCodes.XPTY0004, "Cardinality error in switch operand ", opSeq);
            }
          final AtomicValue opVal = opSeq.itemAt(0).atomize();
          final Collator defaultCollator = context.getDefaultCollator();
          for (final Case next : cases) {
              for (final Expression caseOperand : next.operands) {
                  final Sequence caseSeq = caseOperand.eval(contextSequence, contextItem);
                  if (caseSeq.hasMany()) {
                      throw new XPathException(this, ErrorCodes.XPTY0004, "Cardinality error in switch case operand ", caseSeq);
                  }
                    final AtomicValue caseVal = caseSeq.itemAt(0).atomize();
                  if (FunDeepEqual.deepEquals(caseVal, opVal, defaultCollator)) {
                      return next.returnClause.eval(contextSequence);
                  }
              }
          }
View Full Code Here

TOP

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

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.