1 57 58 package org.apache.commons.jrcs.diff.myers; 59 60 70 public abstract class PathNode 71 { 72 73 public final int i; 74 75 public final int j; 76 77 public final PathNode prev; 78 79 85 public PathNode(int i, int j, PathNode prev) 86 { 87 this.i = i; 88 this.j = j; 89 this.prev = prev; 90 } 91 92 96 public abstract boolean isSnake(); 97 98 105 public boolean isBootstrap() 106 { 107 return i < 0 || j < 0; 108 } 109 110 118 public final PathNode previousSnake() 119 { 120 if (isBootstrap()) 121 return null; 122 if (!isSnake() && prev != null) 123 return prev.previousSnake(); 124 return this; 125 } 126 127 130 public String toString() 131 { 132 StringBuffer buf = new StringBuffer ("["); 133 PathNode node = this; 134 while (node != null) 135 { 136 buf.append("("); 137 buf.append(Integer.toString(node.i)); 138 buf.append(","); 139 buf.append(Integer.toString(node.j)); 140 buf.append(")"); 141 node = node.prev; 142 } 143 buf.append("]"); 144 return buf.toString(); 145 } 146 } | Popular Tags |