KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > parser > NLSLine


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 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.jdt.internal.compiler.parser;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.Iterator JavaDoc;
15 import java.util.List JavaDoc;
16 import org.eclipse.jdt.internal.compiler.ast.StringLiteral;
17
18 public class NLSLine {
19
20     private List JavaDoc elements;
21
22     public NLSLine() {
23         this.elements = new ArrayList JavaDoc();
24     }
25     
26     /**
27      * Adds a NLS element to this line.
28      */

29     public void add(StringLiteral element) {
30         this.elements.add(element);
31     }
32     
33     /**
34      * returns an Iterator over NLSElements
35      */

36     public Iterator JavaDoc iterator() {
37         return this.elements.iterator();
38     }
39     
40     public StringLiteral get(int index) {
41         return (StringLiteral) this.elements.get(index);
42     }
43     
44     public void set(int index, StringLiteral literal) {
45         this.elements.set(index, literal);
46     }
47     
48     public boolean exists(int index) {
49         return index >= 0 && index < this.elements.size();
50     }
51     
52     public int size(){
53         return this.elements.size();
54     }
55     
56     public String JavaDoc toString() {
57         StringBuffer JavaDoc result= new StringBuffer JavaDoc();
58         for (Iterator JavaDoc iter= iterator(); iter.hasNext(); ) {
59             result.append("\t"); //$NON-NLS-1$
60
result.append(iter.next().toString());
61             result.append("\n"); //$NON-NLS-1$
62
}
63         return result.toString();
64     }
65 }
66
Popular Tags