本文整理汇总了Java中com.google.appengine.api.datastore.Text类的典型用法代码示例。如果您正苦于以下问题:Java Text类的具体用法?Java Text怎么用?Java Text使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Text类属于com.google.appengine.api.datastore包,在下文中一共展示了Text类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import com.google.appengine.api.datastore.Text; //导入依赖的package包/类
@Override
public void process() {
UserService userService = UserServiceFactory.getUserService();
// Step 1: Add Text into DB.
Entity textEntity = getNewEntity();
textEntity.setProperty("rawText", new Text(text));
textEntity.setProperty("user",
userService.getCurrentUser().getNickname());
textEntity.setProperty("date", new Date());
putIntoDatabase(textEntity);
Key parentKey = textEntity.getKey();
factory.setParentKey(parentKey);
// Step 2: Call other processors.
factory.createTypePredictor().process();
factory.createKnowledgeGraphBuilder().process();
factory.createSummaryGenerator().process();
}
示例2: parseWaveletEntity
import com.google.appengine.api.datastore.Text; //导入依赖的package包/类
private RemoteConvWavelet parseWaveletEntity(Entity entity) {
Pair<SourceInstance, WaveletName> instanceAndWaveId = parseWaveletKey(entity.getKey());
try {
RobotSearchDigest digest = GsonProto.fromGson(new RobotSearchDigestGsonImpl(),
DatastoreUtil.getExistingProperty(entity, WAVELET_DIGEST_PROPERTY, Text.class)
.getValue());
Assert.check(
instanceAndWaveId.getSecond().waveId.equals(WaveId.deserialise(digest.getWaveId())),
"Wave id mismatch: %s, %s", instanceAndWaveId, entity);
Assert.check(DatastoreUtil.getExistingProperty(
entity, WAVELET_LAST_MODIFIED_MILLIS_PROPERTY, Long.class)
.equals(digest.getLastModifiedMillis()),
"Mismatched last modified times: %s, %s", digest, entity);
@Nullable String privateLocalId = DatastoreUtil.getOptionalProperty(
entity, WAVELET_PRIVATE_LOCAL_ID_PROPERTY, String.class);
@Nullable String sharedLocalId = DatastoreUtil.getOptionalProperty(
entity, WAVELET_SHARED_LOCAL_ID_PROPERTY, String.class);
return new RemoteConvWavelet(instanceAndWaveId.getFirst(), digest,
instanceAndWaveId.getSecond().waveletId,
privateLocalId == null ? null : new SlobId(privateLocalId),
sharedLocalId == null ? null : new SlobId(sharedLocalId));
} catch (MessageException e) {
throw new RuntimeException("Failed to parse wave entity: " + entity, e);
}
}
示例3: get
import com.google.appengine.api.datastore.Text; //导入依赖的package包/类
public ConvMetadataGsonImpl get(CheckedTransaction tx, SlobId convId)
throws PermanentFailure, RetryableFailure {
checkNotNull(tx, "Null tx");
checkNotNull(convId, "Null convId");
Entity entity = tx.get(makeKey(convId));
if (entity == null) {
log.info("No conv metadata found, using default");
return new ConvMetadataGsonImpl();
}
String metadataString =
DatastoreUtil.getExistingProperty(entity, PROPERTY, Text.class).getValue();
log.info("Found conv metadata: " + metadataString);
ConvMetadataGsonImpl metadata;
try {
metadata = GsonProto.fromGson(new ConvMetadataGsonImpl(), metadataString);
} catch (MessageException e) {
throw new RuntimeException("Failed to parse metadata: " + metadataString, e);
}
return metadata;
}
示例4: CryptonomicaUser
import com.google.appengine.api.datastore.Text; //导入依赖的package包/类
public CryptonomicaUser(User googleUser,
PGPPublicKeyData pgpPublicKeyData,
NewUserRegistrationForm newUserRegistrationForm) {
this.userId = googleUser.getUserId();
this.webSafeStringKey = Key.create(
CryptonomicaUser.class, googleUser.getUserId()
).toWebSafeString();
this.firstName = pgpPublicKeyData.getFirstName().toLowerCase();
this.lastName = pgpPublicKeyData.getLastName().toLowerCase();
this.birthday = newUserRegistrationForm.getBirthday();
this.googleUser = googleUser;
if (googleUser.getEmail() != null) {
this.email = new Email(googleUser.getEmail().toLowerCase()); // or email = pgpPublicKeyData.getUserEmail()
}
if (newUserRegistrationForm.getUserInfo() != null) {
this.userInfo = new Text(newUserRegistrationForm.getUserInfo());
}
this.publicKeys = new ArrayList<>();
Key<CryptonomicaUser> cryptonomicaUserKey = Key.create(CryptonomicaUser.class, googleUser.getUserId());
this.publicKeys.add(
Key.create(
cryptonomicaUserKey, PGPPublicKeyData.class, pgpPublicKeyData.getFingerprint()
)
);
}
示例5: DatastoreBackupInfo
import com.google.appengine.api.datastore.Text; //导入依赖的package包/类
/** DatastoreBackupInfo instances should only be obtained via DatastoreBackupService. */
DatastoreBackupInfo(Entity backupEntity) {
backupName = (String) checkNotNull(backupEntity.getProperty("name"), "name");
@SuppressWarnings("unchecked")
List<String> rawKinds = (List<String>) checkNotNull(backupEntity.getProperty("kinds"), "kinds");
Date rawStartTime = (Date) checkNotNull(backupEntity.getProperty("start_time"), "start_time");
Date rawCompleteTime = (Date) backupEntity.getProperty("complete_time");
Text rawGcsFilename = (Text) backupEntity.getProperty("gs_handle");
kinds = ImmutableSet.copyOf(rawKinds);
startTime = new DateTime(rawStartTime).withZone(UTC);
completeTime = Optional.ofNullable(
rawCompleteTime == null ? null : new DateTime(rawCompleteTime).withZone(UTC));
gcsFilename = Optional.ofNullable(
rawGcsFilename == null ? null : gcsPathToUri(rawGcsFilename.getValue()));
}
示例6: putEntity
import com.google.appengine.api.datastore.Text; //导入依赖的package包/类
/**
* Internal routine to serialize and save the column lengths map.
*
* @param e
* @param lenMap
* @param dam
* @param datastore
* @param user
*/
private void putEntity(Entity e, Map<String, Long> lenMap, DatastoreAccessMetrics dam, DatastoreImpl datastore, User user ) {
logger.info(e.getKey().getName());
// build up the string that will be saved in BigTables
StringBuilder b = new StringBuilder();
for ( Map.Entry<String, Long> entry : lenMap.entrySet() ) {
String k = entry.getKey();
Long v = entry.getValue();
b.append(k).append(" ").append(v).append(" ");
}
e.setProperty(LENGTH_MAPPING, new Text(b.toString()));
datastore.getDatastoreService().put(e);
dam.recordPutUsage(TABLE_NAME);
}
示例7: addObjectInstance
import com.google.appengine.api.datastore.Text; //导入依赖的package包/类
/**
* Add object instance
*
* @param instance The object instance
*/
public void addObjectInstance(WebObjectInstance instance) {
String uri = instance.getUri();
// Also insert object if not present yet
if (!isObjectRegistered(uri)) {
addObject(uri);
}
Entity webObjectInstance = new Entity(OBJECT_INSTANCE);
webObjectInstance.setProperty("uri", instance.getUri());
webObjectInstance.setProperty("content",
new Text(instance.getContent()));
webObjectInstance.setProperty("contentType", instance.getContentType());
webObjectInstance.setProperty("timestamp", instance.getTimestamp());
webObjectInstance.setProperty("statusCode", instance.getStatusCode());
datastoreService.put(webObjectInstance);
}
示例8: getAllObjectInstances
import com.google.appengine.api.datastore.Text; //导入依赖的package包/类
/**
* Get all instances of an object present in the data store
*
* @param uri The URI of the Web object
* @return The list of Web instances
*/
public List<WebObjectInstance> getAllObjectInstances(String uri) {
Filter uriFilter = new FilterPredicate("uri", FilterOperator.EQUAL, uri);
Query query = new Query(OBJECT_INSTANCE)
.setFilter(uriFilter)
.addSort("timestamp", SortDirection.DESCENDING);
List<Entity> instances = datastoreService.prepare(query)
.asList(FetchOptions.Builder.withDefaults());
List<WebObjectInstance> instanceList = new ArrayList<WebObjectInstance>();
for (Entity e : instances) {
String content = ((Text) e.getProperty("content")).getValue();
String contentType = (String) e.getProperty("contentType");
int statusCode = ((Integer) e.getProperty("statusCode")).intValue();
Date timestamp = (Date) e.getProperty("timestamp");
instanceList.add(new WebObjectInstance(uri, content, contentType,
timestamp, statusCode));
}
return instanceList;
}
示例9: getMostRecentObjectInstance
import com.google.appengine.api.datastore.Text; //导入依赖的package包/类
/**
* Get the most recent instance of a web object available
*
* @param uri The URI of the Web object
* @return The instance of the Web object
*/
public WebObjectInstance getMostRecentObjectInstance(String uri) {
Filter uriFilter = new FilterPredicate("uri", FilterOperator.EQUAL, uri);
Query query = new Query(OBJECT_INSTANCE)
.setFilter(uriFilter)
.addSort("timestamp", SortDirection.DESCENDING);
List<Entity> instances = datastoreService.prepare(query).asList(
FetchOptions.Builder.withDefaults());
if (instances == null || instances.isEmpty()) {
return null;
}
Entity mostRecentInstance = instances.get(0);
String content = ((Text) mostRecentInstance.getProperty("content"))
.getValue();
String contentType = (String) mostRecentInstance
.getProperty("contentType");
Date timestamp = (Date) mostRecentInstance.getProperty("timestamp");
int statusCode = ((Long) mostRecentInstance.getProperty("statusCode"))
.intValue();
return new WebObjectInstance(uri, content, contentType, timestamp,
statusCode);
}
示例10: doPost
import com.google.appengine.api.datastore.Text; //导入依赖的package包/类
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String identifier = req.getParameter("identifier");
String content = req.getParameter("content");
if (identifier != null && content != null) {
Text contentText = new Text(content);
PersistenceManager pm = PMF.get().getPersistenceManager();
Template template = new TemplateManager( pm ).findById( identifier );
template.setContent(contentText);
pm.close();
}
resp.sendRedirect("/admin/template/");
}
示例11: doPost
import com.google.appengine.api.datastore.Text; //导入依赖的package包/类
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String identifier = req.getParameter("identifier");
String content = req.getParameter("content");
if (identifier != null && content != null) {
Text text = new Text(content);
Template template = new Template();
template.setIdentifier(identifier);
template.setContent(text);
PersistenceManager pm = PMF.get().getPersistenceManager();
pm.makePersistent(template);
pm.close();
}
resp.sendRedirect("/admin/template/");
}
示例12: addUser
import com.google.appengine.api.datastore.Text; //导入依赖的package包/类
public static void addUser(User bean) {
PersistenceManager pm = PMF.get().getPersistenceManager();
UserJDO user = new UserJDO();
user.setTeamId(bean.getTeamId());
user.setRunId(bean.getRunId());
user.setEmail(bean.getFullId());
user.setGameId(bean.getGameId());
Long currentTime = System.currentTimeMillis();
user.setLastModificationDate(currentTime);
user.setLastModificationDateGame(currentTime);
if (bean.getDeleted()!= null && bean.getDeleted()) user.setDeleted(bean.getDeleted());
user.setId();
JsonBeanSerialiser jbs = new JsonBeanSerialiser(bean);
user.setPayload(new Text(jbs.serialiseToJson().toString()));
try {
pm.makePersistent(user);
} finally {
pm.close();
}
}
示例13: createVariableDefinition
import com.google.appengine.api.datastore.Text; //导入依赖的package包/类
public static VariableEffectDefinition createVariableDefinition(VariableEffectDefinition variableDefinition) {
PersistenceManager pm = PMF.get().getPersistenceManager();
VariableEffectDefinitionJDO variableEffectDefinitionJDO = new VariableEffectDefinitionJDO();
variableEffectDefinitionJDO.setName(variableDefinition.getName());
variableEffectDefinitionJDO.setGameId(variableDefinition.getGameId());
variableEffectDefinitionJDO.setEffectValue(variableDefinition.getEffectValue());
variableEffectDefinitionJDO.setEffectType(variableDefinition.getEffectType());
if (variableDefinition.getEffectCount() == null) variableDefinition.setEffectCount(1);
variableEffectDefinitionJDO.setEffectCount(variableDefinition.getEffectCount());
if (variableDefinition.getId() != null) variableEffectDefinitionJDO.setIdentifier(variableDefinition.getId());
JsonBeanSerialiser jbs = new JsonBeanSerialiser(variableDefinition.getDependsOn());
if (variableDefinition.getDependsOn() != null) variableEffectDefinitionJDO.setDependsOn(new Text(jbs.serialiseToJson().toString()));
try {
pm.makePersistent(variableEffectDefinitionJDO);
return toBean(variableEffectDefinitionJDO);
} finally {
pm.close();
}
}
示例14: addRun
import com.google.appengine.api.datastore.Text; //导入依赖的package包/类
public static Long addRun(String title, String owner, Long gameId, Long runId, Long startTime, Long serverCreationTime, Run run) {
PersistenceManager pm = PMF.get().getPersistenceManager();
RunJDO runJdo = new RunJDO();
runJdo.setGameId(gameId);
runJdo.setRunId(runId);
runJdo.setOwner(owner);
runJdo.setTitle(title);
runJdo.setStartTime(startTime);
runJdo.setServerCreationTime(serverCreationTime);
runJdo.setLastModificationDate(serverCreationTime);
runJdo.setPayload(new Text(run.toString()));
runJdo.setCode(run.getCode());
runJdo.setAvoidNotification(run.getAvoidNotification());
if (run.getRunConfig() != null) {
runJdo.setTagId(run.getRunConfig().getNfcTag());
}
try {
return pm.makePersistent(runJdo).getRunId();
} finally {
pm.close();
}
}
示例15: convert
import com.google.appengine.api.datastore.Text; //导入依赖的package包/类
@Override
public EntityImpl convert() {
EntityImpl entity =
entity_.getParent() == null ? new EntityImpl(entity_.getKind(), Long.toString(entity_
.getKey().getId(), 10)) : new EntityImpl(entity_.getKind(), Long.toString(entity_
.getKey().getId(), 10), entity_.getParent().getKind(), Long.toString(entity_
.getParent().getId(), 10));
for (String propertyName : entity_.getProperties().keySet()) {
Object propertyValue = entity_.getProperty(propertyName);
if (propertyValue instanceof Text) {
entity.setProperty(propertyName, ((Text) propertyValue).getValue());
} else if (propertyValue instanceof Date) {
entity.setProperty(propertyName, new Timestamp(((Date) propertyValue).getTime()));
} else {
entity.setProperty(propertyName, propertyValue);
}
}
return entity;
}