Beispiel #1
0
        /**
         * Returns the length of a matching string starting at the
         * specified position. The number of matches to skip can also
         * be specified, but numbers higher than zero (0) cause a
         * failed match for any element that doesn't attempt to
         * combine other elements.
         *
         * @param m              the matcher being used
         * @param buffer         the input character buffer to match
         * @param start          the starting position
         * @param skip           the number of matches to skip
         *
         * @return the length of the longest matching string, or
         *         -1 if no match was found
         *
         * @throws IOException if an I/O error occurred
         */
        public override int Match(Matcher m,
                                  ReaderBuffer buffer,
                                  int start,
                                  int skip)
        {
            int c;

            if (skip != 0)
            {
                return(-1);
            }
            for (int i = 0; i < value.Length; i++)
            {
                c = buffer.Peek(start + i);
                if (c < 0)
                {
                    m.SetReadEndOfString();
                    return(-1);
                }
                if (m.IsCaseInsensitive())
                {
                    c = (int)Char.ToLower((char)c);
                }
                if (c != (int)value[i])
                {
                    return(-1);
                }
            }
            return(value.Length);
        }
        /// <summary>
        /// Returns the length of a matching string starting at the
        /// specified position.The number of matches to skip can also be
        /// specified, but numbers higher than zero (0) cause a failed
        /// match for any element that doesn't attempt to combine other
        /// elements.
        /// </summary>
        /// <param name="m">the matcher being used</param>
        /// <param name="buffer">the input character buffer to match</param>
        /// <param name="start">The starting position</param>
        /// <param name="skip">the number of matches to skip</param>
        /// <returns>
        /// the length of the matching string, or -1 if no match was found
        /// </returns>
        public override int Match(
            Matcher m,
            ReaderBuffer buffer,
            int start,
            int skip)
        {
            int c;

            if (skip != 0)
            {
                return(-1);
            }

            c = buffer.Peek(start);
            if (c < 0)
            {
                m.SetReadEndOfString();
                return(-1);
            }

            if (m.IsCaseInsensitive)
            {
                c = (int)char.ToLower((char)c);
            }

            return(this.InSet((char)c) ? 1 : -1);
        }
        /**
         * Returns the length of a matching string starting at the
         * specified position. The number of matches to skip can also be
         * specified, but numbers higher than zero (0) cause a failed
         * match for any element that doesn't attempt to combine other
         * elements.
         *
         * @param m              the matcher being used
         * @param buffer         the input character buffer to match
         * @param start          the starting position
         * @param skip           the number of matches to skip
         *
         * @return the length of the matching string, or
         *         -1 if no match was found
         *
         * @throws IOException if an I/O error occurred
         */
        public override int Match(Matcher m,
                                  ReaderBuffer buffer,
                                  int start,
                                  int skip) {

            int  c;

            if (skip != 0) {
                return -1;
            }
            c = buffer.Peek(start);
            if (c < 0) {
                m.SetReadEndOfString();
                return -1;
            }
            if (m.IsCaseInsensitive()) {
                c = (int) Char.ToLower((char) c);
            }
            return InSet((char) c) ? 1 : -1;
        }
Beispiel #4
0
        /**
         * Returns the length of a matching string starting at the
         * specified position. The number of matches to skip can also
         * be specified, but numbers higher than zero (0) cause a
         * failed match for any element that doesn't attempt to
         * combine other elements.
         *
         * @param m              the matcher being used
         * @param buffer         the input character buffer to match
         * @param start          the starting position
         * @param skip           the number of matches to skip
         *
         * @return the length of the longest matching string, or
         *         -1 if no match was found
         *
         * @throws IOException if an I/O error occurred
         */
        public override int Match(Matcher m,
                                  ReaderBuffer buffer,
                                  int start,
                                  int skip) {

            int  c;

            if (skip != 0) {
                return -1;
            }
            for (int i = 0; i < value.Length; i++) {
                c = buffer.Peek(start + i);
                if (c < 0) {
                    m.SetReadEndOfString();
                    return -1;
                }
                if (m.IsCaseInsensitive()) {
                    c = (int) Char.ToLower((char) c);
                }
                if (c != (int) value[i]) {
                    return -1;
                }
            }
            return value.Length;
        }