abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r561172 - /incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/MimeTypeHelper.java
Date Mon, 30 Jul 2007 22:47:30 GMT
Author: jmsnell
Date: Mon Jul 30 15:47:29 2007
New Revision: 561172

URL: http://svn.apache.org/viewvc?view=rev&rev=561172
Log:
General bug fixes.  The logic for matching entry and feed documents was wrong

Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/MimeTypeHelper.java

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/MimeTypeHelper.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/MimeTypeHelper.java?view=diff&rev=561172&r1=561171&r2=561172
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/MimeTypeHelper.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/MimeTypeHelper.java
Mon Jul 30 15:47:29 2007
@@ -66,27 +66,33 @@
     return answer;
   }  
   
+  public static boolean isMatch(MimeType a, MimeType b) {
+    return isMatch(a,b,false);
+  }
+  
   /**
    * Returns true if media type a matches media type b
    */
-  public static boolean isMatch(MimeType a, MimeType b) {
+  public static boolean isMatch(MimeType a, MimeType b, boolean includeparams) {
     try {
       if (a == null || b == null) return true;
       if (a.match(b)) {
-        MimeTypeParameterList aparams = a.getParameters();
-        MimeTypeParameterList bparams = b.getParameters();
-        if (aparams.isEmpty() && bparams.isEmpty()) return true;
-        if (aparams.isEmpty() && !bparams.isEmpty()) return false;
-        if (!aparams.isEmpty() && bparams.isEmpty()) return false;
-        boolean answer = true;
-        for (Enumeration e = aparams.getNames(); e.hasMoreElements();) {
-          String aname = (String)e.nextElement();
-          String avalue = aparams.get(aname);
-          String bvalue = bparams.get(aname);
-          if (avalue.equals(bvalue)) answer = true;
-          else { answer = false; break; }
-        }
-        return answer;
+        if (includeparams) {
+          MimeTypeParameterList aparams = a.getParameters();
+          MimeTypeParameterList bparams = b.getParameters();
+          if (aparams.isEmpty() && bparams.isEmpty()) return true;
+          if (aparams.isEmpty() && !bparams.isEmpty()) return false;
+          if (!aparams.isEmpty() && bparams.isEmpty()) return false;
+          boolean answer = true;
+          for (Enumeration e = aparams.getNames(); e.hasMoreElements();) {
+            String aname = (String)e.nextElement();
+            String avalue = aparams.get(aname);
+            String bvalue = bparams.get(aname);
+            if (avalue.equals(bvalue)) answer = true;
+            else { answer = false; break; }
+          }
+          return answer;
+        } else return true;
       }
       if (a.equals(WILDCARD)) return true;
       if (a.getPrimaryType().equals("*")) {
@@ -112,7 +118,8 @@
    * Returns true if media type a matches application/atom+xml
    */
   public static boolean isAtom(String a) {
-    return isMatch(Constants.ATOM_MEDIA_TYPE, a);
+    if (isEntry(a) || isFeed(a)) return true;
+    return isMatch(Constants.ATOM_MEDIA_TYPE,a);
   }
   
   /**
@@ -139,7 +146,7 @@
       MimeType mtb = new MimeType(Constants.ATOM_MEDIA_TYPE);
       if (isMatch(mta,mtb)) {
         String type = mta.getParameter("type");
-        return (type != null && type.equalsIgnoreCase("feed"));
+        return type != null ? type.equalsIgnoreCase("feed") : true;
       }
     } catch (Exception e) {}
     return false;



Mime
View raw message