KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > lexer > LexerSpiPackageAccessor


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.lib.lexer;
21
22 import java.util.Collection JavaDoc;
23 import java.util.Map JavaDoc;
24 import org.netbeans.api.lexer.LanguagePath;
25 import org.netbeans.api.lexer.InputAttributes;
26 import org.netbeans.api.lexer.Language;
27 import org.netbeans.api.lexer.Token;
28 import org.netbeans.api.lexer.TokenId;
29 import org.netbeans.spi.lexer.CharPreprocessor;
30 import org.netbeans.spi.lexer.LanguageEmbedding;
31 import org.netbeans.spi.lexer.LanguageHierarchy;
32 import org.netbeans.spi.lexer.Lexer;
33 import org.netbeans.spi.lexer.LexerInput;
34 import org.netbeans.spi.lexer.LexerRestartInfo;
35 import org.netbeans.spi.lexer.MutableTextInput;
36 import org.netbeans.spi.lexer.TokenFactory;
37 import org.netbeans.spi.lexer.TokenValidator;
38
39 /**
40  * Accessor for the package-private functionality in org.netbeans.api.editor.fold.
41  *
42  * @author Miloslav Metelka
43  * @version 1.00
44  */

45
46 public abstract class LexerSpiPackageAccessor {
47     
48     private static LexerSpiPackageAccessor INSTANCE;
49     
50     public static LexerSpiPackageAccessor get() {
51         return INSTANCE;
52     }
53
54     /**
55      * Register the accessor. The method can only be called once
56      * - othewise it throws IllegalStateException.
57      *
58      * @param accessor instance.
59      */

60     public static void register(LexerSpiPackageAccessor accessor) {
61         if (INSTANCE != null) {
62             throw new IllegalStateException JavaDoc("Already registered"); // NOI18N
63
}
64         INSTANCE = accessor;
65     }
66
67     public abstract <T extends TokenId> Collection JavaDoc<T> createTokenIds(LanguageHierarchy<T> languageHierarchy);
68
69     public abstract <T extends TokenId> Map JavaDoc<String JavaDoc,Collection JavaDoc<T>> createTokenCategories(LanguageHierarchy<T> languageHierarchy);
70     
71     public abstract <T extends TokenId> Lexer<T> createLexer(LanguageHierarchy<T> languageHierarchy, LexerRestartInfo<T> info);
72     
73     public abstract <T extends TokenId> LexerRestartInfo<T> createLexerRestartInfo(
74     LexerInput input, TokenFactory<T> tokenFactory, Object JavaDoc state,
75     LanguagePath languagePath, InputAttributes inputAttributes);
76     
77     public abstract String JavaDoc mimeType(LanguageHierarchy<? extends TokenId> languageHierarchy);
78     
79     public abstract <T extends TokenId> LanguageEmbedding<? extends TokenId> embedding(
80     LanguageHierarchy<T> languageHierarchy, Token<T> token,
81     LanguagePath languagePath, InputAttributes inputAttributes);
82     
83     public abstract <T extends TokenId> TokenValidator<T> createTokenValidator(LanguageHierarchy<T> languageHierarchy, T id);
84
85     public abstract CharPreprocessor createCharPreprocessor(LanguageHierarchy<? extends TokenId> languageHierarchy);
86
87     public abstract <T extends TokenId> boolean isRetainTokenText(LanguageHierarchy<T> languageHierarchy, T id);
88
89     public abstract <T extends TokenId> LanguageOperation<T> operation(LanguageHierarchy<T> languageHierarchy);
90     
91 public abstract LexerInput createLexerInput(CharProvider charProvider);
92     
93     public abstract void init(CharPreprocessor preprocessor, CharPreprocessorOperation operation);
94     
95     public abstract void preprocessChar(CharPreprocessor preprocessor);
96     
97     public abstract Language<? extends TokenId> language(MutableTextInput<?> mti);
98     
99     public abstract <T extends TokenId> LanguageEmbedding<T> createLanguageEmbedding(
100     Language<T> language, int startSkipLength, int endSkipLength, boolean joinSections);
101
102     public abstract CharSequence JavaDoc text(MutableTextInput<?> mti);
103     
104     public abstract InputAttributes inputAttributes(MutableTextInput<?> mti);
105     
106     public abstract <I> I inputSource(MutableTextInput<I> mti);
107     
108     public abstract <T extends TokenId> TokenFactory<T> createTokenFactory(LexerInputOperation<T> lexerInputOperation);
109     
110 }
111
Popular Tags