abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r493177 - /incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/MimeTypeHelper.java
Date Fri, 05 Jan 2007 20:25:54 GMT
Author: jmsnell
Date: Fri Jan  5 12:25:53 2007
New Revision: 493177

URL: http://svn.apache.org/viewvc?view=rev&rev=493177
Log:
Adding support for the new Atom media-type type parameter defined by:

  http://www.ietf.org/internet-drafts/draft-ietf-atompub-typeparam-00.txt

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=493177&r1=493176&r2=493177
==============================================================================
--- 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
Fri Jan  5 12:25:53 2007
@@ -57,12 +57,12 @@
           return true;
     boolean answer = false;
     try {
-      MimeType mta = new MimeType(a);
-      MimeType mtb = new MimeType(b);
+      MimeType mta = new MimeType(a.toLowerCase());
+      MimeType mtb = new MimeType(b.toLowerCase());
       return isMatch(mta,mtb);
     } catch (Exception e) {}
     return answer;
-  }
+  }  
   
   /**
    * Returns true if media type a matches media type b
@@ -99,6 +99,36 @@
   }
   
   /**
+   * Returns true if media type a specifically identifies an Atom entry document
+   */
+  public static boolean isEntry(String a) {
+    try {
+      MimeType mta = new MimeType(a.toLowerCase());
+      MimeType mtb = new MimeType(Constants.ATOM_MEDIA_TYPE);
+      if (isMatch(mta,mtb)) {
+        String type = mta.getParameter("type");
+        return (type != null && type.equalsIgnoreCase("entry"));
+      }
+    } catch (Exception e) {}
+    return false;
+  }
+  
+  /**
+   * Returns true if media type a explicitly identifies an Atom feed document
+   */
+  public static boolean isFeed(String a) {
+    try {
+      MimeType mta = new MimeType(a.toLowerCase());
+      MimeType mtb = new MimeType(Constants.ATOM_MEDIA_TYPE);
+      if (isMatch(mta,mtb)) {
+        String type = mta.getParameter("type");
+        return (type != null && type.equalsIgnoreCase("feed"));
+      }
+    } catch (Exception e) {}
+    return false;
+  }
+  
+  /**
    * Returns true if media type a matches application/xml, text/xml or 
    * application/*+xml 
    */
@@ -155,8 +185,10 @@
         type = (mt != null) ? mt.toString() : null;
       }
       if (type == null) {
-        if (el instanceof Feed || el instanceof Entry)
+        if (el instanceof Feed)
           type = Constants.ATOM_MEDIA_TYPE;
+        else if (el instanceof Entry)
+          type = Constants.ATOM_MEDIA_TYPE + ";type=entry";
         else if (el instanceof Service)
           type = Constants.APP_MEDIA_TYPE;
         else if (el instanceof Categories)



Mime
View raw message