本文整理匯總了Java中org.springframework.web.util.UriTemplate.match方法的典型用法代碼示例。如果您正苦於以下問題:Java UriTemplate.match方法的具體用法?Java UriTemplate.match怎麽用?Java UriTemplate.match使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.web.util.UriTemplate
的用法示例。
在下文中一共展示了UriTemplate.match方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doTestForURITemplateMatch
import org.springframework.web.util.UriTemplate; //導入方法依賴的package包/類
private void doTestForURITemplateMatch(final String uriTemplate, final String uri,
final Boolean uriTemplateExpectedMatch, final String[] varNames, final String[] varValues) {
UriTemplate template = new UriTemplate(uriTemplate);
Assert.assertEquals(template.matches(uri), uriTemplateExpectedMatch.booleanValue());
Map<String, String> matchedVariables = template.match(uri);
for (int i = 0; i < varNames.length; i++) {
// skip variable match if name is "n/a"
if (varNames[i].equals("n/a")) {
continue;
}
Assert.assertEquals(matchedVariables.get(varNames[i]), varValues[i]);
Assert.assertEquals(matchedVariables.get(varNames[i]), varValues[i]);
}
}
示例2: uriVariable
import org.springframework.web.util.UriTemplate; //導入方法依賴的package包/類
/**
* @param pathVariable
* name of path parameter in the URL
* @return path parameter value
*/
public String uriVariable(final String pathVariable) {
if (StringUtils.isEmpty(this.resourceURITemplate) || StringUtils.isEmpty(this.resourceURI)
|| StringUtils.isEmpty(pathVariable)) {
return "";
}
UriTemplate template = new UriTemplate(this.resourceURITemplate);
Map<String, String> match = template.match(this.resourceURI);
String pathVariableValue = match.get(pathVariable);
return pathVariableValue != null ? pathVariableValue : "";
}
示例3: getMatchList
import org.springframework.web.util.UriTemplate; //導入方法依賴的package包/類
private Map<String, String> getMatchList(final UriInfo uriInfo, final ResourceTemplate template) {
final UriTemplate uriTemplate = new UriTemplate(template.getTemplate());
String path = uriInfo.getRequestUri().getPath();
if (path.endsWith("/")) {
path = path.substring(0, (path.length() - 1));
}
return uriTemplate.match(path);
}
示例4: resolve
import org.springframework.web.util.UriTemplate; //導入方法依賴的package包/類
public String resolve(final String uri, final UriTemplate uriTemplate, final String uriTemplateVariableName) {
Map<String, String> variables = uriTemplate.match(uri);
return variables.get(uriTemplateVariableName);
}
示例5: getFacilityIdFromUri
import org.springframework.web.util.UriTemplate; //導入方法依賴的package包/類
public String getFacilityIdFromUri(String facilityUri) {
UriTemplate uriTemplate = new UriTemplate("/facilities/{facilityId}");
Map<String, String> variables = uriTemplate.match(facilityUri);
String facilityId = variables.get("facilityId");
return facilityId;
}
示例6: getProductIdFromUri
import org.springframework.web.util.UriTemplate; //導入方法依賴的package包/類
public String getProductIdFromUri(String productURI) {
UriTemplate uriTemplate = new UriTemplate("/products/{productId}");
Map<String, String> variables = uriTemplate.match(productURI);
return variables.get("productId");
}
示例7: translate
import org.springframework.web.util.UriTemplate; //導入方法依賴的package包/類
public String translate(String requestPath) {
final UriTemplate uriTemplate = new UriTemplate(pattern);
Map<String, String> matchList = uriTemplate.match(requestPath);
if (matchList.isEmpty() || ignorePatternList(requestPath)) {
return requestPath;
}
List<String> translatedIdList = new ArrayList<String>();
if (useProvidedId) {
String[] ids = matchList.get("id").split(",");
translatedIdList.addAll(Arrays.asList(ids));
} else {
NeutralQuery neutralQuery = new NeutralQuery();
neutralQuery.addCriteria(new NeutralCriteria(referenceKey, "in", Arrays.asList(matchList.get("id"))));
neutralQuery.setOffset(0);
neutralQuery.setLimit(0);
Iterable<Entity> entities = repository.findAll(parentEntity, neutralQuery);
for (Entity entity : entities) {
if (key.equals("_id")) {
translatedIdList.add(entity.getEntityId());
} else if (entity.getBody().containsKey(key)) {
Object value = entity.getBody().get(key);
if (value instanceof String) {
translatedIdList.add((String) value);
} else if (value instanceof List<?>) {
for (String id : (List<String>) value) {
translatedIdList.add(id);
}
}
}
}
if (translatedIdList.isEmpty()) {
LOG.warn("Failed upversioning rewrite {} -> {} due not being able to find intermediate entities", requestPath, this.transformTo);
throw new URITranslationException("Upversioning rewrite failed. No target entities found.");
}
}
return buildTranslatedPath(translatedIdList);
}