com.google.gdata.client.Query类的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(12.1k)|赞(0)|评价(0)|浏览(130)

本文整理了Java中com.google.gdata.client.Query类的一些代码示例,展示了Query类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query类的具体详情如下:
包路径:com.google.gdata.client.Query
类名称:Query

Query介绍

[英]The Query class is a helper class that aids in the construction of a GData query. It provides a simple API and object model that exposes query parameters. Once constructed, the query can be executed against a GData service.

The Query class also acts as a simple base class for GData services that support custom query parameters. These services can subclass the base Query class, add APIs to represent service query parameters, and participate in the Query URI generation process.
[中]查询类是一个帮助器类,帮助构造GData查询。它提供了一个简单的API和对象模型来公开查询参数。一旦构造好,就可以对GData服务执行查询。
查询类还充当支持自定义查询参数的GData服务的简单基类。这些服务可以对基本查询类进行子类化,添加API来表示服务查询参数,并参与查询URI生成过程。

代码示例

代码示例来源:origin: com.mulesoft.google/google-api-gdata

/**
 * Sets an integer custom paramter, with null signifying to clear the
 * parameter.
 * 
 * @param name the parameter name
 * @param value the value to set it to
 */
public final void setIntegerCustomParameter(String name, Integer value) {
 if (value == null) {
  setStringCustomParameter(name, null);
 } else {
  setStringCustomParameter(name, value.toString());
 }
}

代码示例来源:origin: com.google.gdata/gdata-core-1.0

/**
 * Sets a string custom parameter, with null signifying to clear the
 * parameter.
 *
 * @param name the name of the parameter
 * @param value the value to set it to
 */
public final void setStringCustomParameter(String name, String value) {
 List<CustomParameter> customParams = getCustomParameters();
 for (CustomParameter existingValue : getCustomParameters(name)) {
  customParams.remove(existingValue);
 }
 if (value != null) {
  customParams.add(new CustomParameter(name, value));
 }
}

代码示例来源:origin: com.google.gdata/gdata-java-client

/**
  * Gets an existing Integer custom paramter, with null signifying that
  * the parameter is not specified or not an integer.
  * 
  * @param name the name of the parameter
  * @return the value of the parameter, or null if it is unspecified
  *         or non-integer
  */
 public final Integer getIntegerCustomParameter(String name) {
  String strValue = getStringCustomParameter(name);
  Integer intValue;

  if (strValue != null) {
   try {
    intValue = Integer.valueOf(Integer.parseInt(strValue));
   } catch (NumberFormatException nfe) {
    intValue = null;
   }
  } else {
   intValue = null;
  }

  return intValue;
 }
}

代码示例来源:origin: wso2-attic/esb-connectors

contactQuery.setFullTextQuery(query);
contactQuery.setMaxResults(Integer.parseInt(maxResults));
contactQuery.setStartIndex(Integer.parseInt(startIndex));
contactQuery.setUpdatedMin(DateTime.parseDateTime(updatedMin));
contactQuery.setStringCustomParameter(Constants.PARAM_ORDER_BY, orderBy);
contactQuery.setStringCustomParameter(Constants.PARAM_SHOW_DELETED, showDeleted);
contactQuery.setStringCustomParameter(Constants.PARAM_REQUIRE_ALL_DELETED, allDeleted);
contactQuery.setStringCustomParameter(Constants.PARAM_SORT_ORDER, sortOrder);
contactQuery.setStringCustomParameter(Constants.GROUP, group);

代码示例来源:origin: wso2-attic/esb-connectors

Query contactQuery = new Query(feedUrl);
  contactQuery.setFullTextQuery(query);
  contactQuery.setMaxResults(Integer.parseInt(maxResults));
  contactQuery.setStartIndex(Integer.parseInt(startIndex));
  contactQuery.setUpdatedMin(DateTime.parseDateTime(updatedMin));

代码示例来源:origin: com.mulesoft.google/google-api-gdata

@Override
public <F extends IFeed> F getFeed(Query query, Class<F> feedClass,
  String etag) throws IOException, ServiceException {
 try {
  return super.getFeed(query, feedClass, etag);
 } catch (RedirectRequiredException e) {
  query = new Query(handleRedirectException(e));
 } catch (SessionExpiredException e) {
  handleSessionExpiredException(e);
 }
 return super.getFeed(query, feedClass, etag);
}

代码示例来源:origin: com.google.gdata/gdata-core-1.0

