Exemple #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()));
        }
Exemple #2
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);
            }
        }
Exemple #3
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));
        }