本文整理汇总了Java中com.sun.jersey.api.uri.UriComponent类的典型用法代码示例。如果您正苦于以下问题:Java UriComponent类的具体用法?Java UriComponent怎么用?Java UriComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UriComponent类属于com.sun.jersey.api.uri包,在下文中一共展示了UriComponent类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configRequest
import com.sun.jersey.api.uri.UriComponent; //导入依赖的package包/类
private static <T> JerseyRequest<T> configRequest(JerseyRequest<T> request, String[] path, ErrorHandler errorHandler) {
request.errorHandler = errorHandler != null ? errorHandler : new DefaultErrorHandler();
boolean validatNnext = true;
for (String pathElem : path) {
if (validatNnext) {
if (!UriComponent.valid(pathElem, UriComponent.Type.PATH_SEGMENT)) {
pathElem = UriComponent.contextualEncode(pathElem, UriComponent.Type.PATH_SEGMENT);
}
if (pathElem.equals("inputControls")) {
validatNnext = false;
}
} else {
validatNnext = true;
}
request.setPath(pathElem);
}
return request;
}
示例2: createQueryInfo
import com.sun.jersey.api.uri.UriComponent; //导入依赖的package包/类
/**
* QueryInfoを生成.
* @param requestQuery requestQuery
* @return requestQuery
*/
public static QueryInfo createQueryInfo(String requestQuery) {
MultivaluedMap<String, String> queryParams = UriComponent.decodeQuery(requestQuery, true);
Integer top = QueryParser.parseTopQuery(queryParams.getFirst("$top"));
Integer skip = QueryParser.parseSkipQuery(queryParams.getFirst("$skip"));
BoolCommonExpression filter = QueryParser.parseFilterQuery(queryParams.getFirst("$filter"));
List<EntitySimpleProperty> select = QueryParser.parseSelectQuery(queryParams.getFirst("$select"));
List<EntitySimpleProperty> expand = QueryParser.parseExpandQuery(queryParams.getFirst("$expand"));
InlineCount inlineCount = QueryParser.parseInlinecountQuery(queryParams.getFirst("$inlinecount"));
String skipToken = QueryParser.parseSkipTokenQuery(queryParams.getFirst("$skiptoken"));
List<OrderByExpression> orderBy = QueryParser.parseOderByQuery(queryParams.getFirst("$orderby"));
parseFullTextSearchQuery(queryParams.getFirst("q"));
// $expand指定時は$topの最大値が変わるためチェックする
if (expand != null && top != null && top > PersoniumUnitConfig.getTopQueryMaxSizeWithExpand()) {
// Integerでそのまま値を返却すると、カンマが付くため、文字列でエラーメッセージを返却する
throw PersoniumCoreException.OData.QUERY_INVALID_ERROR.params("$top", top.toString());
}
Map<String, String> customOptions = new HashMap<String, String>();
customOptions.put("q", queryParams.getFirst("q"));
QueryInfo queryInfo = new QueryInfo(
inlineCount,
top,
skip,
filter,
orderBy,
skipToken,
customOptions,
expand,
select);
return queryInfo;
}
示例3: doFilter
import com.sun.jersey.api.uri.UriComponent; //导入依赖的package包/类
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
throws ServletException, IOException {
HttpServletRequest request = (HttpServletRequest) req;
String httpMethod = request.getMethod();
String requestURI = request.getRequestURI();
String queryString = request.getQueryString();
MultivaluedMap<String, String> queryParams;
String interfaceName = null;
String methodName = null;
if (!Strings.isNullOrEmpty(queryString)) {
queryParams = UriComponent.decodeQuery(queryString, true, true);
interfaceName = queryParams.getFirst("interface");
methodName = queryParams.getFirst("method");
}
if(Strings.isNullOrEmpty(interfaceName))
interfaceName = "/";
if ("GET".equals(httpMethod) && !Strings.isNullOrEmpty(interfaceName) && !Strings.isNullOrEmpty(methodName)) {
if (!requestURI.endsWith("/"))
requestURI += "/";
final String newURI;
if("/".equals(interfaceName))
newURI = requestURI + methodName;
else
newURI = requestURI + interfaceName + "/" + methodName;
req.getRequestDispatcher(newURI).forward(req, res);
} else {
chain.doFilter(req, res);
}
}
示例4: createMultivalueMap
import com.sun.jersey.api.uri.UriComponent; //导入依赖的package包/类
MultivaluedMapImpl createMultivalueMap( String paramName, String paramValue ) {
MultivaluedMapImpl queryParams = new MultivaluedMapImpl();
queryParams.add( paramName, UriComponent.encode( paramValue, UriComponent.Type.QUERY_PARAM ) );
return queryParams;
}