Package org.apache.vxquery.datamodel.accessors.atomic

Examples of org.apache.vxquery.datamodel.accessors.atomic.XSDecimalPointable


        if (!Double.isInfinite(value) && !Double.isNaN(value) && Math.abs(value) >= 0.000001
                && Math.abs(value) <= 1000000) {
            CastToDecimalOperation castToDecimal = new CastToDecimalOperation();
            castToDecimal.convertDouble(doublep, dOutInner);
            XSDecimalPointable decp = (XSDecimalPointable) XSDecimalPointable.FACTORY.createPointable();
            decp.set(abvsInner.getByteArray(), abvsInner.getStartOffset() + 1,
                    XSDecimalPointable.TYPE_TRAITS.getFixedLength());
            convertDecimal(decp, dOut);
        } else if (value == -0.0 || value == 0.0) {
            long bits = Double.doubleToLongBits(value);
            boolean negative = ((bits >> 63) == 0) ? false : true;
View Full Code Here


        if (!Float.isInfinite(value) && !Float.isNaN(value) && Math.abs(value) >= 0.000001
                && Math.abs(value) <= 1000000) {
            CastToDecimalOperation castToDecimal = new CastToDecimalOperation();
            castToDecimal.convertFloat(floatp, dOutInner);
            XSDecimalPointable decp = (XSDecimalPointable) XSDecimalPointable.FACTORY.createPointable();
            decp.set(abvsInner.getByteArray(), abvsInner.getStartOffset() + 1, abvsInner.getLength());
            convertDecimal(decp, dOut);
        } else if (value == -0.0f || value == 0.0f) {
            long bits = Float.floatToIntBits(value);
            boolean negative = ((bits >> 31) == 0) ? false : true;
View Full Code Here

        final SequenceBuilder sb = new SequenceBuilder();
        final SequencePointable seq = (SequencePointable) SequencePointable.FACTORY.createPointable();
        final VoidPointable p = (VoidPointable) VoidPointable.FACTORY.createPointable();
        final DoublePointable doublep = (DoublePointable) DoublePointable.FACTORY.createPointable();
        final LongPointable longp = (LongPointable) LongPointable.FACTORY.createPointable();
        final XSDecimalPointable decp = (XSDecimalPointable) XSDecimalPointable.FACTORY.createPointable();
        final ArrayBackedValueStorage abvsRound = new ArrayBackedValueStorage();
        final FnRoundOperation round = new FnRoundOperation();
        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
            @Override
            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
                try {
                    long startingLoc;
                    TaggedValuePointable tvp2 = args[1];
                    startingLoc = getLongFromArgument(tvp2);
                    if (startingLoc < 1) {
                        startingLoc = 1;
                    }

                    // Get length.
                    long endingLoc = Long.MAX_VALUE;
                    if (args.length > 2) {
                        TaggedValuePointable tvp3 = args[2];
                        endingLoc = getLongFromArgument(tvp3) + startingLoc;
                    }

                    abvs.reset();
                    sb.reset(abvs);
                    TaggedValuePointable tvp1 = args[0];
                    if (tvp1.getTag() == ValueTag.SEQUENCE_TAG) {
                        tvp1.getValue(seq);
                        int seqLen = seq.getEntryCount();
                        if (endingLoc < startingLoc) {
                            // Empty sequence.
                        } else if (startingLoc == 1 && endingLoc > seqLen) {
                            // Includes whole sequence.
                            result.set(tvp1);
                            return;
                        } else {
                            for (int j = 0; j < seqLen; ++j) {
                                if (startingLoc <= j + 1 && j + 1 < endingLoc) {
                                    seq.getEntry(j, p);
                                    sb.addItem(p);
                                }
                            }
                        }
                    } else if (startingLoc == 1 && endingLoc > 1) {
                        // Includes item.
                        result.set(tvp1);
                        return;
                    }
                    sb.finish();
                    result.set(abvs);
                } catch (IOException e) {
                    throw new SystemException(ErrorCode.SYSE0001);
                }
            }

            /**
             * XQuery Specification calls for double value. Integer and Decimal are allowed to cut down on casting.
             *
             * @param tvp
             * @return
             * @throws SystemException
             * @throws IOException
             */
            public long getLongFromArgument(TaggedValuePointable tvp) throws SystemException, IOException {
                if (tvp.getTag() == ValueTag.XS_DOUBLE_TAG) {
                    tvp.getValue(doublep);
                    abvsRound.reset();
                    round.operateDouble(doublep, abvsRound.getDataOutput());
                    doublep.set(abvsRound.getByteArray(), abvsRound.getStartOffset() + 1,
                            DoublePointable.TYPE_TRAITS.getFixedLength());
                    return doublep.longValue();
                } else if (tvp.getTag() == ValueTag.XS_INTEGER_TAG) {
                    tvp.getValue(longp);
                    return longp.longValue();
                } else if (tvp.getTag() == ValueTag.XS_DECIMAL_TAG) {
                    tvp.getValue(decp);
                    return decp.longValue();
                } else {
                    throw new SystemException(ErrorCode.FORG0006);
                }
            }
        };
