本文整理匯總了Java中com.google.appengine.api.datastore.Entity.getProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java Entity.getProperty方法的具體用法?Java Entity.getProperty怎麽用?Java Entity.getProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.appengine.api.datastore.Entity
的用法示例。
在下文中一共展示了Entity.getProperty方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getOptionalProperty
import com.google.appengine.api.datastore.Entity; //導入方法依賴的package包/類
@Nullable public static <T> T getOptionalProperty(
Entity e, String propertyName, Class<T> propertyType)
throws InvalidPropertyException {
Preconditions.checkNotNull(e, "Null entity");
Preconditions.checkNotNull(propertyName, "Null propertyName");
Preconditions.checkNotNull(propertyType, "Null propertyType");
Object value = e.getProperty(propertyName);
if (value == null) {
return null;
}
if (!propertyType.isInstance(value)) {
throw new InvalidPropertyException(e, propertyName, "Expected property type "
+ propertyType + ", found " + value.getClass() + ": " + value);
}
return propertyType.cast(value);
}
示例2: doGet
import com.google.appengine.api.datastore.Entity; //導入方法依賴的package包/類
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("text/html");
resp.getWriter().println("<html><body>");
DatastoreService datastore = DatastoreServiceFactory
.getDatastoreService();
Query query = new Query("SharedList");
query.addSort(Entity.KEY_RESERVED_PROPERTY, SortDirection.ASCENDING);
List<Entity> results = datastore.prepare(query).asList(
FetchOptions.Builder.withDefaults());
for (Entity entity : results) {
String email = (String) entity.getProperty("email");
String productID = (String) entity.getKey().getName();
String productName = (String) entity.getProperty("productName");
Date sharedDate = (Date) entity.getProperty("sharedDate");
resp.getWriter().println(
email + " shared <a href=\"http://www.amazon.com/dp/"
+ productID + "\" target=\"_blank\">" + "<b>"
+ productName + "</b></a>!<br>");
}
resp.getWriter().println("</body></html>");
}
示例3: getEntitiesBrowser
import com.google.appengine.api.datastore.Entity; //導入方法依賴的package包/類
@GET
@Produces(MediaType.TEXT_XML)
public List<SharedProduct> getEntitiesBrowser() {
List<SharedProduct> list = new ArrayList<SharedProduct>();
DatastoreService datastore = DatastoreServiceFactory
.getDatastoreService();
Query query = new Query("SharedList");
query.addSort(Entity.KEY_RESERVED_PROPERTY, SortDirection.ASCENDING);
List<Entity> results = datastore.prepare(query).asList(
FetchOptions.Builder.withDefaults());
for (Entity entity : results) {
String email = (String) entity.getProperty("email");
String productID = (String) entity.getKey().getName();
String productName = (String) entity.getProperty("productName");
Date sharedDate = (Date) entity.getProperty("sharedDate");
list.add(new SharedProduct(email, productID, productName,
sharedDate));
}
return list;
}
示例4: getEntities
import com.google.appengine.api.datastore.Entity; //導入方法依賴的package包/類
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public List<SharedProduct> getEntities() {
List<SharedProduct> list = new ArrayList<SharedProduct>();
DatastoreService datastore = DatastoreServiceFactory
.getDatastoreService();
Query query = new Query("SharedList");
query.addSort(Entity.KEY_RESERVED_PROPERTY, SortDirection.ASCENDING);
List<Entity> results = datastore.prepare(query).asList(
FetchOptions.Builder.withDefaults());
for (Entity entity : results) {
String email = (String) entity.getProperty("email");
String productID = (String) entity.getKey().getName();
String productName = (String) entity.getProperty("productName");
Date sharedDate = (Date) entity.getProperty("sharedDate");
list.add(new SharedProduct(email, productID, productName,
sharedDate));
}
return list;
}
示例5: getHTML
import com.google.appengine.api.datastore.Entity; //導入方法依賴的package包/類
@GET
@Produces(MediaType.TEXT_XML)
public WishlistProduct getHTML() {
DatastoreService datastore = DatastoreServiceFactory
.getDatastoreService();
try {
Key entKey = KeyFactory.createKey(email, productID);
Entity entity = datastore.get(entKey);
String productName = (String) entity.getProperty("productName");
double currentPrice = (double) entity.getProperty("currentPrice");
double lowestPrice = (double) entity.getProperty("lowestPrice");
Date lowestDate = (Date) entity.getProperty("lowestDate");
return new WishlistProduct(productID, productName, currentPrice,
lowestPrice, lowestDate);
} catch (EntityNotFoundException e) {
throw new RuntimeException("GET: Wishlist with " + productID
+ " not found.");
}
}
示例6: get
import com.google.appengine.api.datastore.Entity; //導入方法依賴的package包/類
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public WishlistProduct get() {
DatastoreService datastore = DatastoreServiceFactory
.getDatastoreService();
try {
Key entKey = KeyFactory.createKey(email, productID);
Entity entity = datastore.get(entKey);
String productName = (String) entity.getProperty("productName");
double currentPrice = (double) entity.getProperty("currentPrice");
double lowestPrice = (double) entity.getProperty("lowestPrice");
Date lowestDate = (Date) entity.getProperty("lowestDate");
return new WishlistProduct(productID, productName, currentPrice,
lowestPrice, lowestDate);
} catch (EntityNotFoundException e) {
throw new RuntimeException("GET: Wishlist with " + productID
+ " not found.");
}
}
示例7: DatastoreBackupInfo
import com.google.appengine.api.datastore.Entity; //導入方法依賴的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()));
}
示例8: AnnotatedSentence
import com.google.appengine.api.datastore.Entity; //導入方法依賴的package包/類
/**
* Construct an annotated sentence from a database object.
* @param textSummaryEntity text summary entity from the database.
*/
public AnnotatedSentence(Entity textSummaryEntity) {
this();
sentence = textToString(textSummaryEntity.getProperty("sentence"));
position = (int) (long) textSummaryEntity.getProperty("position");
salience = (double) textSummaryEntity.getProperty("salience");
}
示例9: TextDataStore
import com.google.appengine.api.datastore.Entity; //導入方法依賴的package包/類
public TextDataStore(Entity textEntity,
List<KnowledgeNodeDataStore> keywords,
List<List<KnowledgeNodeDataStore>>
knowledgeNodeDataStoreLst,
List<AnnotatedSentence> annotatedSentenceLst,
int limit) {
super("Text");
keyString = KeyFactory.keyToString(textEntity.getKey());
text = textToString(textEntity.getProperty("rawText"));
type = (int) (long) textEntity.getProperty("type");
this.keywords = keywords;
knowledgeNodeDataStoreList = knowledgeNodeDataStoreLst;
annotatedSentenceList = annotatedSentenceLst;
this.limit = limit;
}
示例10: KnowledgeNodeDataStore
import com.google.appengine.api.datastore.Entity; //導入方法依賴的package包/類
public KnowledgeNodeDataStore(Entity knowledgeGraphEntity) {
name = (String) knowledgeGraphEntity.getProperty("name");
type = (int) (long) knowledgeGraphEntity.getProperty("type");
url = (String) knowledgeGraphEntity.getProperty("URL");
salience = (double) knowledgeGraphEntity.getProperty("salience");
sentimentScore = (int) (long) knowledgeGraphEntity
.getProperty("sentimentScore");
}
示例11: isUpToDate
import com.google.appengine.api.datastore.Entity; //導入方法依賴的package包/類
private boolean isUpToDate(byte[] newHash, UpdateRunLogger logger) {
Entity lastUpdate = logger.getLastRun();
byte[] currentHash = null;
if (lastUpdate != null) {
ShortBlob hash = (ShortBlob) lastUpdate.getProperty("hash");
if (hash != null) {
currentHash = hash.getBytes();
}
}
return Arrays.equals(currentHash, newHash);
}
示例12: getKey
import com.google.appengine.api.datastore.Entity; //導入方法依賴的package包/類
/**
* Gets the access key.
*/
protected String getKey() {
com.google.appengine.api.datastore.DatastoreService datastore = DatastoreServiceFactory
.getDatastoreService();
Key key = KeyFactory.createKey(ENTITY_KIND, ENTITY_KEY);
String apiKey = "";
try {
Entity entity = datastore.get(key);
apiKey = (String) entity.getProperty(ACCESS_KEY_FIELD);
} catch (EntityNotFoundException e) {
mLogger.severe("Exception will retrieving the API Key"
+ e.toString());
}
return apiKey;
}
示例13: postDelete
import com.google.appengine.api.datastore.Entity; //導入方法依賴的package包/類
/**
* To delete an entity with oversized properties, fetch the entity you want to
* delete, delete it and commit the transaction, then pass the entity into
* postDelete().
*/
public void postDelete(Entity entity) {
Preconditions.checkNotNull(entity, "Null entity");
for (MovableProperty property : properties) {
if (entity.hasProperty(property.getMovedPropertyName())) {
BlobKey blobKey = new BlobKey(
(String) entity.getProperty(property.getMovedPropertyName()));
BlobstoreServiceFactory.getBlobstoreService().delete(blobKey);
log.info("Deleted blob for " + property + ": " + blobKey);
listener.blobDeleted(entity.getKey(), property, blobKey);
}
}
}
示例14: getEntitiesBrowser
import com.google.appengine.api.datastore.Entity; //導入方法依賴的package包/類
@GET
@Produces(MediaType.TEXT_XML)
public List<WishlistProduct> getEntitiesBrowser() {
UserService userService = UserServiceFactory.getUserService();
User user = userService.getCurrentUser();
if (user == null) {
System.out.println("Login first");
return null;
}
List<WishlistProduct> list = new ArrayList<WishlistProduct>();
DatastoreService datastore = DatastoreServiceFactory
.getDatastoreService();
Query query = new Query(user.getEmail());
query.addSort(Entity.KEY_RESERVED_PROPERTY, SortDirection.ASCENDING);
List<Entity> results = datastore.prepare(query).asList(
FetchOptions.Builder.withDefaults());
for (Entity entity : results) {
String productID = (String) entity.getKey().getName();
String productName = (String) entity.getProperty("productName");
double currentPrice = (double) entity.getProperty("currentPrice");
double lowestPrice = (double) entity.getProperty("lowestPrice");
Date lowestDate = (Date) entity.getProperty("lowestDate");
list.add(new WishlistProduct(productID, productName, currentPrice,
lowestPrice, lowestDate));
}
return list;
}
示例15: getEntities
import com.google.appengine.api.datastore.Entity; //導入方法依賴的package包/類
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public List<WishlistProduct> getEntities() {
UserService userService = UserServiceFactory.getUserService();
User user = userService.getCurrentUser();
if (user == null) {
System.out.println("Login first");
return null;
}
List<WishlistProduct> list = new ArrayList<WishlistProduct>();
DatastoreService datastore = DatastoreServiceFactory
.getDatastoreService();
Query query = new Query(user.getEmail());
query.addSort(Entity.KEY_RESERVED_PROPERTY, SortDirection.ASCENDING);
List<Entity> results = datastore.prepare(query).asList(
FetchOptions.Builder.withDefaults());
for (Entity entity : results) {
String productID = (String) entity.getKey().getName();
String productName = (String) entity.getProperty("productName");
double currentPrice = (double) entity.getProperty("currentPrice");
double lowestPrice = (double) entity.getProperty("lowestPrice");
Date lowestDate = (Date) entity.getProperty("lowestDate");
list.add(new WishlistProduct(productID, productName, currentPrice,
lowestPrice, lowestDate));
}
return list;
}