You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ve...@apache.org on 2008/12/14 02:15:07 UTC

svn commit: r726325 - in /webservices/commons/trunk/modules/axiom/modules: axiom-api/src/main/java/org/apache/axiom/om/util/CommonUtils.java axiom-tests/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java

Author: veithen
Date: Sat Dec 13 17:15:06 2008
New Revision: 726325

URL: http://svn.apache.org/viewvc?rev=726325&view=rev
Log:
* WSCOMMONS-413: Replaced usages of String#contains by String#indexOf to avoid build failure on JDK 1.4.
* Simplified the code in CommonUtils#isTextualPart.

Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/CommonUtils.java
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/CommonUtils.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/CommonUtils.java?rev=726325&r1=726324&r2=726325&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/CommonUtils.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/CommonUtils.java Sat Dec 13 17:15:06 2008
@@ -171,17 +171,10 @@
      */
     public static boolean isTextualPart(String contentType) {
         String ct = contentType.trim();
-        if (ct.startsWith("text/") ||
-            ct.startsWith("application/soap") ||
-            ct.startsWith("application/xml")) {
-            // REVIEW: What about content-type with a type of "message"
-            return true;
-        } 
-        
-        if (ct.contains("charset")) {
-            return true;
-        }
-        return false;
-                        
+        // REVIEW: What about content-type with a type of "message"
+        return ct.startsWith("text/") ||
+               ct.startsWith("application/soap") ||
+               ct.startsWith("application/xml") ||
+               ct.indexOf("charset") != -1;
     }
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java?rev=726325&r1=726324&r2=726325&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java Sat Dec 13 17:15:06 2008
@@ -197,7 +197,7 @@
         om.serialize(writer);
         String outNormal = baos.toString();
         
-        assertTrue(!outNormal.contains("base64"));
+        assertTrue(outNormal.indexOf("base64") == -1);
         
         // Now do it again but use base64 content-type-encoding for 
         // binary attachments
@@ -215,8 +215,8 @@
         
         // Do a quick check to see if the data is base64 and is
         // writing base64 compliant code.
-        assertTrue(outBase64.contains("base64"));
-        assertTrue(outBase64.contains("GBgcGBQgHBwcJCQgKDBQNDAsL"));
+        assertTrue(outBase64.indexOf("base64") != -1);
+        assertTrue(outBase64.indexOf("GBgcGBQgHBwcJCQgKDBQNDAsL") != -1);
         
         // Now read the data back in
         InputStream is = new ByteArrayInputStream(outBase64.getBytes());
@@ -234,7 +234,7 @@
         om.serialize(writer);
         String outBase64ToNormal = baos.toString();
         
-        assertTrue(!outBase64ToNormal.contains("base64"));
+        assertTrue(outBase64ToNormal.indexOf("base64") == -1);
         
         // Now do it again but use base64 content-type-encoding for 
         // binary attachments
@@ -251,8 +251,8 @@
         
         // Do a quick check to see if the data is base64 and is
         // writing base64 compliant code.
-        assertTrue(outBase64ToBase64.contains("base64"));
-        assertTrue(outBase64ToBase64.contains("GBgcGBQgHBwcJCQgKDBQNDAsL"));
+        assertTrue(outBase64ToBase64.indexOf("base64") != -1);
+        assertTrue(outBase64ToBase64.indexOf("GBgcGBQgHBwcJCQgKDBQNDAsL") != -1);
         
         // Some quick verifications of the isTextualPart logic
         assertTrue(CommonUtils.isTextualPart("text/xml"));