Is there any safe way of emulating those methods?
I looked into the implementation(sorry), and doesn't look very nice:
public static String keyToString(Key key)
{
if(!key.isComplete())
{
throw new IllegalArgumentException("Key is incomplete.");
} else
{
com.google.storage.onestore.v3.OnestoreEntity.Reference
reference = KeyTranslator.convertToPb(key);
return Base64.encodeWebSafe(reference.toByteArray(), false);
}
}
public static Key stringToKey(String encoded)
{
int modulo = encoded.length() % 4;
if(modulo != 0)
encoded = (new StringBuilder()).append(encoded).append("===="
.substring(modulo)).toString();
byte encodedBytes[] = encoded.getBytes();
byte decodedBytes[];
try
{
decodedBytes = Base64.decodeWebSafe(encodedBytes, 0,
encodedBytes.length);
}
catch(Base64DecoderException ex)
{
throw new IllegalArgumentException((new
StringBuilder()).append("Cannot
parse: ").append(encoded).toString(), ex);
}
com.google.storage.onestore.v3.OnestoreEntity.Reference reference =
new com.google.storage.onestore.v3.OnestoreEntity.Reference();
reference.parseFrom(decodedBytes);
return KeyTranslator.createFromPb(reference);
}
The other methods of KeyFactory are easy to emulate on gwt. It will be very
useful to have those two as well.
Thanks in advance.
+1 for an open-source jgae development code
--
Guit: Elegant, beautiful, modular and *production ready* gwt applications.
http://code.google.com/p/guit/
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.