@Override public String keyToString(Key key) { return KeyFactory.keyToString(key); }
/** * Call KeyFactory.keyToString() on the underlying Key. You can reconstitute a Key<?> using the * constructor that takes a websafe string. */ public String getString() { return KeyFactory.keyToString(this.raw); }
/** * Returns {@code com.google.appengine.api.datastore.Key} value as string * representation. */ @Override protected String convertToString(Object value) throws Throwable { Key key = (Key) value; return KeyFactory.keyToString(key); }
public Object revert(Object value) { return KeyFactory.keyToString((Key)value); }
@Override public String from(Key from) { return from == null ? null : KeyFactory.keyToString(from); }
private static String toString(Key key) { return KeyFactory.keyToString(key); }
@Override protected void addProperties(Properties properties) { String keyString = KeyFactory.keyToString(key); properties.setProperty(KEY_PARAM, keyString); }
@Override protected void addProperties(Properties properties) { properties.setProperty(RECORD_KEY_PROPERTY, KeyFactory.keyToString(recordKey)); }
private static String createTaskName(String namePrefix, Key key) { if (null == key) { throw new IllegalArgumentException("key is null."); } if (namePrefix == null) { throw new IllegalArgumentException("namePrix is null."); } return namePrefix + KeyFactory.keyToString(key); }
@Override protected void addProperties(Properties properties) { super.addProperties(properties); properties.setProperty(ROOT_JOB_KEY_PARAM, KeyFactory.keyToString(rootJobKey)); }
@Override protected void addProperties(Properties properties) { super.addProperties(properties); properties.setProperty(FAILED_CHILD_KEY_PARAM, KeyFactory.keyToString(failedChildKey)); }
@Override public String getHandle() { return KeyFactory.keyToString(slot.getKey()); }
/** * <p>Converts a Key<?> into a web-safe string suitable for http parameters * in URLs. Note that you can convert back and forth with the {@code keyToString()} * and {@code stringToKey()} methods.</p> * * <p>The String is actually generated by using the KeyFactory {@code keyToString()} * method on a raw version of the datastore key. You can, if you wanted, use * these web safe strings interchangeably.</p> * * @param key is any Objectify key * @return a simple String which does not need urlencoding */ public String keyToString(Key<?> key) { return KeyFactory.keyToString(key.getRaw()); }
private static Object intOrLongToInternalKey( String kind, Class<?> pkType, AbstractMemberMetaData pkMemberMetaData, Class<?> cls, Object val) { Object result = null; Key keyWithId = KeyFactory.createKey(kind, ((Number) val).longValue()); if (pkType.equals(String.class)) { if (pkMemberMetaData.hasExtension(DatastoreManager.ENCODED_PK)) { result = KeyFactory.keyToString(keyWithId); } else { throw new NucleusFatalUserException( "Received a request to find an object of type " + cls.getName() + ". The primary " + "key for this type is an unencoded String. However, the provided value is of type " + val.getClass().getName() + "."); } } else if (pkType.equals(Long.class) || pkType.equals(long.class)) { result = keyWithId.getId(); } else if (pkType.equals(Key.class)) { result = keyWithId; } return result; }
keyResult = KeyFactory.keyToString(result.getKey());
bld.append(KeyFactory.keyToString(this.actual.getAncestor()));
result = KeyFactory.keyToString(key); } else { if (key.getParent() != null) {
/** * Method to make sure that the Entity has its parentKey assigned. * Will update the Entity of this StoreFieldManager as necessary for the parent key. * Returns the assigned parent PK (when we have a "gae.parent-pk" field/property in this class). * @return The parent key if the pojo class has a parent property. Note that a return value of {@code null} * does not mean that an entity group was not established, it just means the pojo doesn't have a distinct * field for the parent. */ Object establishEntityGroup() { Key parentKey = datastoreEntity.getParent(); if (parentKey == null) { KeyRegistry keyReg = KeyRegistry.getKeyRegistry(ec); if (keyReg.isUnowned(getObjectProvider().getObject())) { return null; } parentKey = EntityUtils.getParentKey(datastoreEntity, getObjectProvider()); if (parentKey != null) { datastoreEntity = EntityUtils.recreateEntityWithParent(parentKey, datastoreEntity); } } AbstractMemberMetaData parentPkMmd = ((DatastoreManager)getStoreManager()).getMetaDataForParentPK(getClassMetaData()); if (parentKey != null && parentPkMmd != null) { return parentPkMmd.getType().equals(Key.class) ? parentKey : KeyFactory.keyToString(parentKey); } return null; }
private String fetchStringPKField(int fieldNumber) { if (MetaDataUtils.isEncodedPKField(cmd, fieldNumber)) { // If this is an encoded pk field, transform the Key into its String representation. return KeyFactory.keyToString(datastoreEntity.getKey()); } else { if (datastoreEntity.getKey().isComplete() && datastoreEntity.getKey().getName() == null) { // This is trouble, probably an incorrect mapping. throw new NucleusFatalUserException( "The primary key for " + cmd.getFullClassName() + " is an unencoded " + "string but the key of the corresponding entity in the datastore does not have a " + "name. You may want to either change the primary key to be an encoded string " + "(add the \"" + DatastoreManager.ENCODED_PK + "\" extension), change the " + "primary key to be of type " + Key.class.getName() + ", or, if you're certain that " + "this class will never have a parent, change the primary key to be of type Long."); } return datastoreEntity.getKey().getName(); } }
if (MetaDataUtils.isEncodedPKField(getClassMetaData(), fieldNumber)) { return KeyFactory.keyToString(datastoreEntity.getKey()); } else { if (datastoreEntity.getKey().isComplete() && datastoreEntity.getKey().getName() == null) { return null; return KeyFactory.keyToString(parentKey); } else if (MetaDataUtils.isPKNameField(getClassMetaData(), fieldNumber)) { AbstractMemberMetaData mmd = getMetaData(fieldNumber);