1 11 package org.eclipse.jdt.internal.corext.refactoring.nls; 12 13 import java.util.ArrayList ; 14 import java.util.Iterator ; 15 import java.util.List ; 16 17 import org.eclipse.core.runtime.Assert; 18 19 20 public class NLSLine { 21 22 private int fLineNumber; 23 private List fElements; 24 25 public NLSLine(int lineNumber) { 26 fLineNumber= lineNumber; 27 Assert.isTrue(fLineNumber >= 0); 28 fElements= new ArrayList (); 29 } 30 31 public int getLineNumber() { 32 return fLineNumber; 33 } 34 35 38 public void add(NLSElement element) { 39 Assert.isNotNull(element); 40 fElements.add(element); 41 } 42 43 public NLSElement[] getElements() { 44 return (NLSElement[]) fElements.toArray(new NLSElement[fElements.size()]); 45 } 46 47 public NLSElement get(int index) { 48 return (NLSElement)fElements.get(index); 49 } 50 51 public boolean exists(int index) { 52 return index >= 0 && index < fElements.size(); 53 } 54 55 public int size(){ 56 return fElements.size(); 57 } 58 59 63 public String toString() { 64 StringBuffer result= new StringBuffer (); 65 result.append("Line: " + fLineNumber + "\n"); for (Iterator iter= fElements.iterator(); iter.hasNext(); ) { 67 result.append("\t"); result.append(iter.next().toString()); 69 result.append("\n"); } 71 return result.toString(); 72 } 73 } 74 75 | Popular Tags |