KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > lexer > demo > handcoded > link > LinkLanguage


1
2 package org.netbeans.modules.lexer.demo.handcoded.link;
3
4 import org.netbeans.api.lexer.Lexer;
5 import org.netbeans.api.lexer.TokenId;
6 import org.netbeans.spi.lexer.AbstractLanguage;
7
8 public class LinkLanguage extends AbstractLanguage {
9
10     /** Lazily initialized singleton instance of this language. */
11     private static LinkLanguage INSTANCE;
12
13     /** @return singleton instance of this language. */
14     public static synchronized LinkLanguage get() {
15         if (INSTANCE == null)
16             INSTANCE = new LinkLanguage();
17
18         return INSTANCE;
19     }
20
21     public static final int TEXT_INT = 1;
22     public static final int HTTP_URI_INT = 2;
23     public static final int FTP_URI_INT = 3;
24     public static final int URI_INT = 4;
25
26
27     public static final TokenId FTP_URI = new TokenId("ftp-uri", FTP_URI_INT, new String JavaDoc[]{"uri"}); // FTP absolute URI
28
public static final TokenId HTTP_URI = new TokenId("http-uri", HTTP_URI_INT, new String JavaDoc[]{"uri"}); // HTTP absolute URI
29
public static final TokenId TEXT = new TokenId("text", TEXT_INT); // Either whole line of text or a part of a line if a link is present on it
30
public static final TokenId URI = new TokenId("uri", URI_INT, new String JavaDoc[]{"uri"}); // Other URI type
31

32     LinkLanguage() {
33     }
34
35     public Lexer createLexer() {
36         return new LinkLexer();
37     }
38
39 }
40
Popular Tags