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 Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.parser;
13 import java.util.ArrayList;
14 import java.util.Iterator;
15 import java.util.List;
16 import org.eclipse.jdt.internal.compiler.ast.StringLiteral;
18 public class NLSLine {
20 private List elements;
23 this.elements = new ArrayList();
27 * Adds a NLS element to this line.
29 public void add(StringLiteral element) {
30 this.elements.add(element);
34 * returns an Iterator over NLSElements
36 public Iterator iterator() {
37 return this.elements.iterator();
40 public StringLiteral get(int index) {
41 return (StringLiteral) this.elements.get(index);
44 public void set(int index, StringLiteral literal) {
45 this.elements.set(index, literal);
48 public boolean exists(int index) {
49 return index >= 0 && index < this.elements.size();
53 return this.elements.size();
56 public String toString() {
57 StringBuffer result= new StringBuffer();
58 for (Iterator iter= iterator(); iter.hasNext(); ) {
59 result.append("\t"); //$NON-NLS-1$
60 result.append(iter.next().toString());
61 result.append("\n"); //$NON-NLS-1$
63 return result.toString();