org.apache.wink.common.utils
Class ProviderUtils

java.lang.Object
  extended by org.apache.wink.common.utils.ProviderUtils

public class ProviderUtils
extends Object


Nested Class Summary
static class ProviderUtils.PROVIDER_EXCEPTION_ORIGINATOR
           
 
Constructor Summary
ProviderUtils()
           
 
Method Summary
static void copyStream(InputStream src, OutputStream dst)
           
static Reader createReader(InputStream stream, javax.ws.rs.core.MediaType mediaType)
           
static Writer createWriter(OutputStream stream, javax.ws.rs.core.MediaType mediaType)
           
static String getCharset(javax.ws.rs.core.MediaType m)
           
static String getCharset(javax.ws.rs.core.MediaType m, javax.ws.rs.core.HttpHeaders requestHeaders)
          Returns the charset on the chosen media type or, if no charset parameter exists on the chosen media type, the most acceptable charset based on the request headers.
static String getCharsetOrNull(javax.ws.rs.core.MediaType m)
           
static void logUserProviderException(RuntimeException e, Object obj, ProviderUtils.PROVIDER_EXCEPTION_ORIGINATOR originator, Object[] methodParams, RuntimeContext context)
           
static byte[] readFromStreamAsBytes(InputStream stream)
           
static String readFromStreamAsString(InputStream stream, javax.ws.rs.core.MediaType mt)
           
static
<T> T
readFromString(javax.ws.rs.ext.Providers providers, String input, Class<T> type, javax.ws.rs.core.MediaType mediaType)
           
static
<T> T
readFromString(javax.ws.rs.ext.Providers providers, String input, Class<T> type, Type genericType, javax.ws.rs.core.MediaType mediaType)
           
static
<T> T
readFromString(javax.ws.rs.ext.Providers providers, String input, Class<T> type, Type genericType, javax.ws.rs.core.MultivaluedMap<String,String> httpHeaders, javax.ws.rs.core.MediaType mediaType)
           
static void writeToStream(String string, OutputStream os, javax.ws.rs.core.MediaType mt)
           
static String writeToString(javax.ws.rs.ext.Providers providers, Object object, Class<?> type, javax.ws.rs.core.MediaType mediaType)
           
static String writeToString(javax.ws.rs.ext.Providers providers, Object object, Class<?> type, Type genericType, javax.ws.rs.core.MediaType mediaType)
           
static String writeToString(javax.ws.rs.ext.Providers providers, Object object, Class<?> type, Type genericType, javax.ws.rs.core.MultivaluedMap<String,Object> httpHeaders, javax.ws.rs.core.MediaType mediaType)
           
static String writeToString(javax.ws.rs.ext.Providers providers, Object object, javax.ws.rs.core.MediaType mediaType)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProviderUtils

public ProviderUtils()
Method Detail

getCharsetOrNull

public static String getCharsetOrNull(javax.ws.rs.core.MediaType m)

getCharset

public static String getCharset(javax.ws.rs.core.MediaType m)

getCharset

public static String getCharset(javax.ws.rs.core.MediaType m,
                                javax.ws.rs.core.HttpHeaders requestHeaders)
Returns the charset on the chosen media type or, if no charset parameter exists on the chosen media type, the most acceptable charset based on the request headers.

Parameters:
m - the chosen media type
requestHeaders - the request headers to inspect
Returns:
the charset

createReader

public static Reader createReader(InputStream stream,
                                  javax.ws.rs.core.MediaType mediaType)

createWriter

public static Writer createWriter(OutputStream stream,
                                  javax.ws.rs.core.MediaType mediaType)

readFromStreamAsBytes

public static byte[] readFromStreamAsBytes(InputStream stream)
                                    throws IOException
Throws:
IOException

readFromStreamAsString

public static String readFromStreamAsString(InputStream stream,
                                            javax.ws.rs.core.MediaType mt)
                                     throws IOException
Throws:
IOException

writeToStream

public static void writeToStream(String string,
                                 OutputStream os,
                                 javax.ws.rs.core.MediaType mt)
                          throws IOException
Throws:
IOException

copyStream

public static void copyStream(InputStream src,
                              OutputStream dst)
                       throws IOException
Throws:
IOException

writeToString

public static String writeToString(javax.ws.rs.ext.Providers providers,
                                   Object object,
                                   javax.ws.rs.core.MediaType mediaType)
                            throws IOException
Throws:
IOException

writeToString

public static String writeToString(javax.ws.rs.ext.Providers providers,
                                   Object object,
                                   Class<?> type,
                                   javax.ws.rs.core.MediaType mediaType)
                            throws IOException
Throws:
IOException

writeToString

public static String writeToString(javax.ws.rs.ext.Providers providers,
                                   Object object,
                                   Class<?> type,
                                   Type genericType,
                                   javax.ws.rs.core.MediaType mediaType)
                            throws IOException
Throws:
IOException

writeToString

public static String writeToString(javax.ws.rs.ext.Providers providers,
                                   Object object,
                                   Class<?> type,
                                   Type genericType,
                                   javax.ws.rs.core.MultivaluedMap<String,Object> httpHeaders,
                                   javax.ws.rs.core.MediaType mediaType)
                            throws IOException
Throws:
IOException

readFromString

public static <T> T readFromString(javax.ws.rs.ext.Providers providers,
                                   String input,
                                   Class<T> type,
                                   javax.ws.rs.core.MediaType mediaType)
                        throws IOException
Throws:
IOException

readFromString

public static <T> T readFromString(javax.ws.rs.ext.Providers providers,
                                   String input,
                                   Class<T> type,
                                   Type genericType,
                                   javax.ws.rs.core.MediaType mediaType)
                        throws IOException
Throws:
IOException

readFromString

public static <T> T readFromString(javax.ws.rs.ext.Providers providers,
                                   String input,
                                   Class<T> type,
                                   Type genericType,
                                   javax.ws.rs.core.MultivaluedMap<String,String> httpHeaders,
                                   javax.ws.rs.core.MediaType mediaType)
                        throws IOException
Throws:
IOException

logUserProviderException

public static void logUserProviderException(RuntimeException e,
                                            Object obj,
                                            ProviderUtils.PROVIDER_EXCEPTION_ORIGINATOR originator,
                                            Object[] methodParams,
                                            RuntimeContext context)


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