本文整理了Java中pl.edu.icm.model.bwmeta.y.YName.getLanguage()
方法的一些代码示例,展示了YName.getLanguage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YName.getLanguage()
方法的具体详情如下:
包路径:pl.edu.icm.model.bwmeta.y.YName
类名称:YName
方法名:getLanguage
暂无
代码示例来源:origin: pl.edu.icm.synat/synat-business-services-api
private Map<YLanguage, List<YName>> separateNames(List<YName> names) {
Map<YLanguage, List<YName>> result = new HashMap<>();
for (YName yName : names) {
final YLanguage language = yName.getLanguage();
if (result.containsKey(language)) {
result.get(language).add(yName);
} else {
result.put(language, new LinkedList<>(Arrays.asList(yName)));
}
}
return result;
}
代码示例来源:origin: pl.edu.icm.synat/synat-portal-core
private List<YName> returnNameInLang(AbstractNDA<?> element, YLanguage language) {
final List<YName> yNameList = new ArrayList<YName>();
for (YName name : element.getNames()) {
if (name.getLanguage().equals(language)) {
yNameList.add(name);
}
}
return yNameList;
}
代码示例来源:origin: pl.edu.icm.yadda.repowebeditor/repository-web-editor-core
private String findNameInLanguage(List<YName> names, YLanguage yLanguage){
for(YName name: names){
if(yLanguage.equals(name.getLanguage()))
return name.getText();
}
return null;
}
}
代码示例来源:origin: pl.edu.icm.synat/synat-business-services-api
/**
* Method for preparation of Languages list
*
* @param element
* @return List of Languages in yElement
*/
public static List<YLanguage> getLanguages(AbstractElementInfo<?> element) {
List<YLanguage> languages = new ArrayList<YLanguage>();
if (element.getLanguages() != null) {
languages.addAll(element.getLanguages());
}
if (languages.isEmpty() && element.getNames() != null) {
for (YName yName : element.getNames()) {
if (!languages.contains(yName.getLanguage())) {
languages.add(yName.getLanguage());
}
}
}
return languages;
}
代码示例来源:origin: pl.edu.icm.yadda/bwmeta-import
/**
* Selects most apropriate (English if available) title.
*
* @param titles list of available titles
* @return best found title or null if list is empty
*/
public static String selectBestName(List<YName> titles) {
if (titles == null || titles.size() == 0) {
return null;
}
for (YName title: titles) { //Search for English version
if (title.getLanguage().equals(YLanguage.English)) {
return title.getText();
}
}
return titles.get(0).getText();
}
代码示例来源:origin: pl.edu.icm.synat/synat-business-services-api
/**
* Utility function retrieving default Language of element
*
* @param element
* @return Language from languages if only one present, else language of
* type MN_CANONICAL name if exists, anyone if Canonical not present
* or null
*/
public static YLanguage getDefaultLanguage(AbstractElementInfo<?> element) {
if (element.getLanguages() != null && element.getLanguages().size() == 1) {
return element.getOneLanguage();
}
if (element.getNames() != null && !element.getNames().isEmpty()) {
YName name = element.getDefaultName();
return ((name != null) ? name.getLanguage() : element.getOneName().getLanguage());
} else {
return null;
}
}
代码示例来源:origin: pl.edu.icm.synat/synat-portal-core
@Override
@Cacheable("datasetTranslationResult")
public String getTranslation(String dataSetId, Locale locale, DictionaryDataTypes type) {
try {
YElement element = dataSetDictionary.getYElement(dataSetId);
for (YName name : element.getNames()) {
if (name.getLanguage() != null && name.getLanguage().equals(YLanguage.byCode(locale.getISO3Language()))) {
return name.getText();
}
}
final String name = YModelUtils.getDefaultName(element);
if (StringUtils.isNotEmpty(name)) {
return name;
}
} catch (NotFoundException e) {
return dataSetId;
}
return dataSetId;
}
代码示例来源:origin: pl.edu.icm.yadda.repowebeditor/repository-web-editor-core
private LocalizedString extractLocalizedStringFrom(YName yName){
YRichText text = yName.getRichText();
if(StringUtils.isBlank(yName.getText())){
return null;
} else {
String langCode = languageExtractor.extractLanguageCode(yName.getLanguage());
return new LocalizedString(langCode, YRTHelper.toXmlFragmentWithoutNamespaces(text));
}
}
代码示例来源:origin: pl.edu.icm.yadda/yaddaweb-lite-core
private Map<String, List<LocalizedString>> prepareTypedNames(YElement element,
IFilteringContext filteringContext) {
Map<String, List<LocalizedString>> result = new HashMap<String, List<LocalizedString>>();
for (YName name : element.getNames()) {
String lang = languageDictionary.getShortDescription(name.getLanguage().getShortCode());
String text = detailsFilter.filter(YRTHelper.toXmlFragment(name.getRichText()),
InputType.RICH_TEXT, filteringContext);
LocalizedString ls = new LocalizedString(lang, text);
List<LocalizedString> list;
String type = name.getType();
if (!result.containsKey(type)) {
list = new ArrayList<LocalizedString>();
result.put(type, list);
} else {
list = result.get(type);
}
list.add(ls);
}
return result;
}
代码示例来源:origin: pl.edu.icm.yadda/yaddaweb-lite-core
private Object prepareTitles(List<YName> names, YName defaultName, IFilteringContext filteringContext) {
List<LocalizedString> res = new ArrayList<LocalizedString>();
if (names != null)
for (YName name : names) {
if (defaultName != name && YNameAndYDescriptionSorter.isMainOrAlternativeName(name.getType())) {
String lang = languageDictionary.getShortDescription(name.getLanguage().getShortCode());
res.add(new LocalizedString(lang, detailsFilter.filter(YRTHelper.toXmlFragment(name.getRichText()),
InputType.RICH_TEXT, filteringContext)));
}
}
return res;
}
代码示例来源:origin: pl.edu.icm.yadda/yaddaweb-lite-core
final String language = name.getLanguage().getShortCode();
代码示例来源:origin: pl.edu.icm.synat/synat-portal-core
private String extractTextFromYElement(final YElement yElement) throws IOException {
final String sep = " ";
final YLanguage lang = YLanguage.Polish;
StringBuilder builder = new StringBuilder();
for (YName data : yElement.getNames()) {
if(lang.equals(data.getLanguage())){
builder.append(data.getText());
builder.append(sep);
}
}
for (YDescription data : yElement.getDescriptions()) {
if(lang.equals(data.getLanguage())){
builder.append(data.getText());
builder.append(sep);
}
}
for(FilteredContentEntry<?> plainTextFile:ResourceDisplayUtilsImpl.fetchPlainTextContentEntries(yElement)){
if(plainTextFile.getSource() instanceof YContentFile){
YContentFile file = (YContentFile)plainTextFile.getSource();
ElementContent elementContent = repositoryFacade.fetchContent(yElement.getId(), file.getLocations().get(0));
builder.append(IOUtils.toString(elementContent.getStream()));
builder.append(sep);
}
}
return builder.toString().trim();
}
代码示例来源:origin: pl.edu.icm.synat/synat-portal-core
final YLanguage yLanguage = name.getLanguage();
if (hasBeenList.contains(yLanguage)) {
continue;
CharSequence name = new FilteredString(YModelUtils.yRichTextToString(yName.getRichText()));
final PublicationNameData titleList = new PublicationNameData(name);
names.add(new LocalizedData<PublicationNameData>(makeLanguageData(yName.getLanguage(), locale), titleList));
代码示例来源:origin: pl.edu.icm.yadda/yadda-cli
if (lang==null || lang.equals(name.getLanguage())) {
textsTexts.add(new Pair<String, TextType>(normalize(name.getText()), TextType.TITLE));
hasTitle = true;
代码示例来源:origin: pl.edu.icm.synat/synat-portal-core
@Override
public boolean hasContentInLanguage(YElement yElement, YLanguage lang) {
for (YName data : yElement.getNames()) {
if (lang.equals(data.getLanguage())) {
return true;
}
}
for (YDescription data : yElement.getDescriptions()) {
if (lang.equals(data.getLanguage())) {
return true;
}
}
return false;
}
代码示例来源:origin: pl.edu.icm.yadda/yaddaweb-lite-core
protected List<LocalizedString> prepareTitles(YElement element, IFilteringContext filteringContext) {
YName oneName = element.getDefaultName();
List<LocalizedString> res = new ArrayList<LocalizedString>();
for (YName name : element.getNames()) {
if (name != oneName && YNameAndYDescriptionSorter.isMainOrAlternativeName(name.getType())) {
String lang = languageDictionary.getShortDescription(name.getLanguage().getShortCode());
res.add(new LocalizedString(lang, detailsFilter.filter(
YRTHelper.toXmlFragment(name.getRichText()),
InputType.RICH_TEXT, filteringContext)));
}
}
return res;
}
代码示例来源:origin: pl.edu.icm.yadda/yaddaweb-lite-core
if (name.getLanguage().getShortCode().equals(lang)) {
page.setTitle(name.getText());
代码示例来源:origin: pl.edu.icm.yadda/yadda-analysis-impl
public static void updateYRelationWithZblNames(YRelation relye, YElement zblye) {
for (YName n : zblye.getNames()) {
YAttribute ya = new YAttribute(YConstants.AT_ENHANCED_FROM_ZBL_NAME, "");
ya.addAttribute(new YAttribute(YConstants.AT_ENHANCED_FROM_ZBL_LANGUAGE, n.getLanguage().getName()));
ya.addAttribute(new YAttribute(YConstants.AT_ENHANCED_FROM_ZBL_TYPE, n.getType()));
ya.addAttribute(new YAttribute(YConstants.AT_ENHANCED_FROM_ZBL_VALUE, n.getText()));
relye.addAttribute(ya);
}
}
代码示例来源:origin: pl.edu.icm.yadda/yadda-analysis-impl
ya.addAttribute(new YAttribute(YConstants.AT_ENHANCED_FROM_ZBL_LANGUAGE,n.getLanguage().getName()));
ya.addAttribute(new YAttribute(YConstants.AT_ENHANCED_FROM_ZBL_TYPE,n.getType()));
ya.addAttribute(new YAttribute(YConstants.AT_ENHANCED_FROM_ZBL_VALUE,n.getText()));
代码示例来源:origin: pl.edu.icm.yadda/yadda-analysis-impl
ya.addAttribute(new YAttribute(YConstants.AT_ENHANCED_FROM_ZBL_LANGUAGE,n.getLanguage().getName()));
ya.addAttribute(new YAttribute(YConstants.AT_ENHANCED_FROM_ZBL_TYPE,n.getType()));
ya.addAttribute(new YAttribute(YConstants.AT_ENHANCED_FROM_ZBL_VALUE,n.getText()));
内容来源于网络,如有侵权,请联系作者删除!