当前位置: 首页>>代码示例>>Java>>正文


Java LangTag类代码示例

本文整理汇总了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);
            }
        }
    }
}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:22,代码来源:AddClientNameToClientMetadata.java

示例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);
}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:20,代码来源:AddClientNameToClientMetadataTest.java

示例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);
}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:15,代码来源:AddClientNameToClientMetadataTest.java

示例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);
	}
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:9,代码来源:DiscoveryConfiguration.java

示例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);
	}
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:9,代码来源:DiscoveryConfiguration.java

示例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;
}
 
开发者ID:Apereo-Learning-Analytics-Initiative,项目名称:Larissa,代码行数:13,代码来源:LanguageMapKeyValidator.java

示例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;
}
 
开发者ID:Apereo-Learning-Analytics-Initiative,项目名称:Larissa,代码行数:16,代码来源:LanguageMapValidator.java


注:本文中的com.nimbusds.langtag.LangTag类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。