1 package org.enhydra.xml.driver.diff; 2 3 import java.util.Enumeration ; 4 import java.util.Vector ; 5 6 10 public class HunkAdd extends Hunk{ 11 12 int ld1; 13 int ld2; 14 int lf2; 15 16 Vector b=new Vector (); 17 18 public void accept(HunkVisitor visitor) { 19 visitor.visitHunkAdd(this); 20 } 21 22 23 26 public String getNewContents(){ 27 String s=new String (); 28 for (Enumeration e = b.elements() ; e.hasMoreElements() ;) 29 s=s.concat((String )e.nextElement()); 30 return s; 31 } 32 33 37 public String convert(){ 38 String s=new String (+ld1+"a"+ld2); 39 if(ld2!=lf2) 40 s=s.concat(","+lf2); 41 s=s.concat("\n"); 42 for (Enumeration e = b.elements() ; e.hasMoreElements() ;) 43 s=s.concat("> "+(String )e.nextElement()); 44 return s; 45 } 46 47 51 public String convert_ED(){ 52 String s=new String (+ld1+"a\n"); 53 for (Enumeration e = b.elements() ; e.hasMoreElements() ;) 54 s=s.concat((String )e.nextElement()); 55 s=s.concat(".\n"); 56 return s; 57 } 58 59 63 public String convert_RCS(){ 64 String s=new String ("a"+ld1+" "+(lf2-ld2+1)+"\n"); 65 for (Enumeration e = b.elements() ; e.hasMoreElements() ;) 66 s=s.concat((String )e.nextElement()); 67 return s; 68 } 69 70 76 public int lowLine(int filenum){ 77 if(filenum==0) 78 return ld1; 79 else 80 return ld2; 81 } 82 83 89 public int highLine(int filenum){ 90 if(filenum==0) 91 return ld1; 92 else 93 return lf2; 94 } 95 96 102 public int numLines(int filenum){ 103 if(filenum==0) 104 return 1; 105 else 106 return(lf2 - ld2 + 1); 107 } 108 109 116 public String relNum(int filenum,int linenum){ 117 if(filenum==0) 118 return null; 119 else 120 return (String )b.elementAt(linenum); 121 } 122 123 } 124 | Popular Tags |