1 11 package org.eclipse.compare.internal.merge; 12 13 import java.io.*; 14 import java.util.ArrayList ; 15 import org.eclipse.compare.rangedifferencer.IRangeComparator; 16 17 20 class LineComparator implements IRangeComparator { 21 22 private String [] fLines; 23 24 public LineComparator(InputStream is, String encoding) throws UnsupportedEncodingException { 25 26 BufferedReader br = new BufferedReader(new InputStreamReader(is, encoding)); 27 String line; 28 ArrayList ar = new ArrayList (); 29 try { 30 while ((line = br.readLine()) != null) 31 ar.add(line); 32 } catch (IOException e) { 33 } 35 fLines = (String []) ar.toArray(new String [ar.size()]); 40 } 41 42 String getLine(int ix) { 43 return fLines[ix]; 44 } 45 46 49 public int getRangeCount() { 50 return fLines.length; 51 } 52 53 56 public boolean rangesEqual(int thisIndex, IRangeComparator other, 57 int otherIndex) { 58 String s1 = fLines[thisIndex]; 59 String s2 = ((LineComparator) other).fLines[otherIndex]; 60 return s1.equals(s2); 61 } 62 63 66 public boolean skipRangeComparison(int length, int maxLength, IRangeComparator other) { 67 return false; 68 } 69 } 70 | Popular Tags |