View Full Code Here

    @Override
    public boolean operateDecimalInteger(XSDecimalPointable decp1, LongPointable longp2) throws SystemException,
            IOException {
        abvsInner.reset();
        XSDecimalPointable decp2 = (XSDecimalPointable) XSDecimalPointable.FACTORY.createPointable();
        decp2.set(abvsInner.getByteArray(), abvsInner.getStartOffset(), XSDecimalPointable.TYPE_TRAITS.getFixedLength());
        decp2.setDecimal(longp2.getLong(), (byte) 0);
        return (decp1.compareTo(decp2) == 0);
    }
View Full Code Here

    @Override
    public boolean operateIntegerDecimal(LongPointable longp1, XSDecimalPointable decp2) throws SystemException,
            IOException {
        abvsInner.reset();
        XSDecimalPointable decp1 = (XSDecimalPointable) XSDecimalPointable.FACTORY.createPointable();
        decp1.set(abvsInner.getByteArray(), abvsInner.getStartOffset(), XSDecimalPointable.TYPE_TRAITS.getFixedLength());
        decp1.setDecimal(longp1.getLong(), (byte) 0);
        return (decp1.compareTo(decp2) == 0);
    }
View Full Code Here

    @Override
    public boolean operateDecimalInteger(XSDecimalPointable decp1, LongPointable longp2) throws SystemException,
            IOException {
        abvsInner.reset();
        XSDecimalPointable decp2 = (XSDecimalPointable) XSDecimalPointable.FACTORY.createPointable();
        decp2.set(abvsInner.getByteArray(), abvsInner.getStartOffset(), XSDecimalPointable.TYPE_TRAITS.getFixedLength());
        decp2.setDecimal(longp2.getLong(), (byte) 0);
        return (decp1.compareTo(decp2) == -1);
    }
View Full Code Here

    @Override
    public boolean operateIntegerDecimal(LongPointable longp1, XSDecimalPointable decp2) throws SystemException,
            IOException {
        abvsInner.reset();
        XSDecimalPointable decp1 = (XSDecimalPointable) XSDecimalPointable.FACTORY.createPointable();
        decp1.set(abvsInner.getByteArray(), abvsInner.getStartOffset(), XSDecimalPointable.TYPE_TRAITS.getFixedLength());
        decp1.setDecimal(longp1.getLong(), (byte) 0);
        return (decp1.compareTo(decp2) == -1);
    }
