KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > spi > lexer > LexerRestartInfo


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.spi.lexer;
21
22 import org.netbeans.api.lexer.InputAttributes;
23 import org.netbeans.api.lexer.LanguagePath;
24 import org.netbeans.api.lexer.TokenId;
25
26 /**
27  * Lexer restart info contains all the necessary information for restarting
28  * of a lexer mainly the lexer input, state and token factory.
29  *
30  * @author Miloslav Metelka
31  * @since
32  */

33
34 public final class LexerRestartInfo<T extends TokenId> {
35
36     private final LexerInput input;
37     
38     private final TokenFactory<T> tokenFactory;
39     
40     private final Object JavaDoc state;
41     
42     private final LanguagePath languagePath;
43     
44     private final InputAttributes inputAttributes;
45     
46     LexerRestartInfo(LexerInput input,
47     TokenFactory<T> tokenFactory, Object JavaDoc state,
48     LanguagePath languagePath, InputAttributes inputAttributes) {
49         this.input = input;
50         this.tokenFactory = tokenFactory;
51         this.state = state;
52         this.languagePath = languagePath;
53         this.inputAttributes = inputAttributes;
54     }
55     
56     public LexerInput input() {
57         return input;
58     }
59
60     public TokenFactory<T> tokenFactory() {
61         return tokenFactory;
62     }
63     
64     public Object JavaDoc state() {
65         return state;
66     }
67     
68     public LanguagePath languagePath() {
69         return languagePath;
70     }
71     
72     public InputAttributes inputAttributes() {
73         return inputAttributes;
74     }
75     
76     public Object JavaDoc getAttributeValue(Object JavaDoc key) {
77         return (inputAttributes != null)
78                 ? inputAttributes.getValue(languagePath, key)
79                 : null;
80     }
81
82 }
83
Popular Tags