public void dumpAllDifferences(List list, String baseText, String witnessText) { String str = "\n"; for (Iterator i = list.iterator(); i.hasNext(); ) { Difference difference = (Difference) i.next(); str += difference.dumpContentsTruncated(baseText, witnessText); } Log(str); }
public AnnotationNode(Annotation annotation) { Difference difference = annotation.getDifference(); this.differenceType = difference.getType(); this.baseDocumentID = difference.getBaseDocumentID(); this.witnessDocumentID = difference.getWitnessDocumentID(); this.baseLength = difference.getLength(Difference.BASE, OffsetRange.Space.ORIGINAL); this.witnessLength = difference.getLength(Difference.WITNESS, OffsetRange.Space.ORIGINAL); this.baseOffset = difference.getOffset(Difference.BASE, OffsetRange.Space.ORIGINAL); this.witnessOffset = difference.getOffset(Difference.WITNESS, OffsetRange.Space.ORIGINAL); this.baseSpace = OffsetRange.Space.ORIGINAL; this.witnessSpace = OffsetRange.Space.ORIGINAL; this.notes = annotation.getNotes(); this.includeImage = annotation.includeImage(); this.fromOldVersion = annotation.isFromOldVersion(); }
void getDiffs(Node node) throws ReportedException { int baseIndex = Integer.parseInt(getAttr(node, "base")); int witnessIndex = Integer.parseInt(getAttr(node, "witness")); Log( "<test id=\"" + getAttr(node, "id") + "\" base=\"" + baseIndex + "\" witness=\"" + witnessIndex + "\" >"); LinkedList docs = documentManager.getDocumentList(); JuxtaDocument baseDoc = (JuxtaDocument) docs.get(baseIndex); JuxtaDocument witnessDoc = (JuxtaDocument) docs.get(witnessIndex); String str = ""; Collation collation = comparisonSet.getCollation(baseDoc); List list = collation.getDifferences(witnessDoc); if (list == null) list = new LinkedList(); dumpAllDifferences(list, baseDoc.getDocumentText(), witnessDoc.getDocumentText()); int count = 0; NodeList nlResult = node.getChildNodes(); int numResults = (createXml ? list.size() : nlResult.getLength()); for (int i = 0; i < numResults; ++i) { Node nodeResult = (createXml ? null : nlResult.item(i)); if (createXml || nodeResult.getNodeType() == Node.ELEMENT_NODE && nodeResult.getNodeName().equals("result")) { if (count >= list.size()) { DoAssert("Not enough difference entries returned", -1, list.size()); break; } Difference difference = (Difference) list.get(count); ++count; String strBaseFilename = documentManager.lookupDocument(difference.getBaseDocumentID()).getDocumentName(); String strWitnessFilename = documentManager.lookupDocument(difference.getWitnessDocumentID()).getDocumentName(); int iBaseOfs = difference.getOffset(Difference.BASE); int iBaseLen = difference.getLength(Difference.BASE); int iWitnessOfs = difference.getOffset(Difference.WITNESS); int iWitnessLen = difference.getLength(Difference.WITNESS); str = "\t<result "; str += "basename=\"" + strBaseFilename; str += "\" baseoffset=\"" + Integer.toString(iBaseOfs); str += "\" baselength=\"" + Integer.toString(iBaseLen); str += "\" witnessname=\"" + strWitnessFilename; str += "\" witnessoffset=\"" + Integer.toString(iWitnessOfs); str += "\" witnesslength=\"" + Integer.toString(iWitnessLen); str += "\" type=\"" + Difference.getTypeName(difference.getType()); str += "\" distance=\"" + Integer.toString(difference.getDistance()); str += "\" />"; Log(str); if (!createXml) { DoAssert( "", "", difference.testContents( Difference.getTypeValue(getAttr(nodeResult, "type")), getAttrInt(nodeResult, "baseoffset"), getAttrInt(nodeResult, "baselength"), getAttrInt(nodeResult, "witnessoffset"), getAttrInt(nodeResult, "witnesslength"))); DoAssert("basename", getAttr(nodeResult, "basename"), strBaseFilename); DoAssert("witnessname", getAttr(nodeResult, "witnessname"), strWitnessFilename); DoAssert( "distance", getAttr(nodeResult, "distance"), Integer.toString(difference.getDistance())); } } } DoAssert("count", count, (list == null) ? 0 : list.size()); Log("</test>"); }