1515package org .xmlunit .diff ;
1616
1717import javax .xml .transform .Source ;
18+ import java .util .Iterator ;
1819
1920/**
2021 * The Diff-Object is the result of two comparisons.
@@ -48,6 +49,38 @@ public Diff(Source controlSource, Source testSource,
4849 }
4950 }
5051
52+ /**
53+ * Returns a string representation of this diff
54+ * using internal {@link ComparisonFormatter} or
55+ * {@link DefaultComparisonFormatter} if formatter wasn't set.
56+ * Each comparison result separated by the end of the line.
57+ * @return a string representation of this diff
58+ */
59+ public String fullDescription () {
60+ return fullDescription (formatter );
61+ }
62+
63+ /**
64+ * Returns a string representation of this diff
65+ * using the given {@link ComparisonFormatter}
66+ * @param formatter the {@link ComparisonFormatter} to use
67+ * @return a string representation of this diff
68+ */
69+ public String fullDescription (ComparisonFormatter formatter ) {
70+ if (!hasDifferences ()) {
71+ return "[identical]" ;
72+ }
73+ Iterator <Difference > diffIterator = getDifferences ().iterator ();
74+ StringBuilder result = new StringBuilder ()
75+ .append (diffIterator .next ().getComparison ().toString (formatter ));
76+ String lineSeparator = System .lineSeparator ();
77+ while (diffIterator .hasNext ()) {
78+ result .append (lineSeparator )
79+ .append (diffIterator .next ().getComparison ().toString (formatter ));
80+ }
81+ return result .toString ();
82+ }
83+
5184 /**
5285 * @return true if there was at least one difference.
5386 */
@@ -72,11 +105,25 @@ public Source getTestSource() {
72105 return testSource ;
73106 }
74107
108+ /**
109+ * Returns a string representation of first found difference in this diff
110+ * using internal {@link ComparisonFormatter} or
111+ * {@link DefaultComparisonFormatter} if formatter wasn't set
112+ * @return a string representation of first found difference in this diff
113+ * @see #fullDescription()
114+ */
75115 @ Override
76116 public String toString () {
77117 return toString (formatter );
78118 }
79119
120+ /**
121+ * Returns a string representation of first found difference in this diff
122+ * using the given {@link ComparisonFormatter}
123+ * @param formatter the {@link ComparisonFormatter} to use
124+ * @return a string representation of first found difference in this diff
125+ * @see #fullDescription(ComparisonFormatter)
126+ */
80127 public String toString (ComparisonFormatter formatter ) {
81128 if (!hasDifferences ()) {
82129 return "[identical]" ;
0 commit comments