Esempio n. 1
0
        /// <summary>
        /// Creates a new ResultSequence consisting of the extractable integer in the
        /// supplied ResultSequence
        /// </summary>
        /// <param name="arg">
        ///            The ResultSequence from which the integer is to be extracted </param>
        /// <returns> New ResultSequence consisting of the integer supplied </returns>
        /// <exception cref="DynamicError"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.eclipse.wst.xml.xpath2.api.ResultSequence constructor(org.eclipse.wst.xml.xpath2.api.ResultSequence arg) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public override ResultSequence constructor(ResultSequence arg)
        {
            if (arg.empty())
            {
                return(ResultBuffer.EMPTY);
            }

            // the function conversion rules apply here too. Get the argument
            // and convert it's string value to an integer.
            Item aat = arg.first();

            if (aat is XSDuration || aat is CalendarType || aat is XSBase64Binary || aat is XSHexBinary || aat is XSAnyURI)
            {
                throw DynamicError.invalidType();
            }

            if (!isCastable(aat))
            {
                throw DynamicError.cant_cast(null);
            }


            try
            {
                System.Numerics.BigInteger bigInt = castInteger(aat);
                return(new XSInteger(bigInt));
            }
            catch (System.FormatException)
            {
                throw DynamicError.invalidLexicalValue();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a new result sequence consisting of the retrievable decimal
        /// number in the supplied result sequence
        /// </summary>
        /// <param name="arg">
        ///            The result sequence from which to extract the decimal number. </param>
        /// <exception cref="DynamicError"> </exception>
        /// <returns> A new result sequence consisting of the decimal number supplied. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.eclipse.wst.xml.xpath2.api.ResultSequence constructor(org.eclipse.wst.xml.xpath2.api.ResultSequence arg) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public override ResultSequence constructor(ResultSequence arg)
        {
            if (arg.empty())
            {
                return(ResultBuffer.EMPTY);
            }

            Item aat = arg.first();

            if (aat is XSDuration || aat is CalendarType || aat is XSBase64Binary || aat is XSHexBinary || aat is XSAnyURI)
            {
                throw DynamicError.invalidType();
            }

            if (aat.StringValue.IndexOf("-INF", StringComparison.Ordinal) != -1)
            {
                throw DynamicError.cant_cast(null);
            }

            if (!isLexicalValue(aat.StringValue))
            {
                throw DynamicError.invalidLexicalValue();
            }

            if (!isCastable(aat))
            {
                throw DynamicError.cant_cast(null);
            }

            try
            {
                // XPath doesn't allow for converting Exponents to Decimal values.

                return(castDecimal(aat));
            }
            catch (System.FormatException)
            {
                throw DynamicError.cant_cast(null);
            }
        }