当前位置: 首页>>代码示例>>Java>>正文


Java Cursor.fromWebSafeString方法代码示例

本文整理汇总了Java中com.google.appengine.api.datastore.Cursor.fromWebSafeString方法的典型用法代码示例。如果您正苦于以下问题:Java Cursor.fromWebSafeString方法的具体用法?Java Cursor.fromWebSafeString怎么用?Java Cursor.fromWebSafeString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.appengine.api.datastore.Cursor的用法示例。


在下文中一共展示了Cursor.fromWebSafeString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Builder

import com.google.appengine.api.datastore.Cursor; //导入方法依赖的package包/类
private Builder(Class<T> resourceClass, @Nullable UriInfo uriInfo,
    @Nullable MultivaluedMap<String, String> queryParams, int defaultLimit) {
  if (uriInfo != null) {
    queryParams = uriInfo.getQueryParameters();
  }
  this.resourceClass = resourceClass;
  this.uriInfo = uriInfo;
  String afterCursorStr = queryParams.getFirst(PagingInfo.AFTER_CURSOR_PARAM);
  if (afterCursorStr != null) {
    afterCursor = Cursor.fromWebSafeString(afterCursorStr);
  } else {
    afterCursor = null;
  }
  limit = queryParams.containsKey(PagingInfo.LIMIT_PARAM) ?
      Integer.valueOf(queryParams.getFirst(PagingInfo.LIMIT_PARAM)) : defaultLimit;
  if (limit <= 0) {
    throw ErrorResponseMsg.createException("limit must be greater than zero",
      ErrorInfo.Type.BAD_REQUEST);
  }
}
 
开发者ID:karma-exchange-org,项目名称:karma-exchange,代码行数:21,代码来源:PaginatedQuery.java

示例2: testSort

