@ -1,5 +1,5 @@
/ *
/ *
* Copyright 2002 - 2011 the original author or authors .
* Copyright 2002 - 2012 the original author or authors .
*
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* you may not use this file except in compliance with the License .
@ -18,6 +18,8 @@ package org.springframework.web.servlet.mvc.condition;
import javax.servlet.http.HttpServletRequest ;
import javax.servlet.http.HttpServletRequest ;
import org.apache.commons.logging.Log ;
import org.apache.commons.logging.LogFactory ;
import org.springframework.http.MediaType ;
import org.springframework.http.MediaType ;
import org.springframework.web.bind.annotation.RequestMapping ;
import org.springframework.web.bind.annotation.RequestMapping ;
@ -31,6 +33,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
* /
* /
abstract class AbstractMediaTypeExpression implements Comparable < AbstractMediaTypeExpression > , MediaTypeExpression {
abstract class AbstractMediaTypeExpression implements Comparable < AbstractMediaTypeExpression > , MediaTypeExpression {
protected final Log logger = LogFactory . getLog ( getClass ( ) ) ;
private final MediaType mediaType ;
private final MediaType mediaType ;
private final boolean isNegated ;
private final boolean isNegated ;
@ -60,9 +64,17 @@ abstract class AbstractMediaTypeExpression implements Comparable<AbstractMediaTy
}
}
public final boolean match ( HttpServletRequest request ) {
public final boolean match ( HttpServletRequest request ) {
try {
boolean match = matchMediaType ( request ) ;
boolean match = matchMediaType ( request ) ;
return ! isNegated ? match : ! match ;
return ! isNegated ? match : ! match ;
}
}
catch ( IllegalArgumentException ex ) {
if ( logger . isDebugEnabled ( ) ) {
logger . debug ( "Could not parse media type header: " + ex . getMessage ( ) ) ;
}
return false ;
}
}
protected abstract boolean matchMediaType ( HttpServletRequest request ) ;
protected abstract boolean matchMediaType ( HttpServletRequest request ) ;