Create a {@code Key} given its URL safe encoded form.

@throws IllegalArgumentException when decoding fails
11649
public static Key fromUrlSafe(String urlSafe) {
    try {
      String utf8Str = URLDecoder.decode(urlSafe, UTF_8.name());
      com.google.datastore.v1.Key.Builder builder = com.google.datastore.v1.Key.newBuilder();
      TextFormat.merge(utf8Str, builder);
      return fromPb(builder.build());
    } catch (UnsupportedEncodingException e) {
      throw new IllegalStateException("Unexpected decoding exception", e);
    } catch (TextFormat.ParseException e) {
      throw new IllegalArgumentException("Could not parse key", e);
    }
  }
917066
public static Attribute createFromEncoded(String unencodedKey, String encodedValue) {
        String value = Entities.unescape(encodedValue, true);
        return new Attribute(unencodedKey, value, null); // parent will get set when Put
    }
704913
@Override
    public String tagKey(String key) {
        String sanitized = StringEscapeUtils.escapeJson(delegate.tagKey(key));
        if (Character.isDigit(sanitized.charAt(0))) {
            sanitized = "m." + sanitized;
        }
        return sanitized;
    }
651249
public static byte[] decode(String key) {
		return Validator.isHex(key) ? HexUtil.decodeHex(key) : Base64.decode(key);
	}
487013
public static <V> Key<V> key( com.google.appengine.api.datastore.Key raw ) {
        if ( raw == null ) {
            return null;
        } else {
            return new Key<V>( raw );
        }
    }
886909
public ParameterBuilder<T> property(String key, Object value) {
    if (key == null) {
      throw new IllegalArgumentException("Key argument must not be null.");
    }
    this.properties.put(key, value);
    return this;
  }
12030
public static String encode(final String input, final boolean urlSafeEncoding) {
		return new String(encode(input.getBytes(charsetUTF8), urlSafeEncoding), charsetISOLatin1);
	}
1106190
public static String encode(String value) throws UnsupportedEncodingException {
        if (isNullOrEmpty(value)) return value;
        return URLEncoder.encode(value, URL_ENCODING);
    }
614826
public static String urlFormEncode(final String s)
        {
        if (StringUtils.isBlank(s))
            {
            LOG.warn("Could not encode blank string");
            throw new IllegalArgumentException("Blank string");
            }
        try
            {
            return URLEncoder.encode(s, "UTF-8");
            }
        catch (final UnsupportedEncodingException e)
            {
            LOG.error ("Could not encode: " + s, e);            
            return s;
            }
        }
261865
public static Key create(String kind, Object key) {
		return create(null, kind, key);
	}
1343643
private String urlencode(String data, String charset) {
        try {
            return URLEncoder.encode(String.valueOf(data), charset);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
81401
public static SecretKey generateKey(final byte[] key) {
        return new SecretKey() {

            private byte[] k;

            {
                if (key.length == 16) {
                    k = key;
                } else {
                    k = new byte[16];
                    System.arraycopy(key, 0, k, 0, key.length < 16 ? key.length : 16);
                }
            }

            @Override
            public String getAlgorithm() {
                return "AES";
            }

            @Override
            public String getFormat() {
                return "RAW";
            }

            @Override
            public byte[] getEncoded() {
                return k;
            }
        };
    }
1304271
private URI buildUriWithKeyAndParams(String key, Map<String, String> params) {
        StringBuilder sb = new StringBuilder();
        sb.append(URI_PREFIX);
        if (key.startsWith("/")) {
            key = key.substring(1);
        }
        for (String token : Splitter.on("/").split(key)) {
            sb.append("/").append(urlEscape(token));
        }
        if (params != null) {
            sb.append("?");
            for (String str : params.keySet()) {
                sb.append(urlEscape(str)).append("=").append(urlEscape(params.get(str)));
                sb.append("&");
            }
        }

        String url = sb.toString();
        if (url.endsWith("&")) {
            url = url.substring(0, url.length() - 1);
        }
        return baseUri.resolve(url);
    }
1030607
public static final void validateKey(String key) throws IllegalArgumentException {
        if (StringUtils.isEmpty(key) || "..".equals(key) || ".".equals(key) || !KEY_PATTERN.matcher(key).matches()) {
            LOG.error("'{}' does not appear to be valid {}", key, KEY_PATTERN);
            throw new IllegalArgumentException(key+" does not appear to be a valid blob key");
        }
    }
1350296
private static URL parseURL(String encodedUrl) {
    try {
      return new URL(encodedUrl);
    } catch (MalformedURLException e) {
      throw new IllegalArgumentException(e);
    }
  }
537780
@Override
	public <T extends Resource> T post(final String uri, final Map<String, String> params) throws UnsupportedEncodingException {
		return post(uri, new Parameters(unsafeCast(params)));
	}
582473
public String getKeyAsString(Key key) {
        Objects.requireNonNull(key, Required.KEY.toString());
        
        return encodeBase64(key.getEncoded());
    }