RC2 compatibility
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / corext / refactoring / nls / NLSLine.java
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
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.corext.refactoring.nls;
12
13 import java.util.ArrayList;
14 import java.util.Iterator;
15 import java.util.List;
16
17 import org.eclipse.jface.util.Assert;
18
19 public class NLSLine {
20
21         private int fLineNumber;
22         private List fElements;
23
24         public NLSLine(int lineNumber) {
25                 fLineNumber= lineNumber;
26                 Assert.isTrue(fLineNumber >= 0);
27                 fElements= new ArrayList();
28         }
29         
30         public int getLineNumber() {
31                 return fLineNumber;
32         }
33         
34         /**
35          * Adds a NLS element to this line.
36          */
37         public void add(NLSElement element) {
38                 Assert.isNotNull(element);
39                 fElements.add(element);
40         }
41         
42         public NLSElement[] getElements() {
43                 return (NLSElement[]) fElements.toArray(new NLSElement[fElements.size()]);
44         }
45         
46         public NLSElement get(int index) {
47                 return (NLSElement)fElements.get(index);
48         }
49         
50         public boolean exists(int index) {
51                 return index >= 0 && index < fElements.size();
52         }
53         
54         public int size(){
55                 return fElements.size();
56         }
57         
58         /* non javaDoc
59          * only for debugging
60          * @see Object#toString()
61          */
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$
69                 }
70                 return result.toString();
71         }
72 }
73