@ -23,7 +23,7 @@ import java.lang.reflect.ParameterizedType;
@@ -23,7 +23,7 @@ import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type ;
import java.util.Collection ;
import org.springframework.core.io.ResourceRegion ;
import org.springframework.core.io.support. ResourceRegion ;
import org.springframework.http.HttpHeaders ;
import org.springframework.http.HttpInputMessage ;
import org.springframework.http.HttpOutputMessage ;
@ -33,11 +33,11 @@ import org.springframework.util.MimeTypeUtils;
@@ -33,11 +33,11 @@ import org.springframework.util.MimeTypeUtils;
import org.springframework.util.StreamUtils ;
/ * *
* Implementation of { @link HttpMessageConverter } that can write a single { @link ResourceRegion ResourceRegion } ,
* Implementation of { @link HttpMessageConverter } that can write a single { @link ResourceRegion } ,
* or Collections of { @link ResourceRegion ResourceRegions } .
*
* @author Brian Clozel
* @since 4 . 3 . 0
* @since 4 . 3
* /
public class ResourceRegionHttpMessageConverter extends AbstractGenericHttpMessageConverter < Object > {
@ -45,6 +45,32 @@ public class ResourceRegionHttpMessageConverter extends AbstractGenericHttpMessa
@@ -45,6 +45,32 @@ public class ResourceRegionHttpMessageConverter extends AbstractGenericHttpMessa
super ( MediaType . ALL ) ;
}
@Override
protected boolean supports ( Class < ? > clazz ) {
// should not be called as we override canRead/canWrite
return false ;
}
@Override
public boolean canRead ( Type type , Class < ? > contextClass , MediaType mediaType ) {
return false ;
}
@Override
public Object read ( Type type , Class < ? > contextClass , HttpInputMessage inputMessage )
throws IOException , HttpMessageNotReadableException {
return null ;
}
@Override
protected ResourceRegion readInternal ( Class < ? extends Object > clazz , HttpInputMessage inputMessage )
throws IOException , HttpMessageNotReadableException {
return null ;
}
@Override
public boolean canWrite ( Class < ? > clazz , MediaType mediaType ) {
return canWrite ( clazz , null , mediaType ) ;
@ -152,6 +178,7 @@ public class ResourceRegionHttpMessageConverter extends AbstractGenericHttpMessa
@@ -152,6 +178,7 @@ public class ResourceRegionHttpMessageConverter extends AbstractGenericHttpMessa
print ( out , "--" + boundaryString + "--" ) ;
}
private static void println ( OutputStream os ) throws IOException {
os . write ( '\r' ) ;
os . write ( '\n' ) ;
@ -161,28 +188,4 @@ public class ResourceRegionHttpMessageConverter extends AbstractGenericHttpMessa
@@ -161,28 +188,4 @@ public class ResourceRegionHttpMessageConverter extends AbstractGenericHttpMessa
os . write ( buf . getBytes ( "US-ASCII" ) ) ;
}
@Override
public boolean canRead ( Type type , Class < ? > contextClass , MediaType mediaType ) {
return false ;
}
@Override
protected boolean supports ( Class < ? > clazz ) {
// should not be called as we override canRead/canWrite
return false ;
}
@Override
public Object read ( Type type , Class < ? > contextClass , HttpInputMessage inputMessage )
throws IOException , HttpMessageNotReadableException {
return null ;
}
@Override
protected ResourceRegion readInternal ( Class < ? extends Object > clazz , HttpInputMessage inputMessage )
throws IOException , HttpMessageNotReadableException {
return null ;
}
}