You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2008/11/30 09:13:23 UTC
svn commit: r721783 - in
/geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer:
TransferListenerSupport.java monitor/ProgressSpinnerMonitor.java
monitor/SimpleMonitor.java
Author: jdillon
Date: Sun Nov 30 00:13:23 2008
New Revision: 721783
URL: http://svn.apache.org/viewvc?rev=721783&view=rev
Log:
More helper methods
Modified:
geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/TransferListenerSupport.java
geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/ProgressSpinnerMonitor.java
geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/SimpleMonitor.java
Modified: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/TransferListenerSupport.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/TransferListenerSupport.java?rev=721783&r1=721782&r2=721783&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/TransferListenerSupport.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/TransferListenerSupport.java Sun Nov 30 00:13:23 2008
@@ -59,4 +59,22 @@
return event.getRequestType() == TransferEvent.RequestType.UPLOAD ? "Uploaded" : "Downloaded";
}
+
+ protected String renderProgressBytes(final long length, final long total) {
+ if (total > 1024) {
+ return length / 1024 + "/" + (total == TransferEvent.UNKNOWN_LENGTH ? "?" : total / 1024 + "K");
+ }
+ else {
+ return length + "/" + (total == TransferEvent.UNKNOWN_LENGTH ? "?" : total + "b");
+ }
+ }
+
+ protected String renderBytes(final long length) {
+ if (length > 1024) {
+ return length / 1024 + "K";
+ }
+ else {
+ return length + "b";
+ }
+ }
}
\ No newline at end of file
Modified: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/ProgressSpinnerMonitor.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/ProgressSpinnerMonitor.java?rev=721783&r1=721782&r2=721783&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/ProgressSpinnerMonitor.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/ProgressSpinnerMonitor.java Sun Nov 30 00:13:23 2008
@@ -73,7 +73,6 @@
String type = renderRequestType(event);
String location = event.getLocation();
-
String message = type + ": " + location;
println(message);
@@ -87,16 +86,8 @@
long total = event.getContentLength();
complete += event.getLength();
- String message;
-
- if (total >= 1024) {
- message = complete / 1024 + "/" + (total == TransferEvent.UNKNOWN_LENGTH ? "?" : total / 1024 + "K");
- }
- else {
- message = complete + "/" + (total == TransferEvent.UNKNOWN_LENGTH ? "?" : total + "b");
- }
+ String message = renderProgressBytes(complete, total);
-
print(spinner.spin(message));
}
@@ -107,7 +98,7 @@
long total = event.getContentLength();
String type = renderRequestTypeFinished(event);
- String bytes = total >= 1024 ? ( total / 1024 ) + "K" : total + "b";
+ String bytes = renderBytes(total);
// HACK: pad at end just incase, should really blank the reset of the line
print(type + " " + bytes + " ");
Modified: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/SimpleMonitor.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/SimpleMonitor.java?rev=721783&r1=721782&r2=721783&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/SimpleMonitor.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/SimpleMonitor.java Sun Nov 30 00:13:23 2008
@@ -53,14 +53,7 @@
super.transferStarted(event);
- String type = renderRequestType(event);
- String location = event.getLocation();
-
- String message = type + ": " + location;
-
- log.debug(message);
-
- println(message);
+ println(renderRequestType(event) + ": " + event.getLocation());
}
public void transferCompleted(final TransferEvent event) {
@@ -68,10 +61,6 @@
super.transferCompleted(event);
- long total = event.getContentLength();
- String type = renderRequestTypeFinished(event);
- String bytes = total >= 1024 ? ( total / 1024 ) + "K" : total + "b";
-
- println(type + " " + bytes);
+ println(renderRequestTypeFinished(event) + " " + renderBytes(event.getContentLength()));
}
}
\ No newline at end of file