1 package org.enhydra.xml.driver.diff; 2 3 import java.util.Enumeration ; 4 import java.util.Vector ; 5 6 10 public class HunkChange extends Hunk{ 11 12 int ld1; 13 int lf1; 14 int ld2; 15 int lf2; 16 17 Vector a=new Vector (); 18 Vector b=new Vector (); 19 20 21 public void accept(HunkVisitor visitor) { 22 visitor.visitHunkChange(this); 23 } 24 25 26 29 public String getNewContents(){ 30 String s=new String (); 31 for (Enumeration e = b.elements() ; e.hasMoreElements() ;) 32 s=s.concat((String )e.nextElement()); 33 return s; 34 } 35 36 40 public String convert(){ 41 String s=new String (Integer.toString(ld1)); 42 if(ld1!=lf1) 43 s=s.concat(","+lf1); 44 s=s.concat("c"+ld2); 45 if(ld2!=lf2) 46 s=s.concat(","+lf2); 47 s=s.concat("\n"); 48 for (Enumeration e = a.elements() ; e.hasMoreElements() ;) 49 s=s.concat("< "+(String )e.nextElement()); 50 s=s.concat("---\n"); 51 for (Enumeration e = b.elements() ; e.hasMoreElements() ;) 52 s=s.concat("> "+(String )e.nextElement()); 53 return s; 54 } 55 56 60 public String convert_ED(){ 61 String s=new String (Integer.toString(ld1)); 62 if(ld1!=lf1) 63 s=s.concat(","+lf1); 64 s=s.concat("c\n"); 65 for (Enumeration e = b.elements() ; e.hasMoreElements() ;) 66 s=s.concat((String )e.nextElement()); 67 s=s.concat(".\n"); 68 return s; 69 } 70 71 75 public String convert_RCS(){ 76 String s=new String ("d"+ld1+" "+(lf1-ld1+1)+"\n"); 77 s=s.concat("a"+lf1+" "+(lf2-ld2+1)+"\n"); 78 for (Enumeration e = b.elements() ; e.hasMoreElements() ;) 79 s=s.concat((String )e.nextElement()); 80 return s; 81 } 82 83 89 public int lowLine(int filenum){ 90 if(filenum==0) 91 return ld1; 92 else 93 return ld2; 94 } 95 96 102 public int highLine(int filenum){ 103 if(filenum==0) 104 return lf1; 105 else 106 return lf2; 107 } 108 109 115 public int numLines(int filenum){ 116 if(filenum==0) 117 return (lf1 - ld1 +1); 118 else 119 return(lf2 - ld2 + 1); 120 } 121 122 129 public String relNum(int filenum,int linenum){ 130 if(filenum==0) 131 return (String )a.elementAt(linenum); 132 else 133 return (String )b.elementAt(linenum); 134 } 135 136 } 137 | Popular Tags |