You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dw...@apache.org on 2009/06/09 21:23:28 UTC
svn commit: r783098 - in /geronimo/server/branches/2.1/framework/modules:
geronimo-cli/src/main/java/org/apache/geronimo/cli/PrintHelper.java
geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployUtils.java
Author: dwoods
Date: Tue Jun 9 19:23:28 2009
New Revision: 783098
URL: http://svn.apache.org/viewvc?rev=783098&view=rev
Log:
GERONIMO-4533 Fix 'This is ridiculous' error messages for thrown IllegalArgumentExceptions.
Modified:
geronimo/server/branches/2.1/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/PrintHelper.java
geronimo/server/branches/2.1/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployUtils.java
Modified: geronimo/server/branches/2.1/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/PrintHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/PrintHelper.java?rev=783098&r1=783097&r2=783098&view=diff
==============================================================================
--- geronimo/server/branches/2.1/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/PrintHelper.java (original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/PrintHelper.java Tue Jun 9 19:23:28 2009
@@ -41,9 +41,14 @@
*/
public class PrintHelper {
- public static String reformat(String source, int indent, int endCol) {
+ public static String reformat(String source, int indent, int width) {
+ int endCol = width;
+ if (endCol == 0) {
+ endCol = DEFAULT_WIDTH;
+ }
if(endCol-indent < 10) {
- throw new IllegalArgumentException("This is ridiculous!");
+ throw new IllegalArgumentException("Need at least 10 spaces for " +
+ "printing, but indent=" + indent + " and endCol=" + endCol);
}
StringBuffer buf = new StringBuffer((int)(source.length()*1.1));
String prefix = indent == 0 ? "" : buildIndent(indent);
Modified: geronimo/server/branches/2.1/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployUtils.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployUtils.java?rev=783098&r1=783097&r2=783098&view=diff
==============================================================================
--- geronimo/server/branches/2.1/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployUtils.java (original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployUtils.java Tue Jun 9 19:23:28 2009
@@ -49,13 +49,18 @@
*
* @param source The unformatted String
* @param indent The number of characters to indent on the left
- * @param endCol The maximum width of the entire line in characters,
+ * @param width The maximum width of the entire line in characters,
* including indent (indent 10 with endCol 70 results
* in 60 "usable" characters).
*/
- public static String reformat(String source, int indent, int endCol) {
+ public static String reformat(String source, int indent, int width) {
+ int endCol = width;
+ if (endCol == 0) {
+ endCol = DEFAULT_WIDTH;
+ }
if (endCol - indent < 10) {
- throw new IllegalArgumentException("This is ridiculous!");
+ throw new IllegalArgumentException("Need at least 10 spaces for " +
+ "printing, but indent=" + indent + " and endCol=" + endCol);
}
StringBuffer buf = new StringBuffer((int) (source.length() * 1.1));
String prefix = indent == 0 ? "" : buildIndent(indent);
@@ -95,7 +100,7 @@
return buf.toString();
}
- private final static int DEFAULT_TERM_WIDTH = 256;
+ private final static int DEFAULT_WIDTH = 76;
public static void println(String line, int indent, ConsoleReader consoleReader) throws IOException {
int endCol = consoleReader.getTermwidth();
@@ -104,11 +109,12 @@
// some terminals will give a terminal width of zero (e.g. emacs shell).
// in that case, default to a reasonable term width value.
if (endCol == 0) {
- endCol = DEFAULT_TERM_WIDTH;
+ endCol = DEFAULT_WIDTH;
}
if (endCol - indent < 10) {
- throw new IllegalArgumentException("This is ridiculous!");
+ throw new IllegalArgumentException("Need at least 10 spaces for " +
+ "printing, but indent=" + indent + " and endCol=" + endCol);
}
String prefix = indent == 0 ? "" : buildIndent(indent);
int pos;