if (!isValidState()) {
 throw new IllegalStateException("Unsupported Query");
  appendQueryParameter(queryBuf, GDataProtocol.Query.FULL_TEXT,
    CharEscapers.uriEscaper().escape(queryString));
  appendQueryParameter(queryBuf, GDataProtocol.Query.AUTHOR,
    CharEscapers.uriEscaper().escape(author));
  appendQueryParameter(queryBuf, GDataProtocol.Parameter.ALT, 
    resultFormat.paramValue());
  appendQueryParameter(queryBuf, GDataProtocol.Query.UPDATED_MIN,
    CharEscapers.uriEscaper().escape(updatedMin.toString()));
  appendQueryParameter(queryBuf, GDataProtocol.Query.UPDATED_MAX,
    CharEscapers.uriEscaper().escape(updatedMax.toString()));
  appendQueryParameter(queryBuf, GDataProtocol.Query.PUBLISHED_MIN,
    CharEscapers.uriEscaper().escape(publishedMin.toString()));
  appendQueryParameter(queryBuf, GDataProtocol.Query.PUBLISHED_MAX,
    CharEscapers.uriEscaper().escape(publishedMax.toString()));
  appendQueryParameter(queryBuf, GDataProtocol.Query.START_INDEX,
    Integer.toString(startIndex));
  appendQueryParameter(queryBuf, GDataProtocol.Query.MAX_RESULTS,
    Integer.toString(maxResults));

代码示例来源:origin: com.google.gdata/gdata-java-client

@SuppressWarnings("unused")
public GDataRequest getRequest(Query query, ContentType contentType)
  throws IOException, ServiceException {
 return getRequest(RequestType.QUERY, query.getUrl(), contentType);
}

代码示例来源:origin: com.google.gdata/gdata-java-client

/**
 * Returns the Query URL that encapsulates the current state of this
 * query object.
 *
 * @return URL that represents the query against the target feed.
 */
public URL getUrl() {
 try {
  String queryUri = getQueryUri().toString();
  if (queryUri.length() == 0) {
   return feedUrl;
  }
  // Build the full query URL.  An earlier implementation of this
  // was done using URI.resolve(), but there are issues if both the
  // base and relative URIs contain path components (the last path
  // element on the base will be removed).
  String feedRoot = feedUrl.toString();
  StringBuilder urlBuf = new StringBuilder(feedRoot);
  if (!feedRoot.endsWith("/") && !queryUri.startsWith("?")) {
   urlBuf.append('/');
  }
  urlBuf.append(queryUri);
  return new URL(urlBuf.toString());
 // Since we are combining a valid URL and a valid URI,
 // any exception thrown below is not a user error.
 } catch (MalformedURLException mue) {
  throw new IllegalStateException("Unable to create query URL", mue);
 }
}

代码示例来源:origin: sih4sing5hong5/google-sites-liberation

/**
 * Returns an iterator containing the valid entries with indices between
 * {@code start} and {@code start}+{@code num}-1 and the number of entries
 * the iterator contains. 
 */
private Pair<Iterator<BaseContentEntry<?>>, Integer>
  getEntries(int start, int num) {
 Query query = new ContentQuery(feedUrl);
 try {
  int numReturned = 0;
  Iterator<BaseContentEntry<?>> itr = Iterators.emptyIterator();
  List<BaseContentEntry<?>> entries;
  do {
   query.setStartIndex(start + numReturned);
   query.setMaxResults(num - numReturned);
   entries = entryProvider.getEntries(query, sitesService);
   numReturned += entries.size();
   itr = Iterators.concat(itr, entries.iterator());
  } while (numReturned < num && entries.size() > 0);
  return Pair.of(itr, numReturned);
 } catch (IOException e) {
  return catchException(e, start, num);
 } catch (ServiceException e) {
  return catchException(e, start, num);
 }
}

代码示例来源:origin: com.google.gdata/gdata-java-client

/**
 * Sets the full-text query.
 * 
 * Matched entries must contain all the specified words somewhere in the
 * input.
 * 
 * @param query the full-text query string such as "Sonja Georgia"
 */
public void setFullTextQuery(String query) {
 
 // overrides super simply for the javadoc
 super.setFullTextQuery(query);
}

代码示例来源:origin: com.google.gdata/gdata-core-1.0

@Override
public <F extends IFeed> F getFeed(Query query, Class<F> feedClass, 
  String etag) throws IOException, ServiceException {
 try {
  return super.getFeed(query, feedClass, etag);
 } catch (RedirectRequiredException e) {
  query = new Query(handleRedirectException(e));
 } catch (SessionExpiredException e) {
  handleSessionExpiredException(e);
 }
 return super.getFeed(query, feedClass, etag);
}

代码示例来源:origin: com.mulesoft.google/google-api-gdata

if (!isValidState()) {
 throw new IllegalStateException("Unsupported Query");
  appendQueryParameter(queryBuf, GDataProtocol.Query.FULL_TEXT,
    CharEscapers.uriEscaper().escape(queryString));
  appendQueryParameter(queryBuf, GDataProtocol.Query.AUTHOR,
    CharEscapers.uriEscaper().escape(author));
  appendQueryParameter(queryBuf, GDataProtocol.Parameter.ALT, 
    resultFormat.paramValue());
  appendQueryParameter(queryBuf, GDataProtocol.Query.UPDATED_MIN,
    CharEscapers.uriEscaper().escape(updatedMin.toString()));
  appendQueryParameter(queryBuf, GDataProtocol.Query.UPDATED_MAX,
    CharEscapers.uriEscaper().escape(updatedMax.toString()));
  appendQueryParameter(queryBuf, GDataProtocol.Query.PUBLISHED_MIN,
    CharEscapers.uriEscaper().escape(publishedMin.toString()));
  appendQueryParameter(queryBuf, GDataProtocol.Query.PUBLISHED_MAX,
    CharEscapers.uriEscaper().escape(publishedMax.toString()));
  appendQueryParameter(queryBuf, GDataProtocol.Query.START_INDEX,
    Integer.toString(startIndex));
  appendQueryParameter(queryBuf, GDataProtocol.Query.MAX_RESULTS,
    Integer.toString(maxResults));

代码示例来源:origin: com.google.gdata/gdata-core-1.0

@SuppressWarnings("unused")
public GDataRequest getRequest(Query query, ContentType contentType)
  throws IOException, ServiceException {
 return getRequest(RequestType.QUERY, query.getUrl(), contentType);
}

代码示例来源:origin: com.google.gdata/gdata-core-1.0

/**
 * Returns the Query URL that encapsulates the current state of this
 * query object.
 *
 * @return URL that represents the query against the target feed.
 */
public URL getUrl() {
 try {
  String queryUri = getQueryUri().toString();
  if (queryUri.length() == 0) {
   return feedUrl;
  }
  // Build the full query URL.  An earlier implementation of this
  // was done using URI.resolve(), but there are issues if both the
  // base and relative URIs contain path components (the last path
  // element on the base will be removed).
  String feedRoot = feedUrl.toString();
  StringBuilder urlBuf = new StringBuilder(feedRoot);
  if (!feedRoot.endsWith("/") && !queryUri.startsWith("?")) {
   urlBuf.append('/');
  }
  urlBuf.append(queryUri);
  return new URL(urlBuf.toString());
 // Since we are combining a valid URL and a valid URI,
 // any exception thrown below is not a user error.
 } catch (MalformedURLException mue) {
  throw new IllegalStateException("Unable to create query URL", mue);
 }
}

代码示例来源:origin: com.mulesoft.google/google-api-gdata

/**
 * Sets the full-text query.
 * 
 * Matched entries must contain all the specified words somewhere in the
 * input.
 * 
 * @param query the full-text query string such as "Sonja Georgia"
 */
public void setFullTextQuery(String query) {
 
 // overrides super simply for the javadoc
 super.setFullTextQuery(query);
}

代码示例来源:origin: com.google.gdata/gdata-java-client

@Override
public <F extends IFeed> F getFeed(Query query, Class<F> feedClass, 
  String etag) throws IOException, ServiceException {
 try {
  return super.getFeed(query, feedClass, etag);
 } catch (RedirectRequiredException e) {
  query = new Query(handleRedirectException(e));
 } catch (SessionExpiredException e) {
  handleSessionExpiredException(e);
 }
 return super.getFeed(query, feedClass, etag);
}

代码示例来源:origin: com.google.gdata/gdata-java-client

if (!isValidState()) {
 throw new IllegalStateException("Unsupported Query");
  appendQueryParameter(queryBuf, GDataProtocol.Query.FULL_TEXT,
    CharEscapers.uriEscaper().escape(queryString));
  appendQueryParameter(queryBuf, GDataProtocol.Query.AUTHOR,
    CharEscapers.uriEscaper().escape(author));
  appendQueryParameter(queryBuf, GDataProtocol.Parameter.ALT, 
    resultFormat.paramValue());
  appendQueryParameter(queryBuf, GDataProtocol.Query.UPDATED_MIN,
    CharEscapers.uriEscaper().escape(updatedMin.toString()));
  appendQueryParameter(queryBuf, GDataProtocol.Query.UPDATED_MAX,
    CharEscapers.uriEscaper().escape(updatedMax.toString()));
  appendQueryParameter(queryBuf, GDataProtocol.Query.PUBLISHED_MIN,
    CharEscapers.uriEscaper().escape(publishedMin.toString()));
  appendQueryParameter(queryBuf, GDataProtocol.Query.PUBLISHED_MAX,
    CharEscapers.uriEscaper().escape(publishedMax.toString()));
  appendQueryParameter(queryBuf, GDataProtocol.Query.START_INDEX,
    Integer.toString(startIndex));
  appendQueryParameter(queryBuf, GDataProtocol.Query.MAX_RESULTS,
    Integer.toString(maxResults));

代码示例来源:origin: com.google.gdata/gdata-java-client

/**
 * Sets an integer custom paramter, with null signifying to clear the
 * parameter.
 * 
 * @param name the parameter name
 * @param value the value to set it to
 */
public final void setIntegerCustomParameter(String name, Integer value) {
 if (value == null) {
  setStringCustomParameter(name, null);
 } else {
  setStringCustomParameter(name, value.toString());
 }
}

代码示例来源:origin: com.mulesoft.google/google-api-gdata

/**
 * Sets a string custom parameter, with null signifying to clear the
 * parameter.
 *
 * @param name the name of the parameter
 * @param value the value to set it to
 */
public final void setStringCustomParameter(String name, String value) {
 List<CustomParameter> customParams = getCustomParameters();
 for (CustomParameter existingValue : getCustomParameters(name)) {
  customParams.remove(existingValue);
 }
 if (value != null) {
  customParams.add(new CustomParameter(name, value));
 }
}

相关文章