本文整理汇总了Java中com.damnhandy.uri.template.MalformedUriTemplateException类的典型用法代码示例。如果您正苦于以下问题:Java MalformedUriTemplateException类的具体用法?Java MalformedUriTemplateException怎么用?Java MalformedUriTemplateException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MalformedUriTemplateException类属于com.damnhandy.uri.template包,在下文中一共展示了MalformedUriTemplateException类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: normalizeTemplateString
import com.damnhandy.uri.template.MalformedUriTemplateException; //导入依赖的package包/类
private static String normalizeTemplateString(final String templateString) {
// https://gbv.github.io/beaconspec/beacon.html#uri-patterns
if (templateString == null || templateString.isEmpty()) {
return RESERVED_EXPANSION;
}
final Expression[] expressions = UriTemplate.fromTemplate(templateString).getExpressions();
if (expressions.length == 0) {
return templateString + SIMPLE_EXPANSION;
}
for (final Expression expression : expressions) {
if (!VALID_EXPRESSIONS.contains(expression.getValue())) {
throw new MalformedUriTemplateException("Invalid template expression " + expression.getValue(),
expression.getStartPosition());
}
}
return templateString;
}
开发者ID:thunken,项目名称:beacon,代码行数:18,代码来源:BeaconParser.java
示例2: visitBaseUriFacet
import com.damnhandy.uri.template.MalformedUriTemplateException; //导入依赖的package包/类
@Override
public Object visitBaseUriFacet(RAMLParser.BaseUriFacetContext ctx) {
final String baseUriText = ctx.baseUri.getText();
try {
final UriTemplate uriTemplate = (UriTemplate) ResourcesFactory.eINSTANCE
.createFromString(ResourcesPackage.Literals.URI_TEMPLATE, baseUriText);
scope.with(API_BASE__BASE_URI).setValue(uriTemplate, ctx.getStart());
return uriTemplate;
} catch (final MalformedUriTemplateException uriTemplateException) {
scope.addError(uriTemplateException.getMessage(), ctx);
return null;
}
}
开发者ID:vrapio,项目名称:rest-modeling-framework,代码行数:15,代码来源:ApiConstructor.java
示例3: NingRestRequestHolder
import com.damnhandy.uri.template.MalformedUriTemplateException; //导入依赖的package包/类
public NingRestRequestHolder(NingRestClient client, String url, String... params) {
try {
this.client = client;
UriTemplate uriTemplate = UriTemplate.fromTemplate(url);
if (uriTemplate.getVariables().length != params.length) {
throw new IllegalArgumentException("The number of variables in the URL and the number of values do not match");
}
for (int i = 0; i < params.length; i++) {
uriTemplate.set(uriTemplate.getVariables()[i], params[i]);
}
url = uriTemplate.expand();
URL reference = new URL(url);
this.url = url;
String userInfo = reference.getUserInfo();
if (userInfo != null) {
this.setAuth(userInfo);
}
if (reference.getQuery() != null) {
this.setQueryString(reference.getQuery());
}
} catch (MalformedURLException | MalformedUriTemplateException | VariableExpansionException e) {
throw new RuntimeException(e);
}
}
开发者ID:mcoira,项目名称:async-rest-client,代码行数:29,代码来源:NingRestRequestHolder.java
示例4: getRelationHref
import com.damnhandy.uri.template.MalformedUriTemplateException; //导入依赖的package包/类
private String getRelationHref(Link link, Object[] args, Annotation[][] parameterAnnotations) {
HalLink halLink = halResource.getLink(link.relation());
if (halLink == null) {
throw new UnsupportedOperationException(link.relation());
}
if (halLink.getDeprecation() != null) {
log.warn("Link '" + link + "' has been deprecated: " + halLink.getDeprecation());
}
String href;
if (halLink.isTemplated()) {
try {
UriTemplate uriTemplate = UriTemplate.fromTemplate(halLink.getHref());
for (int i = 0; i < args.length; i++) {
for (Annotation annotation : parameterAnnotations[i]) {
if (annotation.annotationType() == UriVariable.class) {
UriVariable uriVariable = (UriVariable) annotation;
assignTemplateValue(uriTemplate, uriVariable.name(), args[i]);
}
}
}
for (int i = 0; i < link.uriValues().length; i++) {
UriValue uriValue = link.uriValues()[i];
assignTemplateValue(uriTemplate, uriValue.name(), uriValue.value());
}
href = uriTemplate.expand();
} catch (MalformedUriTemplateException | VariableExpansionException e) {
throw new RuntimeException(e);
}
} else {
href = halLink.getHref();
}
return href;
}
开发者ID:awslabs,项目名称:aws-hal-client-java,代码行数:44,代码来源:HalResourceInvocationHandler.java
注:本文中的com.damnhandy.uri.template.MalformedUriTemplateException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论