Esempio n. 1
0
        /// <summary>
        /// Creates a new ResultSequence consisting of the retrievable float in the
        /// supplied ResultSequence
        /// </summary>
        /// <param name="arg">
        ///            The ResultSequence from which to extract the float </param>
        /// <returns> New ResultSequence consisting of the float 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);
            }

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

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

            if (!(aat.string_type().Equals("xs:string") || aat is NodeType || aat.string_type().Equals("xs:untypedAtomic") || aat.string_type().Equals("xs:boolean") || aat is NumericType))
            {
                throw DynamicError.cant_cast(null);
            }


            try
            {
                float f;
                if (aat.StringValue.Equals("INF"))
                {
                    f = float.PositiveInfinity;
                }
                else if (aat.StringValue.Equals("-INF"))
                {
                    f = float.NegativeInfinity;
                }
                else if (aat is XSBoolean)
                {
                    if (aat.StringValue.Equals("true"))
                    {
                        f = 1.0f;
                    }
                    else
                    {
                        f = 0.0f;
                    }
                }
                else
                {
                    f = Convert.ToSingle(aat.StringValue);
                }
                return(new XSFloat(f));
            }
            catch (System.FormatException)
            {
                throw DynamicError.cant_cast(null);
            }
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private org.eclipse.wst.xml.xpath2.api.ResultSequence convertResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence arg) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        private ResultSequence convertResultSequence(ResultSequence arg)
        {
            ResultSequence carg = arg;
            var            it   = carg.iterator();

            while (it.MoveNext())
            {
                AnyType type = (AnyType)it.Current;
                if (type.string_type().Equals("xs:untypedAtomic") || type.string_type().Equals("xs:string"))
                {
                    throw DynamicError.invalidType();
                }
            }
            carg = constructor(carg);
            return(carg);
        }
Esempio n. 3
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()));
        }
Esempio n. 4
0
        protected internal virtual bool isGDataType(AnyType aat)
        {
            if (!(aat is AnyAtomicType))
            {
                return(false);
            }

            string type = aat.string_type();

            if (type.Equals("xs:gMonthDay") || type.Equals("xs:gDay") || type.Equals("xs:gMonth") || type.Equals("xs:gYear") || type.Equals("xs:gYearMonth"))
            {
                return(true);
            }
            return(false);
        }