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;
22 private List fElements;
24 public NLSLine(int lineNumber) {
25 fLineNumber= lineNumber;
26 Assert.isTrue(fLineNumber >= 0);
27 fElements= new ArrayList();
30 public int getLineNumber() {
35 * Adds a NLS element to this line.
37 public void add(NLSElement element) {
38 Assert.isNotNull(element);
39 fElements.add(element);
42 public NLSElement[] getElements() {
43 return (NLSElement[]) fElements.toArray(new NLSElement[fElements.size()]);
46 public NLSElement get(int index) {
47 return (NLSElement)fElements.get(index);
50 public boolean exists(int index) {
51 return index >= 0 && index < fElements.size();
55 return fElements.size();
60 * @see Object#toString()
62 public String toString() {
63 StringBuffer result= new StringBuffer();
64 result.append("Line: " + fLineNumber + "\n"); //$NON-NLS-2$ //$NON-NLS-1$
65 for (Iterator iter= fElements.iterator(); iter.hasNext(); ) {
66 result.append("\t"); //$NON-NLS-1$
67 result.append(iter.next().toString());
68 result.append("\n"); //$NON-NLS-1$
70 return result.toString();