ccc.api.jaxrs.providers
Class FileReader

java.lang.Object
  extended by ccc.api.jaxrs.providers.AbstractProvider
      extended by ccc.api.jaxrs.providers.FileReader
All Implemented Interfaces:
javax.ws.rs.ext.MessageBodyReader<File>, javax.ws.rs.ext.MessageBodyWriter<File>

@Provider
public class FileReader
extends AbstractProvider
implements javax.ws.rs.ext.MessageBodyWriter<File>, javax.ws.rs.ext.MessageBodyReader<File>

A MessageBodyReader for durations.

Author:
Civic Computing Ltd.

Constructor Summary
FileReader()
           
 
Method Summary
 long getSize(File t, java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
          
 boolean isReadable(java.lang.Class<?> clazz, java.lang.reflect.Type type, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
          
 boolean isWriteable(java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
          
 File readFrom(java.lang.Class<File> arg0, java.lang.reflect.Type arg1, java.lang.annotation.Annotation[] arg2, javax.ws.rs.core.MediaType arg3, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> arg4, java.io.InputStream arg5)
          
protected  java.lang.String toCharset(java.lang.String contentType)
          Extract the charset parameter from the content-type HTTP header.
protected  MimeType toMimeType(java.lang.String contentType)
          Extract the mime type from the content-type HTTP header.
 void writeTo(File t, java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> httpHeaders, java.io.OutputStream entityStream)
          
 
Methods inherited from class ccc.api.jaxrs.providers.AbstractProvider
createWriter, getTypeArgument, isCollectionOfType, isMapOfType, readJson, readString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileReader

public FileReader()
Method Detail

isReadable

public boolean isReadable(java.lang.Class<?> clazz,
                          java.lang.reflect.Type type,
                          java.lang.annotation.Annotation[] annotations,
                          javax.ws.rs.core.MediaType mediaType)

Specified by:
isReadable in interface javax.ws.rs.ext.MessageBodyReader<File>

readFrom

public File readFrom(java.lang.Class<File> arg0,
                     java.lang.reflect.Type arg1,
                     java.lang.annotation.Annotation[] arg2,
                     javax.ws.rs.core.MediaType arg3,
                     javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> arg4,
                     java.io.InputStream arg5)
              throws java.io.IOException

Specified by:
readFrom in interface javax.ws.rs.ext.MessageBodyReader<File>
Throws:
java.io.IOException

toMimeType

protected MimeType toMimeType(java.lang.String contentType)
Extract the mime type from the content-type HTTP header.

If the header value is un-parsable then "application/octet-stream" will be returned.

Parameters:
contentType - The HTTP content type.
Returns:
The mime type as a value object.

toCharset

protected java.lang.String toCharset(java.lang.String contentType)
Extract the charset parameter from the content-type HTTP header.

Parameters:
contentType - The HTTP content type.
Returns:
The charset param as a string.

getSize

public long getSize(File t,
                    java.lang.Class<?> type,
                    java.lang.reflect.Type genericType,
                    java.lang.annotation.Annotation[] annotations,
                    javax.ws.rs.core.MediaType mediaType)

Specified by:
getSize in interface javax.ws.rs.ext.MessageBodyWriter<File>

isWriteable

public boolean isWriteable(java.lang.Class<?> type,
                           java.lang.reflect.Type genericType,
                           java.lang.annotation.Annotation[] annotations,
                           javax.ws.rs.core.MediaType mediaType)

Specified by:
isWriteable in interface javax.ws.rs.ext.MessageBodyWriter<File>

writeTo

public void writeTo(File t,
                    java.lang.Class<?> type,
                    java.lang.reflect.Type genericType,
                    java.lang.annotation.Annotation[] annotations,
                    javax.ws.rs.core.MediaType mediaType,
                    javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> httpHeaders,
                    java.io.OutputStream entityStream)
             throws java.io.IOException

Specified by:
writeTo in interface javax.ws.rs.ext.MessageBodyWriter<File>
Throws:
java.io.IOException


Copyright © 2010. All Rights Reserved.