示例#1
0
        /// <summary>
        /// Compare the arguments as codepoints
        /// </summary>
        /// <param name="args">
        ///            are compared. </param>
        /// <param name="dynamicContext">
        ///            The current dynamic context </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> The result of the comparison of the arguments. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence codepoint_equals(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.DynamicContext dynamicContext) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence codepoint_equals(ICollection args, DynamicContext dynamicContext)
        {
            ICollection cargs = Function.convert_arguments(args, expected_args());

            ResultBuffer rs = new ResultBuffer();

            IEnumerator argiter = cargs.GetEnumerator();

            argiter.MoveNext();
            ResultSequence arg1  = (ResultSequence)argiter.Current;
            XSString       xstr1 = arg1 == null || arg1.empty() ? null : (XSString)arg1.first();

            argiter.MoveNext();
            ResultSequence arg2  = (ResultSequence)argiter.Current;
            XSString       xstr2 = arg2 == null || arg2.empty() ? null : (XSString)arg2.first();

            // This delegates to FnCompare
            System.Numerics.BigInteger result = FnCompare.compare_string(org.eclipse.wst.xml.xpath2.api.CollationProvider_Fields.CODEPOINT_COLLATION, xstr1, xstr2, dynamicContext);
            if (result != null)
            {
                rs.add(new XSBoolean(System.Numerics.BigInteger.Zero.Equals(result)));
            }

            return(rs.Sequence);
        }
示例#2
0
        /// <summary>
        /// Deep-Equal boolean operation for inputs of any atomic type.
        /// </summary>
        /// <param name="one">
        ///            input1 xpath expression/variable. </param>
        /// <param name="two">
        ///            input2 xpath expression/variable. </param>
        /// <returns> Result of fn:deep-equal operation. </returns>
        public static bool deep_equal_atomic(AnyAtomicType one, AnyAtomicType two, DynamicContext context, string collationURI)
        {
            if (!(one is CmpEq))
            {
                return(false);
            }
            if (!(two is CmpEq))
            {
                return(false);
            }

            CmpEq a = (CmpEq)one;

            try
            {
                if (isNumeric(one, two))
                {
                    NumericType numeric = (NumericType)one;
                    if (numeric.eq(two, context))
                    {
                        return(true);
                    }
                    else
                    {
                        XSString value1 = new XSString(one.StringValue);
                        if (value1.eq(two, context))
                        {
                            return(true);
                        }
                    }
                }

                if (a.eq(two, context))
                {
                    return(true);
                }

                if (needsStringComparison(one, two))
                {
                    XSString xstr1 = new XSString(one.StringValue);
                    XSString xstr2 = new XSString(two.StringValue);
                    if (FnCompare.compare_string(collationURI, xstr1, xstr2, context).Equals(System.Numerics.BigInteger.Zero))
                    {
                        return(true);
                    }
                }
                return(false);
            }
            catch (DynamicError)
            {
                return(false);                // XXX ???
            }
        }
示例#3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected static boolean hasValue(org.eclipse.wst.xml.xpath2.api.ResultBuffer rs, org.eclipse.wst.xml.xpath2.processor.internal.types.AnyAtomicType item, org.eclipse.wst.xml.xpath2.api.DynamicContext context, String collationURI) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        protected internal static bool hasValue(ResultBuffer rs, AnyAtomicType item, DynamicContext context, string collationURI)
        {
            XSString itemStr = new XSString(item.StringValue);

            for (IEnumerator i = rs.iterator(); i.MoveNext();)
            {
                AnyType at = (AnyType)i.Current;

                if (!(at is CmpEq))
                {
                    continue;
                }

                if (isBoolean(item, at))
                {
                    XSBoolean boolat = (XSBoolean)at;
                    if (boolat.eq(item, context))
                    {
                        return(true);
                    }
                }

                if (isNumeric(item, at))
                {
                    NumericType numericat = (NumericType)at;
                    if (numericat.eq(item, context))
                    {
                        return(true);
                    }
                }

                if (isDuration(item, at))
                {
                    XSDuration durat = (XSDuration)at;
                    if (durat.eq(item, context))
                    {
                        return(true);
                    }
                }

                if (needsStringComparison(item, at))
                {
                    XSString xstr1 = new XSString(at.StringValue);
                    if (FnCompare.compare_string(collationURI, xstr1, itemStr, context).Equals(System.Numerics.BigInteger.Zero))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
示例#4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected static boolean hasValue(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType itema, org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType itemb, org.eclipse.wst.xml.xpath2.api.DynamicContext context, String collationURI) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        protected internal static bool hasValue(AnyType itema, AnyType itemb, DynamicContext context, string collationURI)
        {
            XSString itemStr = new XSString(itema.StringValue);

            if (isBoolean(itema, itemb))
            {
                XSBoolean boolat = (XSBoolean)itema;
                if (boolat.eq(itemb, context))
                {
                    return(true);
                }
            }

            if (isNumeric(itema, itemb))
            {
                NumericType numericat = (NumericType)itema;
                if (numericat.eq(itemb, context))
                {
                    return(true);
                }
            }

            if (isDuration(itema, itemb))
            {
                XSDuration durat = (XSDuration)itema;
                if (durat.eq(itemb, context))
                {
                    return(true);
                }
            }

            if (needsStringComparison(itema, itemb))
            {
                XSString xstr1 = new XSString(itema.StringValue);
                if (FnCompare.compare_string(collationURI, xstr1, itemStr, context).Equals(System.Numerics.BigInteger.Zero))
                {
                    return(true);
                }
            }
            return(false);
        }
示例#5
0
        /// <summary>
        /// Index-Of operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <param name="dynamicContext"> </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:index-of operation. </returns>
        public static ResultSequence index_of(ICollection args, DynamicContext dc)
        {
            Function.convert_arguments(args, expected_args());

            // get args
            IEnumerator citer = args.GetEnumerator();

            citer.MoveNext();
            ResultSequence arg1 = (ResultSequence)citer.Current;

            citer.MoveNext();
            ResultSequence arg2 = (ResultSequence)citer.Current;

            if (arg1 == null || arg1.empty())
            {
                return(ResultBuffer.EMPTY);
            }

            // sanity chex
            if (arg2 == null || arg2.size() != 1)
            {
                DynamicError.throw_type_error();
            }

            string collationUri = dc.CollationProvider.DefaultCollation;

            if (citer.MoveNext())
            {
                ResultSequence arg3 = (ResultSequence)citer.Current;
                if (!arg3.empty())
                {
                    XSString collation = (XSString)arg3.first();
                    collationUri = collation.StringValue;
                }
            }

            ResultBuffer  rb = new ResultBuffer();
            AnyAtomicType at = (AnyAtomicType)arg2.first();

            get_comparable(at);

            int index = 1;

            for (var i = arg1.iterator(); i.MoveNext();)
            {
                AnyType cmptype = (AnyType)i.Current;
                get_comparable(cmptype);

                if (!(at is CmpEq))
                {
                    continue;
                }

                if (isBoolean(cmptype, at))
                {
                    XSBoolean boolat = (XSBoolean)cmptype;
                    if (boolat.eq(at, dc))
                    {
                        rb.add(new XSInteger(new System.Numerics.BigInteger(index)));
                    }
                }
                else
                {
                    if (isNumeric(cmptype, at))
                    {
                        NumericType numericat = (NumericType)at;
                        if (numericat.eq(cmptype, dc))
                        {
                            rb.add(new XSInteger(new System.Numerics.BigInteger(index)));
                        }
                    }
                    else
                    {
                        if (isDuration(cmptype, at))
                        {
                            XSDuration durat = (XSDuration)at;
                            if (durat.eq(cmptype, dc))
                            {
                                rb.add(new XSInteger(new System.Numerics.BigInteger(index)));
                            }
                        }
                        else
                        {
                            if (at is QName && cmptype is QName)
                            {
                                QName qname = (QName)at;
                                if (qname.eq(cmptype, dc))
                                {
                                    rb.add(new XSInteger(new System.Numerics.BigInteger(index)));
                                }
                            }
                            else
                            {
                                if (needsStringComparison(cmptype, at))
                                {
                                    XSString xstr1   = new XSString(cmptype.StringValue);
                                    XSString itemStr = new XSString(at.StringValue);
                                    if (FnCompare.compare_string(collationUri, xstr1, itemStr, dc).Equals(System.Numerics.BigInteger.Zero))
                                    {
                                        rb.add(new XSInteger(new System.Numerics.BigInteger(index)));
                                    }
                                }
                            }
                        }
                    }
                }

                index++;
            }

            return(rb.Sequence);
        }