You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2010/02/12 20:00:15 UTC
svn commit: r909561 - in /subversion/trunk/subversion/bindings/javahl:
src/org/apache/subversion/javahl/BlameCallbackImpl.java
tests/org/apache/subversion/javahl/BasicTests.java
Author: hwright
Date: Fri Feb 12 19:00:15 2010
New Revision: 909561
URL: http://svn.apache.org/viewvc?rev=909561&view=rev
Log:
JavaHL: Remove a class which doesn't really belong in the public package.
Instead, make it a part of the testsuite, which actually uses it.
[ subversion/bindings/javahl/ ]
* tests/org/apache/subversion/javahl/BasicTests.java
(BlameCallbackImpl): Copied from...
* src/org/apache/subversion/javahl/BlameCallbackImpl.java:
...here.
Removed:
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/BlameCallbackImpl.java
Modified:
subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
Modified: subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java?rev=909561&r1=909560&r2=909561&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java (original)
+++ subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java Fri Feb 12 19:00:15 2010
@@ -3817,4 +3817,217 @@
}
return sb.toString().getBytes();
}
+
+
+ /* A blame callback implementation. */
+ protected class BlameCallbackImpl implements BlameCallback
+ {
+
+ /** list of blame records (lines) */
+ private List lines = new ArrayList();
+
+ public void singleLine(Date changed, long revision, String author,
+ String line)
+ {
+ addBlameLine(new BlameLine(revision, author, changed, line));
+ }
+
+ public void singleLine(Date date, long revision, String author,
+ Date merged_date, long merged_revision,
+ String merged_author, String merged_path,
+ String line)
+ {
+ addBlameLine(new BlameLine(getRevision(revision, merged_revision),
+ getAuthor(author, merged_author),
+ getDate(date, merged_date),
+ line));
+ }
+
+ public void singleLine(long lineNum, long rev, Map revProps,
+ long mergedRevision, Map mergedRevProps,
+ String mergedPath, String line,
+ boolean localChange)
+ throws ClientException
+ {
+ DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
+
+ try {
+ singleLine(
+ df.parse((String) revProps.get("svn:date")),
+ rev,
+ (String) revProps.get("svn:author"),
+ mergedRevProps == null ? null
+ : df.parse((String) mergedRevProps.get("svn:date")),
+ mergedRevision,
+ mergedRevProps == null ? null
+ : (String) mergedRevProps.get("svn:author"),
+ mergedPath, line);
+ } catch (ParseException e) {
+ throw ClientException.fromException(e);
+ }
+ }
+
+ private Date getDate(Date date, Date merged_date) {
+ return (merged_date == null ? date : merged_date);
+ }
+
+ private String getAuthor(String author, String merged_author) {
+ return (merged_author == null ? author : merged_author);
+ }
+
+ private long getRevision(long revision, long merged_revision) {
+ return (merged_revision == -1 ? revision : merged_revision);
+ }
+
+ /**
+ * Retrieve the number of line of blame information
+ * @return number of lines of blame information
+ */
+ public int numberOfLines()
+ {
+ return this.lines.size();
+ }
+
+ /**
+ * Retrieve blame information for specified line number
+ * @param i the line number to retrieve blame information about
+ * @return Returns object with blame information for line
+ */
+ public BlameLine getBlameLine(int i)
+ {
+ if (i >= this.lines.size())
+ {
+ return null;
+ }
+ return (BlameLine) this.lines.get(i);
+ }
+
+ /**
+ * Append the given blame info to the list
+ * @param blameLine
+ */
+ protected void addBlameLine(BlameLine blameLine)
+ {
+ this.lines.add(blameLine);
+ }
+
+ /**
+ * Class represeting one line of the lines, i.e. a blame record
+ *
+ */
+ public static class BlameLine
+ {
+
+ private long revision;
+
+ private String author;
+
+ private Date changed;
+
+ private String line;
+
+ /**
+ * Constructor
+ *
+ * @param revision
+ * @param author
+ * @param changed
+ * @param line
+ */
+ public BlameLine(long revision, String author,
+ Date changed, String line)
+ {
+ super();
+ this.revision = revision;
+ this.author = author;
+ this.changed = changed;
+ this.line = line;
+ }
+
+ /**
+ * @return Returns the author.
+ */
+ public String getAuthor()
+ {
+ return author;
+ }
+
+ /**
+ * @return Returns the date changed.
+ */
+ public Date getChanged()
+ {
+ return changed;
+ }
+
+ /**
+ * @return Returns the source line content.
+ */
+ public String getLine()
+ {
+ return line;
+ }
+
+
+ /**
+ * @return Returns the revision.
+ */
+ public long getRevision()
+ {
+ return revision;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer();
+ if (revision > 0)
+ {
+ pad(sb, Long.toString(revision), 6);
+ sb.append(' ');
+ }
+ else
+ {
+ sb.append(" - ");
+ }
+
+ if (author != null)
+ {
+ pad(sb, author, 10);
+ sb.append(" ");
+ }
+ else
+ {
+ sb.append(" - ");
+ }
+
+ sb.append(line);
+
+ return sb.toString();
+ }
+
+ /**
+ * Left pad the input string to a given length, to simulate
+ * printf()-style output. This method appends the output to the
+ * class sb member.
+ * @param sb StringBuffer to append to
+ * @param val the input string
+ * @param len the minimum length to pad to
+ */
+ private void pad(StringBuffer sb, String val, int len)
+ {
+ int padding = len - val.length();
+
+ for (int i = 0; i < padding; i++)
+ {
+ sb.append(' ');
+ }
+
+ sb.append(val);
+ }
+ }
+ }
}