• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Key类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jbibtex.Key的典型用法代码示例。如果您正苦于以下问题:Java Key类的具体用法?Java Key怎么用?Java Key使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Key类属于org.jbibtex包,在下文中一共展示了Key类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getBibTeX

import org.jbibtex.Key; //导入依赖的package包/类
private String getBibTeX(KnownColormap colormap)
{
	List<String> entries = Lists.newArrayList();
	for (String ref : colormap.getReferences())
	{
		BibTeXEntry entry = database.resolveEntry(new Key(ref));
		if (entry != null)
		{
			entries.add(getField(entry, BibTeXEntry.KEY_TITLE));
			entries.add(getField(entry, BibTeXEntry.KEY_AUTHOR));
			entries.add(getField(entry, BibTeXEntry.KEY_YEAR));
			entries.add(getField(entry, BibTeXEntry.KEY_HOWPUBLISHED));
			entries.add("");
		}
		else
		{
			logger.warn("Invalid BibTeX reference " + ref);
		}
	}

	String refs = Joiner.on("<br/>").skipNulls().join(entries);
	return refs;
}
 
开发者ID:igd-iva,项目名称:colormap-explorer,代码行数:24,代码来源:ConfigPanel.java


示例2: bibEntryToCSLItemData

import org.jbibtex.Key; //导入依赖的package包/类
/**
 * Converts the {@link BibEntry} into {@link CSLItemData}.
 */
private static CSLItemData bibEntryToCSLItemData(BibEntry bibEntry) {
    String citeKey = bibEntry.getCiteKeyOptional().orElse("");
    BibTeXEntry bibTeXEntry = new BibTeXEntry(new Key(bibEntry.getType()), new Key(citeKey));

    // Not every field is already generated into latex free fields
    HTMLChars latexToHtmlConverter = new HTMLChars();
    RemoveNewlinesFormatter removeNewlinesFormatter = new RemoveNewlinesFormatter();
    for (String key : bibEntry.getFieldMap().keySet()) {
        bibEntry.getField(key)
                .map(removeNewlinesFormatter::format)
                .map(latexToHtmlConverter::format)
                .ifPresent(value -> bibTeXEntry.addField(new Key(key), new DigitStringValue(value)));
    }
    return BIBTEX_CONVERTER.toItemData(bibTeXEntry);
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:19,代码来源:CSLAdapter.java


示例3: loadDatabase

import org.jbibtex.Key; //导入依赖的package包/类
/**
 * <p>Loads a BibTeX database from a stream.</p>
 * <p>This method does not close the given stream. The caller is
 * responsible for closing it.</p>
 * @param is the input stream to read from
 * @return the BibTeX database
 * @throws IOException if the database could not be read
 * @throws ParseException if the database is invalid
 */
public BibTeXDatabase loadDatabase(InputStream is) throws IOException, ParseException {
	Reader reader = new InputStreamReader(is, "UTF-8");
	BibTeXParser parser = new BibTeXParser() {
		@Override
		public void checkStringResolution(Key key, BibTeXString string) {
			if (string == null) {
				//ignore
			}
		}
	};
	try {
		return parser.parse(reader);
	} catch (TokenMgrException err) {
		throw new ParseException("Could not parse BibTeX library: " +
				err.getMessage());
	}
}
 
开发者ID:michel-kraemer,项目名称:citeproc-java,代码行数:27,代码来源:BibTeXConverter.java


示例4: singleEntryWithDateRange

import org.jbibtex.Key; //导入依赖的package包/类
/**
 * Tests if a bibliography entry with a date range can be converted
 * @throws Exception if something goes wrong
 */
@Test
public void singleEntryWithDateRange() throws Exception {
	BibTeXDatabase db = loadUnixDatabase();
	
	BibTeXEntry e = db.resolveEntry(new Key("Lycklama:1978:UTSb"));
	
	BibTeXConverter conv = new BibTeXConverter();
	CSLItemData cid = conv.toItemData(e);
	assertEquals("Lycklama:1978:UTSb", cid.getId());
	assertEquals(CSLType.ARTICLE_JOURNAL, cid.getType());
	assertEquals(1, cid.getAuthor().length);
	assertEquals("Lycklama", cid.getAuthor()[0].getFamily());
	assertEquals("H.", cid.getAuthor()[0].getGiven());
	assertEquals("The Bell System Technical Journal", cid.getCollectionTitle());
	assertEquals("The Bell System Technical Journal", cid.getContainerTitle());
	assertEquals("57", cid.getVolume());
	assertEquals("6", cid.getIssue());
	assertEquals("6", cid.getNumber());
	assertEquals("15", cid.getNumberOfPages());
	assertEquals("2087-2101", cid.getPage());
	assertEquals("2087", cid.getPageFirst());
	assertEquals("UNIX Time-Sharing System: UNIX on a Microprocessor", cid.getTitle());
	assertArrayEquals(new int[][] { new int[] { 1978, 7 }, new int[] { 1978, 8 } }, cid.getIssued().getDateParts());
}
 
开发者ID:michel-kraemer,项目名称:citeproc-java,代码行数:29,代码来源:BibTeXConverterTest.java


示例5: setFieldValue

import org.jbibtex.Key; //导入依赖的package包/类
/**
 * Set a value to a bibtex key into a specific bibtex bibTeXEntry.
 *
 * @param keyName Name of the key to be set
 * @param valueStr Value to be set on the key
 */
public void setFieldValue(final String keyName, final String valueStr) {
    if(bibTeXEntry == null)
        throw new RuntimeException("The paper is not linked to a BibTeX entry. The bibTeXEntry field is null.");
    
    Key key = new Key(keyName);
    Value bibValue = bibTeXEntry.getField(key);
    if (bibValue != null) {
        bibTeXEntry.removeField(key);
    }
    bibTeXEntry.addField(key, new StringValue(valueStr, StringValue.Style.BRACED));
}
 
开发者ID:manoelcampos,项目名称:BibTeXPaperDownloader,代码行数:18,代码来源:Paper.java


示例6: getField

import org.jbibtex.Key; //导入依赖的package包/类
private String getField(BibTeXEntry entry, Key key)
{
	Value field = entry.getField(key);
	if (field == null)
		return null;

	String left = key.toString();
	left = Character.toUpperCase(left.charAt(0)) + left.substring(1);
	left = "<b>" + left + ":</b> ";

	// remove capitalization-preserving brackets { }
	String userString = field.toUserString();
	if (userString.startsWith("{") && userString.endsWith("}"))
	{
		userString = userString.substring(1, userString.length() - 2);
	}

	userString = userString.replaceAll("\\\\\"\\{u\\}", "�");	// matches \"{u}
	userString = userString.replaceAll("\\{\\\\\"u\\}", "�");	// matches {\"u}

	userString = userString.replaceAll("\\\\\"\\{a\\}", "�");	// matches \"{a}
	userString = userString.replaceAll("\\{\\\\\"a\\}", "�");	// matches {\"a}

	userString = userString.replaceAll("\\\\\"\\{o\\}", "�");	// matches \"{o}
	userString = userString.replaceAll("\\{\\\\\"o\\}", "�");	// matches {\"o}

	return left + userString;
}
 
开发者ID:igd-iva,项目名称:colormap-explorer,代码行数:29,代码来源:ConfigPanel.java


示例7: toItemData

import org.jbibtex.Key; //导入依赖的package包/类
/**
 * Converts the given database to a map of CSL citation items
 * @param db the database
 * @return a map consisting of citation keys and citation items
 */
public Map<String, CSLItemData> toItemData(BibTeXDatabase db) {
	Map<String, CSLItemData> result = new HashMap<>();
	for (Map.Entry<Key, BibTeXEntry> e : db.getEntries().entrySet()) {
		result.put(e.getKey().getValue(), toItemData(e.getValue()));
	}
	return result;
}
 
开发者ID:michel-kraemer,项目名称:citeproc-java,代码行数:13,代码来源:BibTeXConverter.java


示例8: singleEntry

import org.jbibtex.Key; //导入依赖的package包/类
/**
 * Tests if a single bibliography entry can be converted
 * @throws Exception if something goes wrong
 */
@Test
public void singleEntry() throws Exception {
	BibTeXDatabase db = loadUnixDatabase();
	
	BibTeXEntry e = db.resolveEntry(new Key("Ritchie:1974:UTS"));
	
	BibTeXConverter conv = new BibTeXConverter();
	CSLItemData cid = conv.toItemData(e);
	assertEquals("Ritchie:1974:UTS", cid.getId());
	assertEquals(CSLType.ARTICLE_JOURNAL, cid.getType());
	assertEquals(2, cid.getAuthor().length);
	assertEquals("Ritchie", cid.getAuthor()[0].getFamily());
	assertEquals("Dennis W.", cid.getAuthor()[0].getGiven());
	assertEquals("Thompson", cid.getAuthor()[1].getFamily());
	assertEquals("Ken", cid.getAuthor()[1].getGiven());
	assertEquals("Communications of the Association for Computing Machinery", cid.getCollectionTitle());
	assertEquals("Communications of the Association for Computing Machinery", cid.getContainerTitle());
	assertEquals("17", cid.getVolume());
	assertEquals("7", cid.getIssue());
	assertEquals("7", cid.getNumber());
	assertEquals("11", cid.getNumberOfPages());
	assertEquals("365-375", cid.getPage());
	assertEquals("365", cid.getPageFirst());
	assertEquals("The UNIX Time-Sharing System", cid.getTitle());
	assertArrayEquals(new int[][] { new int[] { 1974, 7 } }, cid.getIssued().getDateParts());
}
 
开发者ID:michel-kraemer,项目名称:citeproc-java,代码行数:31,代码来源:BibTeXConverterTest.java


示例9: carriageReturnInTitle

import org.jbibtex.Key; //导入依赖的package包/类
/**
 * Test if a BibTeX entry whose title contains a CR character (\r) can
 * be converted correctly.
 */
@Test
public void carriageReturnInTitle() {
	BibTeXEntry e = new BibTeXEntry(new Key("article"), new Key("a"));
	e.addField(new Key("title"), new StringValue(
			"syst\\`emes\r\ndiff\\'erentiels", StringValue.Style.QUOTED));
	BibTeXConverter conv = new BibTeXConverter();
	CSLItemData i = conv.toItemData(e);
	assertEquals("systèmes différentiels", i.getTitle());
}
 
开发者ID:michel-kraemer,项目名称:citeproc-java,代码行数:14,代码来源:BibTeXConverterTest.java


示例10: safeGetField

import org.jbibtex.Key; //导入依赖的package包/类
private String safeGetField(BibTeXEntry entry, Key key) {
	if (entry.getField(key) != null) {
		return entry.getField(key).toUserString();
	}
	return "";
}
 
开发者ID:sebastiangoetz,项目名称:slr-toolkit,代码行数:7,代码来源:BibtexResourceImpl.java


示例11: MockReference

import org.jbibtex.Key; //导入依赖的package包/类
/**
 * Construct from a BibTeXEntry
 * @param entry the BibTeXEntry
 */
public MockReference(BibTeXEntry entry) {
	type = ReferenceType.getReferenceType(entry.getType().getValue());
	
	Map<Key, Value> fields = entry.getFields();
	for (Entry<Key, Value> e : fields.entrySet()) {
		String ks = e.getKey().getValue();
		Value v = e.getValue();
		
		if (ks.equalsIgnoreCase("author"))
			author = ((StringValue) v).getString().split(" and ");
		else if (ks.equalsIgnoreCase("title"))
			title = ((StringValue) v).getString();
		else if (ks.equalsIgnoreCase("year"))
			year = ((StringValue) v).getString();
		else if (ks.equalsIgnoreCase("journal"))
			journal = ((StringValue) v).getString();
		else if (ks.equalsIgnoreCase("booktitle"))
			booktitle = ((StringValue) v).getString();
		else if (ks.equalsIgnoreCase("pages"))
			pages = ((StringValue) v).getString().split(",|-|--");
		else if (ks.equalsIgnoreCase("chapter"))
			chapter = ((StringValue) v).getString();
		else if (ks.equalsIgnoreCase("edition"))
			edition = ((StringValue) v).getString();
		else if (ks.equalsIgnoreCase("url"))
			url = ((StringValue) v).getString();
		else if (ks.equalsIgnoreCase("note"))
			note = ((StringValue) v).getString();
		else if (ks.equalsIgnoreCase("editor"))
			editor = ((StringValue) v).getString().split(" and ");
		else if (ks.equalsIgnoreCase("institution"))
			institution = ((StringValue) v).getString();
		else if (ks.equalsIgnoreCase("month"))
			month = ((StringValue) v).getString();
		else if (ks.equalsIgnoreCase("number"))
			number = ((StringValue) v).getString();
		else if (ks.equalsIgnoreCase("organization"))
			organization = ((StringValue) v).getString();
		else if (ks.equalsIgnoreCase("publisher"))
			publisher = ((StringValue) v).getString();
		else if (ks.equalsIgnoreCase("school"))
			school = ((StringValue) v).getString();
		else if (ks.equalsIgnoreCase("series"))
			series = ((StringValue) v).getString();
		else if (ks.equalsIgnoreCase("volume"))
			volume = ((StringValue) v).getString();
		else {
			List<String> data = new ArrayList<String>();
			data.addAll(Arrays.asList(customData));
			
			if (v instanceof StringValue) {
				data.add(ks);
				data.add(((StringValue)v).getString());
			}
			
			customData = data.toArray(customData);
		}
	}	
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:64,代码来源:MockReference.java


示例12: toType

import org.jbibtex.Key; //导入依赖的package包/类
/**
 * Converts a BibTeX type to a CSL type
 * @param type the type to convert
 * @return the converted type (never null, falls back to {@link CSLType#ARTICLE})
 */
public CSLType toType(Key type) {
	String s = type.getValue();
	if (s.equalsIgnoreCase(TYPE_ARTICLE)) {
		return CSLType.ARTICLE_JOURNAL;
	} else if (s.equalsIgnoreCase(TYPE_PROCEEDINGS)) {
		return CSLType.BOOK;
	} else if (s.equalsIgnoreCase(TYPE_MANUAL)) {
		return CSLType.BOOK;
	} else if (s.equalsIgnoreCase(TYPE_BOOK)) {
		return CSLType.BOOK;
	} else if (s.equalsIgnoreCase(TYPE_PERIODICAL)) {
		return CSLType.BOOK;
	} else if (s.equalsIgnoreCase(TYPE_BOOKLET)) {
		return CSLType.PAMPHLET;
	} else if (s.equalsIgnoreCase(TYPE_INBOOK)) {
		return CSLType.CHAPTER;
	} else if (s.equalsIgnoreCase(TYPE_INCOLLECTION)) {
		return CSLType.CHAPTER;
	} else if (s.equalsIgnoreCase(TYPE_INPROCEEDINGS)) {
		return CSLType.PAPER_CONFERENCE;
	} else if (s.equalsIgnoreCase(TYPE_CONFERENCE)) {
		return CSLType.PAPER_CONFERENCE;
	} else if (s.equalsIgnoreCase(TYPE_MASTERSTHESIS)) {
		return CSLType.THESIS;
	} else if (s.equalsIgnoreCase(TYPE_PHDTHESIS)) {
		return CSLType.THESIS;
	} else if (s.equalsIgnoreCase(TYPE_TECHREPORT)) {
		return CSLType.REPORT;
	} else if (s.equalsIgnoreCase(TYPE_PATENT)) {
		return CSLType.PATENT;
	} else if (s.equalsIgnoreCase(TYPE_ELECTRONIC)) {
		return CSLType.WEBPAGE;
	} else if (s.equalsIgnoreCase(TYPE_ONLINE)) {
		return CSLType.WEBPAGE;
	} else if (s.equalsIgnoreCase(TYPE_WWW)) {
		return CSLType.WEBPAGE;
	} else if (s.equalsIgnoreCase(TYPE_STANDARD)) {
		return CSLType.LEGISLATION;
	} else if (s.equalsIgnoreCase(TYPE_UNPUBLISHED)) {
		return CSLType.MANUSCRIPT;
	}
	return CSLType.ARTICLE;
}
 
开发者ID:michel-kraemer,项目名称:citeproc-java,代码行数:49,代码来源:BibTeXConverter.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Credentials类代码示例发布时间:2022-05-23
下一篇:
Java Loader类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap