You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by vm...@apache.org on 2002/08/28 21:57:15 UTC
cvs commit: jakarta-cactus/framework/src/java/share/org/apache/cactus/util UrlUtil.java StringUtil.java HttpURLConnection.java JUnitVersionHelper.java IoUtil.java
vmassol 2002/08/28 12:57:15
Modified: framework/src/java/share/org/apache/cactus/util UrlUtil.java
StringUtil.java HttpURLConnection.java
JUnitVersionHelper.java IoUtil.java
Log:
new coding conventions
Revision Changes Path
1.3 +22 -8 jakarta-cactus/framework/src/java/share/org/apache/cactus/util/UrlUtil.java
Index: UrlUtil.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/util/UrlUtil.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- UrlUtil.java 25 Aug 2002 13:41:20 -0000 1.2
+++ UrlUtil.java 28 Aug 2002 19:57:15 -0000 1.3
@@ -79,14 +79,21 @@
{
String file = theURL.getFile();
String path = null;
- if (file != null) {
+
+ if (file != null)
+ {
int q = file.lastIndexOf('?');
- if (q != -1) {
+
+ if (q != -1)
+ {
path = file.substring(0, q);
- } else {
+ }
+ else
+ {
path = file;
}
}
+
return path;
}
@@ -102,14 +109,21 @@
{
String file = theURL.getFile();
String query = null;
- if (file != null) {
+
+ if (file != null)
+ {
int q = file.lastIndexOf('?');
- if (q != -1) {
+
+ if (q != -1)
+ {
query = file.substring(q + 1);
- } else {
+ }
+ else
+ {
query = "";
}
}
+
return query;
}
-}
+}
\ No newline at end of file
1.2 +5 -3 jakarta-cactus/framework/src/java/share/org/apache/cactus/util/StringUtil.java
Index: StringUtil.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/util/StringUtil.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- StringUtil.java 28 Jul 2002 13:38:41 -0000 1.1
+++ StringUtil.java 28 Aug 2002 19:57:15 -0000 1.2
@@ -56,8 +56,8 @@
*/
package org.apache.cactus.util;
-import java.io.StringWriter;
import java.io.PrintWriter;
+import java.io.StringWriter;
/**
* Various utility methods for string manipulation.
@@ -77,7 +77,9 @@
{
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
+
theThrowable.printStackTrace(pw);
+
return sw.toString();
}
-}
+}
\ No newline at end of file
1.2 +19 -14 jakarta-cactus/framework/src/java/share/org/apache/cactus/util/HttpURLConnection.java
Index: HttpURLConnection.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/util/HttpURLConnection.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HttpURLConnection.java 26 Jul 2002 18:50:29 -0000 1.1
+++ HttpURLConnection.java 28 Aug 2002 19:57:15 -0000 1.2
@@ -56,16 +56,18 @@
*/
package org.apache.cactus.util;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.Header;
-
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.net.URL;
+
import java.net.ProtocolException;
+import java.net.URL;
+
import java.security.Permission;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpMethod;
+
/**
* Provides a <code>HttpURLConnection</code> wrapper around HttpClient
* <code>HttpMethod</code>. This allows existing code to easily switch to
@@ -191,8 +193,11 @@
// Note: Return the last matching header in the Header[] array, as in
// the JDK implementation.
Header[] headers = this.method.getResponseHeaders();
- for (int i = headers.length - 1; i >= 0; i--) {
- if (headers[i].getName().equalsIgnoreCase(theName)) {
+
+ for (int i = headers.length - 1; i >= 0; i--)
+ {
+ if (headers[i].getName().equalsIgnoreCase(theName))
+ {
return headers[i].getValue();
}
}
@@ -207,9 +212,10 @@
{
// Note: I hope the header fields are kept in the correct order when
// calling getRequestHeaders.
-
Header[] headers = this.method.getResponseHeaders();
- if (theKeyPosition < 0 || theKeyPosition >= headers.length) {
+
+ if ((theKeyPosition < 0) || (theKeyPosition >= headers.length))
+ {
return null;
}
@@ -223,9 +229,10 @@
{
// Note: I hope the header fields are kept in the correct order when
// calling getRequestHeaders.
-
Header[] headers = this.method.getResponseHeaders();
- if (thePosition < 0 || thePosition >= headers.length) {
+
+ if ((thePosition < 0) || (thePosition >= headers.length))
+ {
return null;
}
@@ -243,7 +250,6 @@
// Note: We don't implement the following methods so that they default to
// the JDK implementation. They will all call
// <code>getHeaderField(String)</code> which we have overridden.
-
// java.net.HttpURLConnection#getHeaderFieldDate(String, long)
// java.net.HttpURLConnection#getContentLength()
// java.net.HttpURLConnection#getContentType()
@@ -430,5 +436,4 @@
{
throw new RuntimeException("Not implemented yet");
}
-
-}
+}
\ No newline at end of file
1.5 +23 -12 jakarta-cactus/framework/src/java/share/org/apache/cactus/util/JUnitVersionHelper.java
Index: JUnitVersionHelper.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/util/JUnitVersionHelper.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JUnitVersionHelper.java 27 May 2002 15:23:35 -0000 1.4
+++ JUnitVersionHelper.java 28 Aug 2002 19:57:15 -0000 1.5
@@ -58,8 +58,8 @@
import java.lang.reflect.Method;
-import junit.framework.TestCase;
import junit.framework.Test;
+import junit.framework.TestCase;
/**
* Work around for some changes to the public JUnit API between
@@ -78,14 +78,21 @@
*/
private static Method testCaseName = null;
- static {
- try {
+ static
+ {
+ try
+ {
testCaseName = TestCase.class.getMethod("getName", new Class[0]);
- } catch (NoSuchMethodException e) {
+ }
+ catch (NoSuchMethodException e)
+ {
// pre JUnit 3.7
- try {
+ try
+ {
testCaseName = TestCase.class.getMethod("name", new Class[0]);
- } catch (NoSuchMethodException e2) {
+ }
+ catch (NoSuchMethodException e2)
+ {
throw new ChainedRuntimeException("Cannot find method name()");
}
}
@@ -102,14 +109,18 @@
*/
public static String getTestCaseName(Test theTest)
{
- if (theTest instanceof TestCase && testCaseName != null) {
- try {
+ if (theTest instanceof TestCase && (testCaseName != null))
+ {
+ try
+ {
return (String) testCaseName.invoke(theTest, new Object[0]);
- } catch (Throwable e) {
+ }
+ catch (Throwable e)
+ {
// If it fails, we return "unknown"
}
}
+
return "unknown";
}
-
-}
+}
\ No newline at end of file
1.2 +8 -6 jakarta-cactus/framework/src/java/share/org/apache/cactus/util/IoUtil.java
Index: IoUtil.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/util/IoUtil.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- IoUtil.java 21 Apr 2002 12:45:44 -0000 1.1
+++ IoUtil.java 28 Aug 2002 19:57:15 -0000 1.2
@@ -57,9 +57,9 @@
package org.apache.cactus.util;
import java.io.BufferedReader;
-import java.io.InputStreamReader;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
/**
* Various utility methods for manipulating IO streams.
@@ -78,8 +78,7 @@
* @return the string representation of the data
* @throws IOException if an error occurs during the read of data
*/
- public static String getText(InputStream theStream)
- throws IOException
+ public static String getText(InputStream theStream) throws IOException
{
StringBuffer sb = new StringBuffer();
@@ -87,11 +86,14 @@
new InputStreamReader(theStream));
char[] buffer = new char[2048];
int nb;
- while (-1 != (nb = input.read(buffer, 0, 2048))) {
+
+ while (-1 != (nb = input.read(buffer, 0, 2048)))
+ {
sb.append(buffer, 0, nb);
}
+
input.close();
return sb.toString();
}
-}
+}
\ No newline at end of file
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>