當前位置: 首頁>>代碼示例>>Java>>正文


Java UriTemplate.match方法代碼示例

本文整理匯總了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]);
    }
}
 
開發者ID:eclipse,項目名稱:keti,代碼行數:17,代碼來源:PolicyMatcherImplTest.java

示例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 : "";
}
 
開發者ID:eclipse,項目名稱:keti,代碼行數:16,代碼來源:ResourceHandler.java

示例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);
}
 
開發者ID:inbloom,項目名稱:secure-data-service,代碼行數:9,代碼來源:RestResourceHelper.java

示例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);
    }
 
開發者ID:eclipse,項目名稱:keti,代碼行數:6,代碼來源:UriTemplateVariableResolver.java

示例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;
}
 
開發者ID:thomasletsch,項目名稱:moserp,代碼行數:7,代碼來源:FacilityUtil.java

示例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");
}
 
開發者ID:thomasletsch,項目名稱:moserp,代碼行數:6,代碼來源:BaseWebInventoryTest.java

示例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);
}
 
開發者ID:inbloom,項目名稱:secure-data-service,代碼行數:42,代碼來源:URITranslator.java


注:本文中的org.springframework.web.util.UriTemplate.match方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。