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;
18 //import org.eclipse.jface.text.Assert;
19 import org.eclipse.core.runtime.Assert;
21 public class NLSLine {
23 private int fLineNumber;
25 private List fElements;
27 public NLSLine(int lineNumber) {
28 fLineNumber = lineNumber;
29 Assert.isTrue(fLineNumber >= 0);
30 fElements = new ArrayList();
33 public int getLineNumber() {
38 * Adds a NLS element to this line.
40 public void add(NLSElement element) {
41 Assert.isNotNull(element);
42 fElements.add(element);
45 public NLSElement[] getElements() {
46 return (NLSElement[]) fElements
47 .toArray(new NLSElement[fElements.size()]);
50 public NLSElement get(int index) {
51 return (NLSElement) fElements.get(index);
54 public boolean exists(int index) {
55 return index >= 0 && index < fElements.size();
59 return fElements.size();
63 * non javaDoc only for debugging
65 * @see Object#toString()
67 public String toString() {
68 StringBuffer result = new StringBuffer();
69 result.append("Line: " + fLineNumber + "\n"); //$NON-NLS-2$ //$NON-NLS-1$
70 for (Iterator iter = fElements.iterator(); iter.hasNext();) {
71 result.append("\t"); //$NON-NLS-1$
72 result.append(iter.next().toString());
73 result.append("\n"); //$NON-NLS-1$
75 return result.toString();