View Full Code Here

                throw new UnsupportedOperationException("Encountered tag: " + tvp.getTag());
        }
    }

    private void printDecimal(PrintStream ps, TaggedValuePointable tvp) {
        XSDecimalPointable dp = pp.takeOne(XSDecimalPointable.class);
        try {
            tvp.getValue(dp);
            abvs.reset();
            castToString.convertDecimal(dp, dOut);
            printStringAbvs(ps);
View Full Code Here

        final SequenceBuilder sb = new SequenceBuilder();
        final SequencePointable seq = new SequencePointable();
        final VoidPointable p = (VoidPointable) VoidPointable.FACTORY.createPointable();
        final DoublePointable doublep = (DoublePointable) DoublePointable.FACTORY.createPointable();
        final LongPointable longp = (LongPointable) LongPointable.FACTORY.createPointable();
        final XSDecimalPointable decp = (XSDecimalPointable) XSDecimalPointable.FACTORY.createPointable();
        final ArrayBackedValueStorage abvsRound = new ArrayBackedValueStorage();
        final FnRoundOperation round = new FnRoundOperation();
        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
            @Override
            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
                try {
                    long startingLoc;
                    TaggedValuePointable tvp2 = args[1];
                    startingLoc = getLongFromArgument(tvp2);
                    if (startingLoc < 1) {
                        startingLoc = 1;
                    }

                    // Get length.
                    long endingLoc = Long.MAX_VALUE;
                    if (args.length > 2) {
                        TaggedValuePointable tvp3 = args[2];
                        endingLoc = getLongFromArgument(tvp3) + startingLoc;
                    }

                    abvs.reset();
                    sb.reset(abvs);
                    TaggedValuePointable tvp1 = args[0];
                    if (tvp1.getTag() == ValueTag.SEQUENCE_TAG) {
                        tvp1.getValue(seq);
                        int seqLen = seq.getEntryCount();
                        if (endingLoc < startingLoc) {
                            // Empty sequence.
                        } else if (startingLoc == 1 && endingLoc > seqLen) {
                            // Includes whole sequence.
                            result.set(tvp1);
                            return;
                        } else {
                            for (int j = 0; j < seqLen; ++j) {
                                if (startingLoc <= j + 1 && j + 1 < endingLoc) {
                                    seq.getEntry(j, p);
                                    sb.addItem(p);
                                }
                            }
                        }
                    } else if (startingLoc == 1 && endingLoc > 1) {
                        // Includes item.
                        result.set(tvp1);
                        return;
                    }
                    sb.finish();
                    result.set(abvs);
                } catch (IOException e) {
                    throw new SystemException(ErrorCode.SYSE0001);
                }
            }

            /**
             * XQuery Specification calls for double value. Integer and Decimal are allowed to cut down on casting.
             *
             * @param tvp
             * @return
             * @throws SystemException
             * @throws IOException
             */
            public long getLongFromArgument(TaggedValuePointable tvp) throws SystemException, IOException {
                if (tvp.getTag() == ValueTag.XS_DOUBLE_TAG) {
                    tvp.getValue(doublep);
                    abvsRound.reset();
                    round.operateDouble(doublep, abvsRound.getDataOutput());
                    doublep.set(abvsRound.getByteArray(), abvsRound.getStartOffset() + 1,
                            DoublePointable.TYPE_TRAITS.getFixedLength());
                    return doublep.longValue();
                } else if (tvp.getTag() == ValueTag.XS_INTEGER_TAG) {
                    tvp.getValue(longp);
                    return longp.longValue();
                } else if (tvp.getTag() == ValueTag.XS_DECIMAL_TAG) {
                    tvp.getValue(decp);
                    return decp.longValue();
                } else {
                    throw new SystemException(ErrorCode.FORG0006);
                }
            }
        };
View Full Code Here

                throw new UnsupportedOperationException("Encountered tag: " + tvp.getTag());
        }
    }

    private void printDecimal(PrintStream ps, TaggedValuePointable tvp) {
        XSDecimalPointable dp = pp.takeOne(XSDecimalPointable.class);
        try {
            tvp.getValue(dp);
            abvs.reset();
            castToString.convertDecimal(dp, dOut);
            printStringAbvs(ps);
View Full Code Here

TOP

Related Classes of org.apache.vxquery.datamodel.accessors.atomic.XSDecimalPointable

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.