This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 88623
Collapse All | Expand All

(-)LexerInput.java (+49 lines)
Lines 19-24 Link Here
19
19
20
package org.netbeans.spi.lexer;
20
package org.netbeans.spi.lexer;
21
21
22
import java.lang.Character;
22
import org.netbeans.lib.editor.util.AbstractCharSequence;
23
import org.netbeans.lib.editor.util.AbstractCharSequence;
23
import org.netbeans.lib.lexer.CharProvider;
24
import org.netbeans.lib.lexer.CharProvider;
24
import org.netbeans.lib.lexer.IntegerCache;
25
import org.netbeans.lib.lexer.IntegerCache;
Lines 60-65 Link Here
60
    public static final int EOF = -1;
61
    public static final int EOF = -1;
61
    
62
    
62
    /**
63
    /**
64
     * Indicates successful match in methods
65
     * {@link #match(String)} and
66
     * {@link #matchIgnoreCase(String)}.
67
     */
68
    public static final int MATCH = -2;
69
    
70
    /**
63
     * Character provider to which this lexer input delegates
71
     * Character provider to which this lexer input delegates
64
     * its operation.
72
     * its operation.
65
     */
73
     */
Lines 273-278 Link Here
273
            backup(1);
281
            backup(1);
274
            return false;
282
            return false;
275
        }
283
        }
284
    }
285
    
286
    /**
287
     * Check whether the next characters in the input match the given text.
288
     * <br/>
289
     * The method reads the input characters and compares them to the given
290
     * text. If all the charcters match the text the method returns {@link #MATCH}.
291
     * <br/>
292
     * Otherwise it returns a character that did not
293
     * match the corresponding one in the text. The input stays positioned
294
     * after that returned character.
295
     * <br/>
296
     * The {@link #readLength()} can be called before and after this method
297
     * to find out how many characters this method consumed.
298
     *
299
     * @param text non-null text to be matched.
300
     * @return {# MATCH} if the text was matched successfully or the character
301
     *  that did not matched the corresponding one in the text
302
     *  (it may be #EOF as well).
303
     */
304
    public int match(String text) {
305
        for (int i = 0; i < text.length(); i++) {
306
            int c = read();
307
            if (c != text.charAt(i))
308
                return c;
309
        }
310
        return MATCH;
311
    }
312
    
313
    /**
314
     * Check whether the next characters in the input match the given lower case text
315
     * in a case-insensitive way.
316
     * @see #match(String)
317
     */
318
    public int matchIgnoreCase(String lowerCaseText) {
319
        for (int i = 0; i < lowerCaseText.length(); i++) {
320
            int c = read();
321
            if (c != lowerCaseText.charAt(i) && c != Character.toUpperCase(lowerCaseText.charAt(i)))
322
                return c;
323
        }
324
        return MATCH;
276
    }
325
    }
277
    
326
    
278
    /**
327
    /**

Return to bug 88623