KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > lexer > inc > TokenChangeInfo


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.inc;
21
22 import java.util.List JavaDoc;
23 import org.netbeans.api.lexer.TokenChange;
24 import org.netbeans.api.lexer.TokenId;
25 import org.netbeans.lib.lexer.LAState;
26 import org.netbeans.lib.lexer.LexerApiPackageAccessor;
27 import org.netbeans.lib.lexer.TokenList;
28 import org.netbeans.lib.lexer.token.AbstractToken;
29
30 /**
31  * Description of the change in a token list.
32  * <br/>
33  * The change is expressed as a list of removed tokens
34  * plus the current list and index and number of the tokens
35  * added to the current list.
36  *
37  * @author Miloslav Metelka
38  * @version 1.00
39  */

40
41 public final class TokenChangeInfo<T extends TokenId> {
42     
43     private static final TokenChange<? extends TokenId>[] EMPTY_EMBEDDED_CHANGES
44             = (TokenChange<? extends TokenId>[])new TokenChange[0];
45
46     private TokenChange<? extends TokenId>[] embeddedChanges = EMPTY_EMBEDDED_CHANGES;
47     
48     private final TokenList<T> currentTokenList;
49     
50     private RemovedTokenList<T> removedTokenList;
51     
52     private int addedTokenCount;
53
54     private int index;
55
56     private int offset;
57
58
59     public TokenChangeInfo(TokenList<T> currentTokenList) {
60         this.currentTokenList = currentTokenList;
61     }
62
63     public TokenChange<? extends TokenId>[] embeddedChanges() {
64         return embeddedChanges;
65     }
66     
67     public void addEmbeddedChange(TokenChangeInfo<? extends TokenId> change) {
68         TokenChange<? extends TokenId>[] tmp = (TokenChange<? extends TokenId>[])
69                 new TokenChange[embeddedChanges.length + 1];
70         System.arraycopy(embeddedChanges, 0, tmp, 0, embeddedChanges.length);
71         tmp[embeddedChanges.length] = LexerApiPackageAccessor.get().createTokenChange(change);
72         embeddedChanges = tmp;
73     }
74     
75     public int index() {
76         return index;
77     }
78
79     public void setIndex(int index) {
80         this.index = index;
81     }
82     
83     public int offset() {
84         return offset;
85     }
86
87     public void setOffset(int offset) {
88         this.offset = offset;
89     }
90
91     public RemovedTokenList<T> removedTokenList() {
92         return removedTokenList;
93     }
94     
95     public void setRemovedTokenList(RemovedTokenList<T> removedTokenList) {
96         this.removedTokenList = removedTokenList;
97     }
98     
99     public int addedTokenCount() {
100         return addedTokenCount;
101     }
102
103     public void setAddedTokenCount(int addedTokenCount) {
104         this.addedTokenCount = addedTokenCount;
105     }
106     
107     public TokenList<T> currentTokenList() {
108         return currentTokenList;
109     }
110     
111 }
Popular Tags