Package org.exist.xquery.value

Examples of org.exist.xquery.value.Item.convertTo()


                if( !Type.subTypeOf( key.getType(), Type.STRING ) ) {
                    LOG.info( "Truncated key. Converted from " + Type.getTypeName( key.getType() ) + " to xs:string" );

                    //truncation is only possible on strings
                    key = key.convertTo( Type.STRING );
                }
            }
            //else if key is not the same type as the index
            //TODO : use Type.isSubType() ??? -pb
            else if( key.getType() != indexType ) {
View Full Code Here


            //TODO : use Type.isSubType() ??? -pb
            else if( key.getType() != indexType ) {

                //try to convert the key to the index type
                try {
                    key = key.convertTo( indexType );
                }
                catch( final XPathException xpe ) {

                    if( LOG.isTraceEnabled() ) {
                        LOG.trace( "Cannot convert key: " + Type.getTypeName( key.getType() ) + " to required index type: " + Type.getTypeName( indexType ) );
View Full Code Here

                    if( !Type.subTypeOf( key.getType(), Type.STRING ) ) {
                        LOG.info( "Truncated key. Converted from " + Type.getTypeName( key.getType() ) + " to xs:string" );

                        //truncation is only possible on strings
                        key = key.convertTo( Type.STRING );
                    }
                }
                //else if key is not the same type as the index
                //TODO : use Type.isSubType() ??? -pb
                else if( key.getType() != indexType ) {
View Full Code Here

                //TODO : use Type.isSubType() ??? -pb
                else if( key.getType() != indexType ) {

                    //try to convert the key to the index type
                    try {
                        key = key.convertTo( indexType );
                    }
                    catch( final XPathException xpe ) {
                        //TODO : rethrow the exception ? -pb

                        //Could not convert the key to a suitable type for the index, fallback to nodeSetCompare()
View Full Code Here

    private Sequence convert(Sequence seq) throws XPathException {
        final ValueSequence result = new ValueSequence();
        Item item;
        for(final SequenceIterator i = seq.iterate(); i.hasNext(); ) {
            item = i.nextItem();
            result.add(item.convertTo(type.getPrimaryType()));
        }
        return result;
    }
}
View Full Code Here

            Item rvalue = rseq.itemAt(0);
            try {
                if (lvalue.getType() == Type.UNTYPED_ATOMIC || lvalue.getType() == Type.ATOMIC)
                    {lvalue = lvalue.convertTo(Type.NUMBER);}
                if (rvalue.getType() == Type.UNTYPED_ATOMIC || rvalue.getType() == Type.ATOMIC)
                    {rvalue = rvalue.convertTo(Type.NUMBER);}
                if (!(lvalue instanceof ComputableValue))
                    {throw new XPathException(this, ErrorCodes.XPTY0004, "'" +
                        Type.getTypeName(lvalue.getType()) + "(" + lvalue + ")' can not be an operand for " +
                        Constants.OPS[operator]);}
                if (!(rvalue instanceof ComputableValue))
View Full Code Here

          final Item item = seq.itemAt(0);
          NumericValue value;
          if (item instanceof NumericValue) {
        value = (NumericValue) item;
      } else {
        value = (NumericValue) item.convertTo(Type.NUMBER);
      }
         
      result = value.round(precision);
        }
       
View Full Code Here

          final Item item = seq.itemAt(0);
          NumericValue value;
          if (item instanceof NumericValue) {
        value = (NumericValue) item;
      } else {
        value = (NumericValue) item.convertTo(Type.NUMBER);
      }
            result = value.abs();
        }
        if (context.getProfiler().isEnabled())
            {context.getProfiler().end(this, "", result);}
View Full Code Here

          final Item item = seq.itemAt(0);
          NumericValue value;
          if (item instanceof NumericValue) {
        value = (NumericValue) item;
      } else {
        value = (NumericValue) item.convertTo(Type.NUMBER);
      }
        result = value.floor();
        }
       
        if (context.getProfiler().isEnabled())
View Full Code Here

            }

            if(existDestinationType == value.getType()) {
                convertedValue = value;
            } else if(value instanceof AtomicValue) {
                convertedValue = value.convertTo(existDestinationType);
            } else {
                LOG.warn("Could not convert parameter '" + argumentName + "' from '" + typedValue.getType().name() + "' to '" + destinationType.name() + "'.");
                convertedValue = value;
            }
           
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.