|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.basho.riak.client.util.ClientUtils
WARNING: This class will be REMOVED in the next version.
@Deprecated public class ClientUtils
Utility functions.
ClientUtils
Constructor Summary | |
---|---|
ClientUtils()
Deprecated. |
Method Summary | |
---|---|
static Map<String,String> |
asHeaderMap(org.apache.http.Header[] headers)
Deprecated. Convert a header array returned from HttpClient to a map |
static byte[] |
bufferStream(InputStream valueStream)
Deprecated. Buffers an input stream into a byte array |
static void |
copyStream(InputStream in,
OutputStream out)
Deprecated. Copies data from an InputStream to an OutputStream in
blocks |
static String |
encodeClientId(byte[] clientId)
Deprecated. Base64 encodes the first 4 bytes of clientId into a value acceptable for the X-Riak-ClientId header. |
static String |
encodeClientId(String clientId)
Deprecated. |
static String |
getPathFromUrl(String url)
Deprecated. Return just the path portion of the given URL |
static String |
join(String[] arr,
String delimiter)
Deprecated. Join the elements in arr in to a single string separated by delimiter. |
static List<String> |
jsonArrayAsList(JSONArray json)
Deprecated. Convert a JSONArray to a list |
static Map<String,String> |
jsonObjectAsMap(JSONObject json)
Deprecated. Convert a JSONObject to a map |
static String |
makeURI(RiakConfig config,
String bucket)
Deprecated. Return a URL to the given bucket |
static String |
makeURI(RiakConfig config,
String bucket,
String key)
Deprecated. Return a URL to the given object |
static String |
makeURI(RiakConfig config,
String bucket,
String key,
String extra)
Deprecated. Return a URL to the given object |
static org.apache.http.client.HttpClient |
newHttpClient(RiakConfig config)
Deprecated. Construct a new HttpClient instance given a RiakConfig . |
static List<RiakLink> |
parseLinkHeader(String header)
Deprecated. Parse a link header into a RiakLink . |
static List<RiakObject> |
parseMultipart(RiakClient riak,
String bucket,
String key,
Map<String,String> docHeaders,
byte[] docBody)
Deprecated. Convert a multipart/mixed document to a list of RiakObject s. |
static Map<String,String> |
parseUsermeta(Map<String,String> headers)
Deprecated. Extract only the user-specified metadata headers from a header set: all headers prefixed with X-Riak-Meta-. |
static String |
randomClientId()
Deprecated. Returns a random X-Riak-ClientId header value. |
static void |
throwChecked(Throwable exception)
Deprecated. Throws a checked Exception not declared in the method signature,
which can be particularly useful for throwing checked exceptions within a
RiakExceptionHandler . |
static String |
unquoteString(String s)
Deprecated. Unquote and unescape an HTTP quoted-string :
http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2
Does nothing if s is not quoted. |
static String |
urlDecode(String s)
Deprecated. Decodes a UTF-8 encoded string |
static String |
urlEncode(String s)
Deprecated. UTF-8 encode the string |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ClientUtils()
Method Detail |
---|
public static org.apache.http.client.HttpClient newHttpClient(RiakConfig config)
HttpClient
instance given a RiakConfig
.
config
- RiakConfig
containing HttpClient configuration
specifics.
HttpClient
public static String makeURI(RiakConfig config, String bucket)
config
- RiakConfig containing the base URL to Riakbucket
- Bucket whose URL to retrieving
public static String makeURI(RiakConfig config, String bucket, String key)
config
- RiakConfig containing the base URL to Riakbucket
- Bucket of the objectkey
- Key of the object
public static String makeURI(RiakConfig config, String bucket, String key, String extra)
config
- RiakConfig containing the base URL to Riakbucket
- Bucket of the objectkey
- Key of the objectextra
- Extra path information beyond the bucket and key (e.g. for
link walking or query parameters)
public static String getPathFromUrl(String url)
public static String urlEncode(String s)
public static String urlDecode(String s)
public static String encodeClientId(byte[] clientId)
public static String encodeClientId(String clientId)
public static String randomClientId()
public static String unquoteString(String s)
quoted-string
:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2
Does nothing if s
is not quoted.
s
- quoted-string
to unquote
public static Map<String,String> asHeaderMap(org.apache.http.Header[] headers)
HttpClient
to a map
headers
- Header array returned from HttpClient
public static Map<String,String> jsonObjectAsMap(JSONObject json)
JSONObject
to a map
json
- JSONObject
to convert
public static List<String> jsonArrayAsList(JSONArray json)
JSONArray
to a list
json
- JSONArray
to convert
public static String join(String[] arr, String delimiter)
public static void copyStream(InputStream in, OutputStream out) throws IOException
InputStream
to an OutputStream
in
blocks
in
- InputStream to copyout
- OutputStream to copy to
IOException
public static List<RiakLink> parseLinkHeader(String header)
RiakLink
. See LinkHeader
.
header
- The HTTP Link header value.
RiakLink
objects constructed from the links in
header in order.public static Map<String,String> parseUsermeta(Map<String,String> headers)
headers
- The full HTTP header set from the response
public static List<RiakObject> parseMultipart(RiakClient riak, String bucket, String key, Map<String,String> docHeaders, byte[] docBody)
RiakObject
s.
riak
- RiakClient
this object should be associate with, or
null if nonebucket
- original object's bucketkey
- original object's keydocHeaders
- original document's headersdocBody
- original document's body
RiakObject
s represented by the multipart documentpublic static void throwChecked(Throwable exception)
Exception
not declared in the method signature,
which can be particularly useful for throwing checked exceptions within a
RiakExceptionHandler
. Clearly, this circumvents compiler
safeguards, so use with caution. You've been warned.
exception
- A checked (or unchecked) exception to be thrown.public static byte[] bufferStream(InputStream valueStream)
valueStream
- the stream to read into an array
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |