本文整理汇总了Java中com.nimbusds.langtag.LangTag类的典型用法代码示例。如果您正苦于以下问题:Java LangTag类的具体用法?Java LangTag怎么用?Java LangTag使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LangTag类属于com.nimbusds.langtag包,在下文中一共展示了LangTag类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doExecute
import com.nimbusds.langtag.LangTag; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
final String nameNoTag = StringSupport.trimOrNull(getInputMetadata().getName());
final Map<LangTag, String> map = getInputMetadata().getNameEntries();
if (nameNoTag != null) {
log.debug("{} Found client name without name tag: {}", getLogPrefix(), nameNoTag);
getOutputMetadata().setName(nameNoTag, null);
}
if (map != null && !map.isEmpty()) {
final Iterator<LangTag> tags = map.keySet().iterator();
while (tags.hasNext()) {
final LangTag tag = tags.next();
final String name = StringSupport.trimOrNull(map.get(tag));
if (name != null) {
log.debug("{} Found client name {} for language tag {}", getLogPrefix(), name, tag);
getOutputMetadata().setName(name, tag);
}
}
}
}
示例2: testTags
import com.nimbusds.langtag.LangTag; //导入依赖的package包/类
@Test
public void testTags() throws ComponentInitializationException, LangTagException {
OIDCClientMetadata request = new OIDCClientMetadata();
String name1 = "client name";
LangTag tag1 = new LangTag("en");
String name2 = "asiakkaan nimi";
LangTag tag2 = new LangTag("fi");
request.setName(name1, tag1);
request.setName(name2, tag2);
OIDCClientMetadata result = new OIDCClientMetadata();
setUpContext(request, result);
Assert.assertNull(action.execute(requestCtx));
Assert.assertNull(result.getName());
Map<LangTag, String> map = result.getNameEntries();
Assert.assertFalse(map.isEmpty());
Assert.assertEquals(map.size(), 2);
Assert.assertEquals(map.get(tag1), name1);
Assert.assertEquals(map.get(tag2), name2);
}
示例3: testNoTag
import com.nimbusds.langtag.LangTag; //导入依赖的package包/类
@Test
public void testNoTag() throws ComponentInitializationException {
OIDCClientMetadata request = new OIDCClientMetadata();
String name = "client name";
request.setName(name);
OIDCClientMetadata result = new OIDCClientMetadata();
setUpContext(request, result);
Assert.assertNull(action.execute(requestCtx));
Assert.assertEquals(result.getName(), name);
Map<LangTag, String> map = result.getNameEntries();
Assert.assertFalse(map.isEmpty());
Assert.assertEquals(map.size(), 1);
Assert.assertEquals(map.get(map.keySet().iterator().next()), name);
}
示例4: claimLocales
import com.nimbusds.langtag.LangTag; //导入依赖的package包/类
private List<LangTag> claimLocales() {
try {
return Collections.singletonList(new LangTag("en"));
}
catch (LangTagException e) {
throw new RuntimeException(e);
}
}
示例5: uiLocales
import com.nimbusds.langtag.LangTag; //导入依赖的package包/类
private List<LangTag> uiLocales() {
try {
return Collections.singletonList(new LangTag("en"));
}
catch (LangTagException e) {
throw new RuntimeException(e);
}
}
示例6: isValid
import com.nimbusds.langtag.LangTag; //导入依赖的package包/类
@Override
public boolean isValid(String string, ConstraintValidatorContext context) {
if (string == null) {
return true;
}
try {
LangTag.parse(string);
} catch (LangTagException e) {
return false;
}
return true;
}
示例7: isValid
import com.nimbusds.langtag.LangTag; //导入依赖的package包/类
@Override
public boolean isValid(Map<String, String> map,
ConstraintValidatorContext context) {
if (map == null) {
return true;
}
try {
for (String key : map.keySet()) {
LangTag.parse(key);
}
} catch (LangTagException e) {
return false;
}
return true;
}