1 57 58 package org.apache.commons.jrcs.diff; 59 60 import java.util.List ; 61 62 71 public class ChangeDelta extends Delta 72 { 73 74 ChangeDelta() 75 { 76 super(); 77 } 78 79 public ChangeDelta(Chunk orig, Chunk rev) 80 { 81 init(orig, rev); 82 } 83 84 public void verify(List target) throws PatchFailedException 85 { 86 if (!original.verify(target)) 87 { 88 throw new PatchFailedException(); 89 } 90 if (original.first() > target.size()) 91 { 92 throw new PatchFailedException("original.first() > target.size()"); 93 } 94 } 95 96 public void applyTo(List target) 97 { 98 original.applyDelete(target); 99 revised.applyAdd(original.first(), target); 100 } 101 102 public void toString(StringBuffer s) 103 { 104 original.rangeString(s); 105 s.append("c"); 106 revised.rangeString(s); 107 s.append(Diff.NL); 108 original.toString(s, "< ", "\n"); 109 s.append("---"); 110 s.append(Diff.NL); 111 revised.toString(s, "> ", "\n"); 112 } 113 114 117 public void toRCSString(StringBuffer s, String EOL) 118 { 119 s.append("d"); 120 s.append(original.rcsfrom()); 121 s.append(" "); 122 s.append(original.size()); 123 s.append(EOL); 124 s.append("a"); 125 s.append(original.rcsto()); 126 s.append(" "); 127 s.append(revised.size()); 128 s.append(EOL); 129 revised.toString(s, "", EOL); 130 } 131 132 public void accept(RevisionVisitor visitor) 133 { 134 visitor.visit(this); 135 } 136 } 137 138 | Popular Tags |