Пример #1
0
        /// <summary>
        /// Creates a new ResultSequence consisting of the extractable unsignedByte
        /// in the supplied ResultSequence
        /// </summary>
        /// <param name="arg">
        ///            The ResultSequence from which the unsignedByte is to be extracted </param>
        /// <returns> New ResultSequence consisting of the 'unsignedByte' 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 a unsignedByte.
            Item aat = arg.first();

            try
            {
                System.Numerics.BigInteger.TryParse(aat.StringValue, out System.Numerics.BigInteger bigInt);

                // doing the range checking
                // min value is 0
                // max value is 255
                System.Numerics.BigInteger min = new System.Numerics.BigInteger(0);
                System.Numerics.BigInteger max = new System.Numerics.BigInteger(255L);

                if (bigInt.CompareTo(min) < 0 || bigInt.CompareTo(max) > 0)
                {
                    // invalid input
                    throw DynamicError.cant_cast(null);
                }

                return(new XSUnsignedByte(bigInt));
            }
            catch (System.FormatException)
            {
                throw DynamicError.cant_cast(null);
            }
        }
Пример #2
0
        /// <summary>
        /// Creates a new ResultSequence consisting of the extractable long in the
        /// supplied ResultSequence
        /// </summary>
        /// <param name="arg">
        ///            The ResultSequence from which the long is to be extracted </param>
        /// <returns> New ResultSequence consisting of the 'long' 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 a long.
            Item aat = arg.first();

            try
            {
                System.Numerics.BigInteger.TryParse(aat.StringValue, out System.Numerics.BigInteger bigInt);

                // doing the range checking
                System.Numerics.BigInteger min = new System.Numerics.BigInteger(-9223372036854775808L);
                System.Numerics.BigInteger max = new System.Numerics.BigInteger(9223372036854775807L);

                if (bigInt.CompareTo(min) < 0 || bigInt.CompareTo(max) > 0)
                {
                    // invalid input
                    DynamicError.throw_type_error();
                }

                return(new XSLong(bigInt));
            }
            catch (System.FormatException)
            {
                throw DynamicError.cant_cast(null);
            }
        }
Пример #3
0
//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);
            }

            AnyAtomicType aat = (AnyAtomicType)arg.first();

            return(new XSUntypedAtomic(aat.StringValue));
        }
Пример #4
0
        /// <summary>
        /// Creation of a result sequence consisting of a URI from a previous result
        /// sequence.
        /// </summary>
        /// <param name="arg">
        ///            previous result sequence </param>
        /// <exception cref="DynamicError"> </exception>
        /// <returns> new result sequence consisting of the URI 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);
            }

            AnyType aat = (AnyType)arg.first();

            if (!(aat.string_type().Equals("xs:string") || aat.string_type().Equals(XS_ANY_URI) || aat.string_type().Equals("xs:untypedAtomic")))
            {
                throw DynamicError.invalidType();
            }

            return(new XSAnyURI(aat.string_value()));
        }
Пример #5
0
        /// <summary>
        /// Creates a new ResultSequence consisting of the ENTITY within
        /// the supplied ResultSequence.  The specification says that this
        /// is relaxed from the XML Schema requirement.  The ENTITY does
        /// not have to be located or expanded during construction and
        /// evaluation for casting.
        /// </summary>
        /// <param name="arg">
        ///            The ResultSequence from which to extract the ENTITY </param>
        /// <returns> New ResultSequence consisting of the ENTITY 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);
            }

            AnyAtomicType aat      = (AnyAtomicType)arg.first();
            string        strValue = aat.StringValue;

            if (!isConstraintSatisfied(strValue))
            {
                // invalid input
                DynamicError.throw_type_error();
            }

            return(new XSEntity(strValue));
        }
Пример #6
0
        /// <summary>
        /// Creates a new ResultSequence consisting of the extractable NMTOKEN within
        /// the supplied ResultSequence
        /// </summary>
        /// <param name="arg">
        ///            The ResultSequence from which to extract the NMTOKEN </param>
        /// <returns> New ResultSequence consisting of the NMTOKEN 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);
            }

            AnyAtomicType aat      = (AnyAtomicType)arg.first();
            string        strValue = aat.StringValue;

            if (!XMLChar.isValidNmtoken(strValue))
            {
                // invalid input
                DynamicError.throw_type_error();
            }

            return(new XSNMTOKEN(strValue));
        }