import com.google.appengine.api.datastore.Cursor; //导入方法依赖的package包/类
@Test
public void testSort() {
    int onePage = 6;
    Query query = new Query(kindName, rootKey);
    query.addSort("name", Query.SortDirection.ASCENDING);
    // fetch first page   aa,aa,aa,aa,aa,aa
    Cursor cursor = checkPage(query, null, null, onePage, onePage, testDat[0], testDat[0]);
    Cursor decodedCursor = Cursor.fromWebSafeString(cursor.toWebSafeString());
    // fetch next page    aa,aa,aa,aa,bb,bb
    checkPage(query, decodedCursor, null, onePage, onePage, testDat[0], testDat[1]);

    // desc
    onePage = total / testDat.length;
    query = new Query(kindName, rootKey);
    query.addSort("name", Query.SortDirection.DESCENDING);
    // fetch first page   jj,jj,........,jj,jj
    String chkChar = testDat[testDat.length - 1];
    cursor = checkPage(query, null, null, onePage, onePage, chkChar, chkChar);
    decodedCursor = Cursor.fromWebSafeString(cursor.toWebSafeString());
    // fetch next page   ii,ii,........,ii,ii
    chkChar = testDat[testDat.length - 2];
    checkPage(query, decodedCursor, null, onePage, onePage, chkChar, chkChar);
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:24,代码来源:CursorTest.java

示例3: listAllUsers

import com.google.appengine.api.datastore.Cursor; //导入方法依赖的package包/类
public static List<UserJDO> listAllUsers(PersistenceManager pm, String cursorString) {
	javax.jdo.Query query = pm.newQuery(UserJDO.class);
	if (cursorString != null) {
		Cursor cursor = Cursor.fromWebSafeString(cursorString);
		Map<String, Object> extensionMap = new HashMap<String, Object>();
		extensionMap.put(JDOCursorHelper.CURSOR_EXTENSION, cursor);
		query.setExtensions(extensionMap);
	}
	query.setRange(0, LIMIT);
	return (List<UserJDO>) query.execute();
}
 
开发者ID:WELTEN,项目名称:dojo-ibl,代码行数:12,代码来源:UserManager.java

示例4: listAllRuns

import com.google.appengine.api.datastore.Cursor; //导入方法依赖的package包/类
public static List<RunJDO> listAllRuns(PersistenceManager pm, String cursorString) {
	javax.jdo.Query query = pm.newQuery(RunJDO.class);
	if (cursorString != null) {
		Cursor cursor = Cursor.fromWebSafeString(cursorString);
		Map<String, Object> extensionMap = new HashMap<String, Object>();
		extensionMap.put(JDOCursorHelper.CURSOR_EXTENSION, cursor);
		query.setExtensions(extensionMap);
	}
	query.setRange(0, LIMIT);
	return (List<RunJDO>) query.execute();
}
 
开发者ID:WELTEN,项目名称:dojo-ibl,代码行数:12,代码来源:RunManager.java

示例5: listCategory

import com.google.appengine.api.datastore.Cursor; //导入方法依赖的package包/类
/**
 * This method lists all the entities inserted in datastore.
 * It uses HTTP GET method and paging support.
 *
 * @return A CollectionResponse class containing the list of all entities
 * persisted and a cursor to the next page.
 */
@SuppressWarnings({ "unchecked", "unused" })
@ApiMethod(name = "listCategory")
public CollectionResponse<Category> listCategory(
		@Nullable @Named("cursor") String cursorString,
		@Nullable @Named("limit") Integer limit) {

	EntityManager mgr = null;
	Cursor cursor = null;
	List<Category> execute = null;

	try {
		mgr = getEntityManager();
		Query query = mgr.createQuery("select from Category as Category");
		if (cursorString != null && cursorString != "") {
			cursor = Cursor.fromWebSafeString(cursorString);
			query.setHint(JPACursorHelper.CURSOR_HINT, cursor);
		}

		if (limit != null) {
			query.setFirstResult(0);
			query.setMaxResults(limit);
		}

		execute = (List<Category>) query.getResultList();
		cursor = JPACursorHelper.getCursor(execute);
		if (cursor != null)
			cursorString = cursor.toWebSafeString();

		// Tight loop for fetching all entities from datastore and accomodate
		// for lazy fetch.
		for (Category obj : execute)
			;
	} finally {
		mgr.close();
	}

	return CollectionResponse.<Category> builder().setItems(execute)
			.setNextPageToken(cursorString).build();
}
 
开发者ID:ljug,项目名称:gestionDepenseMobile,代码行数:47,代码来源:CategoryEndpoint.java

示例6: listExpense

import com.google.appengine.api.datastore.Cursor; //导入方法依赖的package包/类
/**
 * This method lists all the entities inserted in datastore.
 * It uses HTTP GET method and paging support.
 *
 * @return A CollectionResponse class containing the list of all entities
 * persisted and a cursor to the next page.
 */
@SuppressWarnings({ "unchecked", "unused" })
@ApiMethod(name = "listExpense")
public CollectionResponse<Expense> listExpense(
		@Nullable @Named("cursor") String cursorString,
		@Nullable @Named("limit") Integer limit) {

	EntityManager mgr = null;
	Cursor cursor = null;
	List<Expense> execute = null;

	try {
		mgr = getEntityManager();
		Query query = mgr.createQuery("select from Expense as Expense");
		if (cursorString != null && cursorString != "") {
			cursor = Cursor.fromWebSafeString(cursorString);
			query.setHint(JPACursorHelper.CURSOR_HINT, cursor);
		}

		if (limit != null) {
			query.setFirstResult(0);
			query.setMaxResults(limit);
		}

		execute = (List<Expense>) query.getResultList();
		cursor = JPACursorHelper.getCursor(execute);
		if (cursor != null)
			cursorString = cursor.toWebSafeString();

		// Tight loop for fetching all entities from datastore and accomodate
		// for lazy fetch.
		for (Expense obj : execute)
			;
	} finally {
		mgr.close();
	}

	return CollectionResponse.<Expense> builder().setItems(execute)
			.setNextPageToken(cursorString).build();
}
 
开发者ID:ljug,项目名称:gestionDepenseMobile,代码行数:47,代码来源:ExpenseEndpoint.java

示例7: listIncome

import com.google.appengine.api.datastore.Cursor; //导入方法依赖的package包/类
/**
 * This method lists all the entities inserted in datastore.
 * It uses HTTP GET method and paging support.
 *
 * @return A CollectionResponse class containing the list of all entities
 * persisted and a cursor to the next page.
 */
@SuppressWarnings({ "unchecked", "unused" })
@ApiMethod(name = "listIncome")
public CollectionResponse<Income> listIncome(
		@Nullable @Named("cursor") String cursorString,
		@Nullable @Named("limit") Integer limit) {

	EntityManager mgr = null;
	Cursor cursor = null;
	List<Income> execute = null;

	try {
		mgr = getEntityManager();
		Query query = mgr.createQuery("select from Income as Income");
		if (cursorString != null && cursorString != "") {
			cursor = Cursor.fromWebSafeString(cursorString);
			query.setHint(JPACursorHelper.CURSOR_HINT, cursor);
		}

		if (limit != null) {
			query.setFirstResult(0);
			query.setMaxResults(limit);
		}

		execute = (List<Income>) query.getResultList();
		cursor = JPACursorHelper.getCursor(execute);
		if (cursor != null)
			cursorString = cursor.toWebSafeString();

		// Tight loop for fetching all entities from datastore and accomodate
		// for lazy fetch.
		for (Income obj : execute)
			;
	} finally {
		mgr.close();
	}

	return CollectionResponse.<Income> builder().setItems(execute)
			.setNextPageToken(cursorString).build();
}
 
开发者ID:ljug,项目名称:gestionDepenseMobile,代码行数:47,代码来源:IncomeEndpoint.java

示例8: listPlace

import com.google.appengine.api.datastore.Cursor; //导入方法依赖的package包/类
/**
 * This method lists all the entities inserted in datastore.
 * It uses HTTP GET method and paging support.
 *
 * @return A CollectionResponse class containing the list of all entities
 * persisted and a cursor to the next page.
 */
@SuppressWarnings({"unchecked", "unused"})
@ApiMethod(name = "listPlace")
public CollectionResponse<Place> listPlace(
    @Nullable @Named("cursor") String cursorString, @Nullable @Named("limit") Integer limit) {

  EntityManager mgr = null;
  Cursor cursor = null;
  List<Place> execute = null;

  try {
    mgr = getEntityManager();
    Query query = mgr.createQuery("select from Place as Place");
    if (cursorString != null && cursorString != "") {
      cursor = Cursor.fromWebSafeString(cursorString);
      query.setHint(JPACursorHelper.CURSOR_HINT, cursor);
    }

    if (limit != null) {
      query.setFirstResult(0);
      query.setMaxResults(limit);
    }

    execute = (List<Place>) query.getResultList();
    cursor = JPACursorHelper.getCursor(execute);
    if (cursor != null) cursorString = cursor.toWebSafeString();

    // Tight loop for fetching all entities from datastore and accomodate
    // for lazy fetch.
    for (Place obj : execute);
  } finally {
    mgr.close();
  }

  return CollectionResponse.<Place>builder()
      .setItems(execute).setNextPageToken(cursorString).build();
}
 
开发者ID:googlearchive,项目名称:solutions-mobile-shopping-assistant-backend-java,代码行数:44,代码来源:PlaceEndpoint.java

示例9: testEndFetch

import com.google.appengine.api.datastore.Cursor; //导入方法依赖的package包/类
@Test
public void testEndFetch() {
    int onePage = total - 30;
    Query query = new Query(kindName, rootKey);
    // fetch first page
    Cursor cursor = checkPage(query, null, null, onePage, onePage, null, null);
    Cursor decodedCursor = Cursor.fromWebSafeString(cursor.toWebSafeString());
    // fetch next page,   get remaining after 1st page.
    checkPage(query, decodedCursor, null, onePage, total - onePage, null, null);
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:11,代码来源:CursorTest.java

示例10: testEndCursor

import com.google.appengine.api.datastore.Cursor; //导入方法依赖的package包/类
@Test
public void testEndCursor() {
    int limit = total / testDat.length;
    Query query = new Query(kindName, rootKey);
    query.addSort("name", Query.SortDirection.ASCENDING);
    // fetch 1st page
    Cursor cursor = checkPage(query, null, null, limit, limit, testDat[0], testDat[0]);
    Cursor decodedCursor = Cursor.fromWebSafeString(cursor.toWebSafeString());
    // fetch 1st page again since using decodedCursor as end cursor
    checkPage(query, null, decodedCursor, limit, limit, testDat[0], testDat[0]);
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:12,代码来源:CursorTest.java

示例11: listDeviceInfo

import com.google.appengine.api.datastore.Cursor; //导入方法依赖的package包/类
/**
 * This method lists all the entities inserted in datastore. It uses HTTP GET method and paging
 * support.
 * 
 * @return A CollectionResponse class containing the list of all entities persisted and a cursor
 *         to the next page.
 */
@SuppressWarnings({"unchecked", "unused"})
@ApiMethod(name = "listDeviceInfo")
public CollectionResponse<DeviceInfo> listDeviceInfo(
    @Nullable @Named("cursor") String cursorString, @Nullable @Named("limit") Integer limit) {

  Cursor cursor = null;
  List<DeviceInfo> execute = null;

  StringBuilder q = new StringBuilder("select from DeviceInfo as d order by timestamp DESC ");
  Query query = em.get().createQuery(q.toString());
  if (cursorString != null && cursorString != "") {
    cursor = Cursor.fromWebSafeString(cursorString);
    query.setHint(JPACursorHelper.CURSOR_HINT, cursor);
  }

  if (limit != null) {
    query.setFirstResult(0);
    query.setMaxResults(limit);
  }

  execute = query.getResultList();
  cursor = JPACursorHelper.getCursor(execute);
  if (cursor != null) {
    cursorString = cursor.toWebSafeString();
  }

  // Tight loop for fetching all entities from datastore and accomodate
  // for lazy fetch.
  for (DeviceInfo obj : execute) {
    ;
  }

  return CollectionResponse.<DeviceInfo> builder().setItems(execute).setNextPageToken(
      cursorString).build();
}
 
开发者ID:larrytin,项目名称:realtime-server-appengine,代码行数:43,代码来源:DeviceEndpoint.java

示例12: listAccountInfo

import com.google.appengine.api.datastore.Cursor; //导入方法依赖的package包/类
@ApiMethod(name = "listAccountInfo")
public CollectionResponse<AccountInfo> listAccountInfo(
    @Nullable @Named("cursor") String cursorString, @Nullable @Named("limit") Integer limit) {

  Cursor cursor = null;

  StringBuilder q = new StringBuilder("select from AccountInfo as a");
  Query query = em.get().createQuery(q.toString());
  if (cursorString != null && cursorString != "") {
    cursor = Cursor.fromWebSafeString(cursorString);
    query.setHint(JPACursorHelper.CURSOR_HINT, cursor);
  }

  if (limit != null) {
    query.setFirstResult(0);
    query.setMaxResults(limit);
  }

  @SuppressWarnings("unchecked")
  List<AccountInfo> execute = query.getResultList();
  cursor = JPACursorHelper.getCursor(execute);
  if (cursor != null) {
    cursorString = cursor.toWebSafeString();
  }

  // Tight loop for fetching all entities from datastore and accomodate
  // for lazy fetch.
  for (AccountInfo obj : execute) {
    ;
  }

  return CollectionResponse.<AccountInfo> builder().setItems(execute).setNextPageToken(
      cursorString).build();
}
 
开发者ID:larrytin,项目名称:realtime-server-appengine,代码行数:35,代码来源:AccountEndpoint.java

示例13: listOffer

import com.google.appengine.api.datastore.Cursor; //导入方法依赖的package包/类
/**
 * This method lists all the entities inserted in datastore.
 * It uses HTTP GET method and paging support.
 *
 * @return A CollectionResponse class containing the list of all entities
 * persisted and a cursor to the next page.
 */
@SuppressWarnings({"unchecked", "unused"})
@ApiMethod(name = "listOffer")
public CollectionResponse<Offer> listOffer(
    @Nullable @Named("cursor") String cursorString, @Nullable @Named("limit") Integer limit) {

  EntityManager mgr = null;
  Cursor cursor = null;
  List<Offer> execute = null;

  try {
    mgr = getEntityManager();
    Query query = mgr.createQuery("select from Offer as Offer");
    if (cursorString != null && cursorString != "") {
      cursor = Cursor.fromWebSafeString(cursorString);
      query.setHint(JPACursorHelper.CURSOR_HINT, cursor);
    }

    if (limit != null) {
      query.setFirstResult(0);
      query.setMaxResults(limit);
    }

    execute = (List<Offer>) query.getResultList();
    cursor = JPACursorHelper.getCursor(execute);
    if (cursor != null) cursorString = cursor.toWebSafeString();

    // Tight loop for fetching all entities from datastore and accomodate
    // for lazy fetch.
    for (Offer obj : execute);
  } finally {
    mgr.close();
  }

  return CollectionResponse.<Offer>builder()
      .setItems(execute).setNextPageToken(cursorString).build();
}
 
开发者ID:googlearchive,项目名称:solutions-mobile-shopping-assistant-backend-java,代码行数:44,代码来源:OfferEndpoint.java

示例14: listRecommendation

import com.google.appengine.api.datastore.Cursor; //导入方法依赖的package包/类
/**
 * This method lists all the entities inserted in datastore.
 * It uses HTTP GET method and paging support.
 *
 * @return A CollectionResponse class containing the list of all entities
 * persisted and a cursor to the next page.
 */
@SuppressWarnings({"unchecked", "unused"})
@ApiMethod(name = "listRecommendation")
public CollectionResponse<Recommendation> listRecommendation(
    @Nullable @Named("cursor") String cursorString, @Nullable @Named("limit") Integer limit) {

  EntityManager mgr = null;
  Cursor cursor = null;
  List<Recommendation> execute = null;

  try {
    mgr = getEntityManager();
    Query query = mgr.createQuery("select from Recommendation as Recommendation");
    if (cursorString != null && cursorString != "") {
      cursor = Cursor.fromWebSafeString(cursorString);
      query.setHint(JPACursorHelper.CURSOR_HINT, cursor);
    }

    if (limit != null) {
      query.setFirstResult(0);
      query.setMaxResults(limit);
    }

    execute = (List<Recommendation>) query.getResultList();
    cursor = JPACursorHelper.getCursor(execute);
    if (cursor != null) cursorString = cursor.toWebSafeString();

    // Tight loop for fetching all entities from datastore and accomodate
    // for lazy fetch.
    for (Recommendation obj : execute);
  } finally {
    mgr.close();
  }

  return CollectionResponse.<Recommendation>builder()
      .setItems(execute).setNextPageToken(cursorString).build();
}
 
开发者ID:googlearchive,项目名称:solutions-mobile-shopping-assistant-backend-java,代码行数:44,代码来源:RecommendationEndpoint.java

示例15: listCheckIn

import com.google.appengine.api.datastore.Cursor; //导入方法依赖的package包/类
/**
 * This method lists all the entities inserted in datastore.
 * It uses HTTP GET method and paging support.
 *
 * @return A CollectionResponse class containing the list of all entities
 * persisted and a cursor to the next page.
 */
@SuppressWarnings({"unchecked", "unused"})
@ApiMethod(name = "listCheckIn")
public CollectionResponse<CheckIn> listCheckIn(
    @Nullable @Named("cursor") String cursorString, @Nullable @Named("limit") Integer limit) {

  EntityManager mgr = null;
  Cursor cursor = null;
  List<CheckIn> execute = null;

  try {
    mgr = getEntityManager();
    Query query = mgr.createQuery("select from CheckIn as CheckIn");
    if (cursorString != null && cursorString != "") {
      cursor = Cursor.fromWebSafeString(cursorString);
      query.setHint(JPACursorHelper.CURSOR_HINT, cursor);
    }

    if (limit != null) {
      query.setFirstResult(0);
      query.setMaxResults(limit);
    }

    execute = (List<CheckIn>) query.getResultList();
    cursor = JPACursorHelper.getCursor(execute);
    if (cursor != null) cursorString = cursor.toWebSafeString();

    // Tight loop for fetching all entities from datastore and accomodate
    // for lazy fetch.
    for (CheckIn obj : execute);
  } finally {
    mgr.close();
  }

  return CollectionResponse.<CheckIn>builder()
      .setItems(execute).setNextPageToken(cursorString).build();
}
 
开发者ID:googlearchive,项目名称:solutions-mobile-shopping-assistant-backend-java,代码行数:44,代码来源:CheckInEndpoint.java


注:本文中的com.google.appengine.api.datastore.Cursor.fromWebSafeString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。