1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 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 net.sourceforge.phpdt.corext.refactoring.nls;
13 import java.util.ArrayList;
14 import java.util.Iterator;
15 import java.util.List;
17 import org.eclipse.jface.util.Assert;
19 public class NLSLine {
21 private int fLineNumber;
23 private List fElements;
25 public NLSLine(int lineNumber) {
26 fLineNumber = lineNumber;
27 Assert.isTrue(fLineNumber >= 0);
28 fElements = new ArrayList();
31 public int getLineNumber() {
36 * Adds a NLS element to this line.
38 public void add(NLSElement element) {
39 Assert.isNotNull(element);
40 fElements.add(element);
43 public NLSElement[] getElements() {
44 return (NLSElement[]) fElements
45 .toArray(new NLSElement[fElements.size()]);
48 public NLSElement get(int index) {
49 return (NLSElement) fElements.get(index);
52 public boolean exists(int index) {
53 return index >= 0 && index < fElements.size();
57 return fElements.size();
61 * non javaDoc only for debugging
63 * @see Object#toString()
65 public String toString() {
66 StringBuffer result = new StringBuffer();
67 result.append("Line: " + fLineNumber + "\n"); //$NON-NLS-2$ //$NON-NLS-1$
68 for (Iterator iter = fElements.iterator(); iter.hasNext();) {
69 result.append("\t"); //$NON-NLS-1$
70 result.append(iter.next().toString());
71 result.append("\n"); //$NON-NLS-1$
73 return result.toString();