|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jets3t.service.utils.ServiceUtils
public class ServiceUtils
General utility methods used throughout the jets3t project.
Field Summary | |
---|---|
protected static java.text.SimpleDateFormat |
iso8601DateParser
|
protected static java.text.SimpleDateFormat |
iso8601DateParser_Walrus
|
protected static java.text.SimpleDateFormat |
rfc822DateParser
|
Constructor Summary | |
---|---|
ServiceUtils()
|
Method Summary | |
---|---|
static S3Object |
buildObjectFromUrl(java.lang.String host,
java.lang.String urlPath)
Builds an object based on the bucket name and object key information available in the components of a URL. |
static java.util.Map |
cleanRestMetadataMap(java.util.Map metadata)
From a map of metadata returned from a REST Get Object or Get Object Head request, returns a map of metadata with the HTTP-connection-specific metadata items removed. |
static byte[] |
computeMD5Hash(byte[] data)
Computes the MD5 hash of the given data and returns it as a hex string. |
static byte[] |
computeMD5Hash(java.io.InputStream is)
Computes the MD5 hash of the data in the given input stream and returns it as a hex string. |
static long |
countBytesInObjects(S3Object[] objects)
Counts the total number of bytes in a set of S3Objects by summing the content length of each. |
static java.lang.String |
findBucketNameInHostname(java.lang.String host)
Identifies the name of a bucket from a given host name, if available. |
static java.lang.String |
formatIso8601Date(java.util.Date date)
|
static java.lang.String |
formatRfc822Date(java.util.Date date)
|
static byte[] |
fromBase64(java.lang.String b64Data)
Converts a Base64-encoded string to the original byte data. |
static byte[] |
fromHex(java.lang.String hexData)
Converts a Hex-encoded data string to the original byte data. |
static java.lang.String |
getUserAgentDescription(java.lang.String applicationDescription)
Returns a user agent string describing the jets3t library, and optionally the application using it, to server-side services. |
static java.lang.String |
join(int[] ints,
java.lang.String delimiter)
Joins a list of ints into a delimiter-separated string. |
static java.lang.String |
join(java.util.List items,
java.lang.String delimiter)
Joins a list of items into a delimiter-separated string. |
static java.lang.String |
join(java.lang.Object[] items,
java.lang.String delimiter)
Joins a list of items into a delimiter-separated string. |
static java.util.Date |
parseIso8601Date(java.lang.String dateString)
|
static java.util.Date |
parseRfc822Date(java.lang.String dateString)
|
static java.lang.String |
readInputStreamLineToString(java.io.InputStream is,
java.lang.String encoding)
Reads from an input stream until a newline character or the end of the stream is reached. |
static byte[] |
readInputStreamToBytes(java.io.InputStream is)
Reads binary data from an input stream and returns it as a byte array. |
static java.lang.String |
readInputStreamToString(java.io.InputStream is,
java.lang.String encoding)
Reads text data from an input stream and returns it as a String. |
static java.lang.String |
signWithHmacSha1(java.lang.String awsSecretKey,
java.lang.String canonicalString)
Calculate the HMAC/SHA1 on a string. |
static java.lang.String |
toBase64(byte[] data)
Converts byte data to a Base64-encoded string. |
static java.lang.String |
toHex(byte[] data)
Converts byte data to a Hex-encoded string. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.text.SimpleDateFormat iso8601DateParser
protected static final java.text.SimpleDateFormat iso8601DateParser_Walrus
protected static final java.text.SimpleDateFormat rfc822DateParser
Constructor Detail |
---|
public ServiceUtils()
Method Detail |
---|
public static java.util.Date parseIso8601Date(java.lang.String dateString) throws java.text.ParseException
java.text.ParseException
public static java.lang.String formatIso8601Date(java.util.Date date)
public static java.util.Date parseRfc822Date(java.lang.String dateString) throws java.text.ParseException
java.text.ParseException
public static java.lang.String formatRfc822Date(java.util.Date date)
public static java.lang.String signWithHmacSha1(java.lang.String awsSecretKey, java.lang.String canonicalString) throws S3ServiceException
awsSecretKey
- AWS secret key.canonicalString
- canonical string representing the request to sign.
S3ServiceException
public static java.lang.String readInputStreamToString(java.io.InputStream is, java.lang.String encoding) throws java.io.IOException
is
- input stream from which text data is read.encoding
- the character encoding of the textual data in the input stream. If this
parameter is null, the default system encoding will be used.
java.io.IOException
public static java.lang.String readInputStreamLineToString(java.io.InputStream is, java.lang.String encoding) throws java.io.IOException
is
-
java.io.IOException
public static byte[] readInputStreamToBytes(java.io.InputStream is) throws java.io.IOException
is
- input stream from which data is read.
java.io.IOException
public static long countBytesInObjects(S3Object[] objects)
objects
-
public static java.util.Map cleanRestMetadataMap(java.util.Map metadata)
metadata
-
public static java.lang.String toHex(byte[] data)
data
- data to hex encode.
public static byte[] fromHex(java.lang.String hexData)
hexData
- hex-encoded data to decode.
public static java.lang.String toBase64(byte[] data)
data
- data to Base64 encode.
public static java.lang.String join(java.util.List items, java.lang.String delimiter)
items
- the items to include in a delimited stringdelimiter
- the delimiter character or string to insert between each item in the list
public static java.lang.String join(java.lang.Object[] items, java.lang.String delimiter)
items
- the items to include in a delimited stringdelimiter
- the delimiter character or string to insert between each item in the list
public static java.lang.String join(int[] ints, java.lang.String delimiter)
ints
- the ints to include in a delimited stringdelimiter
- the delimiter character or string to insert between each item in the list
public static byte[] fromBase64(java.lang.String b64Data)
b64Data
- a Base64-encoded string to decode.
public static byte[] computeMD5Hash(java.io.InputStream is) throws java.security.NoSuchAlgorithmException, java.io.IOException
is
-
java.security.NoSuchAlgorithmException
java.io.IOException
public static byte[] computeMD5Hash(byte[] data) throws java.security.NoSuchAlgorithmException, java.io.IOException
data
-
java.security.NoSuchAlgorithmException
java.io.IOException
public static java.lang.String findBucketNameInHostname(java.lang.String host)
host
- the host name component of a URL that may include the bucket name,
if an alternative host name is in use.
public static S3Object buildObjectFromUrl(java.lang.String host, java.lang.String urlPath) throws java.io.UnsupportedEncodingException
host
- the host name component of a URL that may include the bucket name,
if an alternative host name is in use.urlPath
- the path of a URL that references an S3 object, and which may or may
not include the bucket name.
java.io.UnsupportedEncodingException
public static java.lang.String getUserAgentDescription(java.lang.String applicationDescription)
applicationDescription
- a description of the application using the jets3t toolkit, included at the end of the
user agent string. This value may be null.
S3Service.VERSION_NO__JETS3T_TOOLKIT
(os.name/os.version; os.arch; user.region;
user.region; user.language) applicationDescription
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |