> +/**
> + * Converts ETag header values to byte arrays.
> + *
> + * @author Francis Devereux
> + */
> +public class ETagUtils {
> +   public static byte[] convertETagToHash(String eTag) {
> +      eTag = unquote(eTag);
> +      return base16().lowerCase().decode(eTag);
> +   }
> +
> +   static String unquote(String eTag) {
> +      if (eTag.length() >= 2 &&
> +          eTag.startsWith("\"") && eTag.endsWith("\"")) {
> +         eTag = eTag.substring(1, eTag.length() - 1);
> +      }

I don't think it could be done elegantly with a Splitter. I considered using a 
regex but thought it would be less clear (and probably slower, although not 
significantly).

The `length() >= 2` check was suggested by @andrewgaul. A single `"` is not a 
valid input as I alluded to in 
https://github.com/jclouds/jclouds/pull/120#discussion_r5902842.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/120/files#r5911564

Reply via email to