예제 #1
0
        /// <summary>
        /// Exists operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:exists operation. </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 exists(java.util.Collection args) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence exists(ICollection args)
        {
            Debug.Assert(args.Count == 1);

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

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

            return(XSBoolean.valueOf(!arg1.empty()));
        }
예제 #2
0
        /// <summary>
        /// Not operation.
        /// </summary>
        /// <param name="arg">
        ///            Result from the expressions evaluation. </param>
        /// <returns> Result of fn:note operation. </returns>
        /// <exception cref="DynamicError">  </exception>
        public static ResultSequence fn_not(ResultSequence arg)
        {
            XSBoolean ret = FnBoolean.fn_boolean(arg);

            bool answer = false;

            if (ret.value() == false)
            {
                answer = true;
            }

            return(ResultSequenceFactory.create_new(new XSBoolean(answer)));
        }
예제 #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
        /// <summary>
        /// Matches operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:matches operation. </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 matches(java.util.Collection args) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence matches(ICollection args)
        {
            ICollection cargs = Function.convert_arguments(args, expected_args());

            // get args
            IEnumerator argiter = cargs.GetEnumerator();

            argiter.MoveNext();
            ResultSequence arg1 = (ResultSequence)argiter.Current;
            string         str1 = "";

            if (!arg1.empty())
            {
                str1 = ((XSString)arg1.first()).value();
            }

            argiter.MoveNext();
            ResultSequence arg2    = (ResultSequence)argiter.Current;
            string         pattern = ((XSString)arg2.first()).value();
            string         flags   = null;

            if (argiter.MoveNext())
            {
                ResultSequence flagRS = null;
                flagRS = (ResultSequence)argiter.Current;
                flags  = flagRS.first().StringValue;
                if (validflags.IndexOf(flags, StringComparison.Ordinal) == -1 && flags.Length > 0)
                {
                    throw DynamicError.regex_flags_error(null);
                }
            }

            try
            {
                bool result = false;
                result = matches(pattern, flags, str1);
                return(XSBoolean.valueOf(result));
            }
            catch (Exception pex)
            {
                throw DynamicError.regex_error(pex.Message);
            }
        }
예제 #5
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);
        }
예제 #6
0
        /// <summary>
        /// Contains operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:contains operation. </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 contains(java.util.Collection args) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence contains(ICollection args)
        {
            ICollection cargs = Function.convert_arguments(args, expected_args());

            // get args
            IEnumerator argiter = cargs.GetEnumerator();

            argiter.MoveNext();
            ResultSequence arg1 = (ResultSequence)argiter.Current;
            string         str1 = "";
            string         str2 = "";

            if (!(arg1 == null || arg1.empty()))
            {
                str1 = ((XSString)arg1.first()).value();
            }

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

            if (!(arg2 == null || arg2.empty()))
            {
                str2 = ((XSString)arg2.first()).value();
            }

            int str1len = str1.Length;
            int str2len = str2.Length;

            if (str2len == 0)
            {
                return(XSBoolean.TRUE);
            }

            if (str1len == 0)
            {
                return(XSBoolean.FALSE);
            }

            return(XSBoolean.valueOf(str1.IndexOf(str2, StringComparison.Ordinal) != -1));
        }
예제 #7
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);
        }