KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > text > XMLTagRule


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.editor.text;
12
13 import org.eclipse.jface.text.rules.ICharacterScanner;
14 import org.eclipse.jface.text.rules.IToken;
15 import org.eclipse.jface.text.rules.MultiLineRule;
16
17 public class XMLTagRule extends MultiLineRule {
18
19     public XMLTagRule(IToken token) {
20         super("<", ">", token); //$NON-NLS-1$ //$NON-NLS-2$
21
}
22
23     protected boolean sequenceDetected(ICharacterScanner scanner, char[] sequence,
24             boolean eofAllowed) {
25         int c = scanner.read();
26         if (sequence[0] == '<') {
27             if (c == '?') {
28                 // processing instruction - abort
29
scanner.unread();
30                 return false;
31             }
32             if (c == '!') {
33                 scanner.unread();
34                 // comment - abort
35
return false;
36             }
37         } else if (sequence[0] == '>') {
38             scanner.unread();
39         }
40
41         return super.sequenceDetected(scanner, sequence, eofAllowed);
42     }
43 }
44
Popular Tags