replace deprecated org.eclipse.jface.text.Assert with org.eclipse.core.runtime.Assert
[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 //incastrix
18 //import org.eclipse.jface.text.Assert;
19 import org.eclipse.core.runtime.Assert;
20
21 public class NLSLine {
22
23         private int fLineNumber;
24
25         private List fElements;
26
27         public NLSLine(int lineNumber) {
28                 fLineNumber = lineNumber;
29                 Assert.isTrue(fLineNumber >= 0);
30                 fElements = new ArrayList();
31         }
32
33         public int getLineNumber() {
34                 return fLineNumber;
35         }
36
37         /**
38          * Adds a NLS element to this line.
39          */
40         public void add(NLSElement element) {
41                 Assert.isNotNull(element);
42                 fElements.add(element);
43         }
44
45         public NLSElement[] getElements() {
46                 return (NLSElement[]) fElements
47                                 .toArray(new NLSElement[fElements.size()]);
48         }
49
50         public NLSElement get(int index) {
51                 return (NLSElement) fElements.get(index);
52         }
53
54         public boolean exists(int index) {
55                 return index >= 0 && index < fElements.size();
56         }
57
58         public int size() {
59                 return fElements.size();
60         }
61
62         /*
63          * non javaDoc only for debugging
64          * 
65          * @see Object#toString()
66          */
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$
74                 }
75                 return result.toString();
76         }
77 }