org.apache.clerezza.triaxrs.util
Class MediaTypeComparator

java.lang.Object
  extended by org.apache.clerezza.triaxrs.util.MediaTypeComparator
All Implemented Interfaces:
Comparator<javax.ws.rs.core.MediaType>

public class MediaTypeComparator
extends Object
implements Comparator<javax.ws.rs.core.MediaType>

Sorts media types in accordance with an accept-header, falling back to a built-in priority list and to literal sorting to guarantee constistency. Also provides static Utility methods for Media Type comparison.

Author:
reto

Constructor Summary
MediaTypeComparator()
           
MediaTypeComparator(AcceptHeader acceptHeader)
           
 
Method Summary
 int compare(javax.ws.rs.core.MediaType o1, javax.ws.rs.core.MediaType o2)
           
static int compareByWildCardCount(javax.ws.rs.core.MediaType o1, javax.ws.rs.core.MediaType o2)
           
static int countWildChars(javax.ws.rs.core.MediaType m)
           
static int inconsistentCompare(javax.ws.rs.core.MediaType o1, javax.ws.rs.core.MediaType o2)
          this is not consistent with equals
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

MediaTypeComparator

public MediaTypeComparator()

MediaTypeComparator

public MediaTypeComparator(AcceptHeader acceptHeader)
Method Detail

inconsistentCompare

public static int inconsistentCompare(javax.ws.rs.core.MediaType o1,
                                      javax.ws.rs.core.MediaType o2)
this is not consistent with equals

Parameters:
o1 -
o2 -
Returns:

compare

public int compare(javax.ws.rs.core.MediaType o1,
                   javax.ws.rs.core.MediaType o2)
Specified by:
compare in interface Comparator<javax.ws.rs.core.MediaType>

compareByWildCardCount

public static int compareByWildCardCount(javax.ws.rs.core.MediaType o1,
                                         javax.ws.rs.core.MediaType o2)
Parameters:
o1 -
o2 -
Returns:
-1 if o1 contains less wildcards

countWildChars

public static int countWildChars(javax.ws.rs.core.MediaType m)


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.