Verified Owner
Top Inners Fields Constructors Methods
org.jabref.logic.importer.fileformat

public Class CitaviXmlImporter

extends Importer
implements Parser
Class Inheritance
All Implemented Interfaces
org.jabref.logic.importer.Parser
Imports
java.io.BufferedReader, .IOException, .InputStream, .InputStreamReader, .Reader, java.nio.charset.StandardCharsets, java.nio.file.Files, .Path, .StandardCopyOption, .StandardOpenOption, java.util.ArrayList, .Arrays, .EnumSet, .HashMap, .List, .Locale, .Map, .Objects, .Optional, .StringJoiner, java.util.stream.Collectors, java.util.zip.ZipEntry, .ZipInputStream, javax.xml.stream.XMLInputFactory, .XMLStreamConstants, .XMLStreamException, .XMLStreamReader, org.jabref.logic.citationkeypattern.CitationKeyGenerator, org.jabref.logic.formatter.bibtexfields.HtmlToLatexFormatter, .NormalizePagesFormatter, org.jabref.logic.importer.Importer, .Parser, .ParserResult, org.jabref.logic.importer.fileformat.citavi.KnowledgeItem, .Reference, org.jabref.logic.l10n.Localization, org.jabref.logic.util.StandardFileType, org.jabref.logic.util.strings.StringUtil, org.jabref.model.entry.Author, .AuthorList, .BibEntry, .Keyword, .KeywordList, org.jabref.model.entry.field.StandardField, org.jabref.model.entry.types.EntryType, .IEEETranEntryType, .StandardEntryType, org.apache.commons.io.ByteOrderMark, org.apache.commons.io.input.BOMInputStream, org.jspecify.annotations.NonNull, org.slf4j.Logger, .LoggerFactory

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static enum

Field Summary

Modifier and TypeField and Description
private static final int
private final HtmlToLatexFormatter
private final List<KnowledgeItem>
private final Map<String, Keyword>
private final Map<String, Author>
private final Map<String, String>
private static final Logger
private final NormalizePagesFormatter
private static final EnumSet<CitaviXmlImporter.QuotationTypeMapping>
private final List<Reference>
private final Map<String, List<String>>
private final Map<String, List<String>>
private final Map<String, List<String>>
private final Map<String, List<String>>
private static final byte
private static final byte
private final XMLInputFactory

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private List<BibEntry>
private String
clean(String input)

pack-priv String
private void
private static EntryType
public String
getDescription()

Implements abstract org.jabref.logic.importer.Importer.getDescription.

Returns the description of the import format.

public StandardFileType
getFileType()

Implements abstract org.jabref.logic.importer.Importer.getFileType.

Returns the type of files that this importer can read

public String
getId()

Implements abstract org.jabref.logic.importer.Importer.getId.

Returns a slug, which identifies this importer.

private String
getKnowledgeItem(Map<String, List<KnowledgeItem>> groupedKnowledgeItemMap, Reference reference)

public String
getName()

Implements abstract org.jabref.logic.importer.Importer.getName.

Returns the name of this import format.

private String
getPages(String pageRange, String pageCount)

PageRange and PageCount tags contain text with additional markers that need to be discarded.

private BufferedReader
private EntryType
getType(Reference reference)

public ParserResult
importDatabase(@NonNull Path filePath)

Overrides org.jabref.logic.importer.Importer.importDatabase.

Parse the database in the specified file.

public ParserResult
importDatabase(@NonNull BufferedReader reader)

Implements abstract org.jabref.logic.importer.Importer.importDatabase.

Parse the database in the source.

public boolean
isRecognizedFormat(@NonNull Reader reader)

Overrides org.jabref.logic.importer.Importer.isRecognizedFormat.

#isRecognizedFormat(BufferedReader) without the requirement to reset

public boolean
isRecognizedFormat(@NonNull Path filePath)

Overrides org.jabref.logic.importer.Importer.isRecognizedFormat.

Check whether the source is in the correct format for this importer.

private void
public List<BibEntry>
private void
private void
private void
private void
private void
private void
private void
private void
private void
private void
private String
private Map<String, String>
resolveKeywordMap(Map<String, List<String>> referenceIdMap, Map<String, Keyword> keywordMap)

private Map<String, String>
resolvePersonMap(Map<String, List<String>> referenceIdMap, Map<String, Author> personMap)

private Map<String, String>
resolvePublisherMap(Map<String, List<String>> referenceIdMap, Map<String, String> publisherMap)

private static String
private void
Inherited from org.jabref.logic.importer.Importer:
compareToequalsgetCharsetgetReadergetReaderhashCodeimportDatabaseisRecognizedFormatisRecognizedFormatsupportsFileExtensiontoString

Field Detail

END_TAG_CHARACTER_COUNTback to summary
private static final int END_TAG_CHARACTER_COUNT
htmlToLatexFormatterback to summary
private final HtmlToLatexFormatter htmlToLatexFormatter
knowledgeItemsback to summary
private final List<KnowledgeItem> knowledgeItems
knownKeywordsback to summary
private final Map<String, Keyword> knownKeywords
knownPersonsback to summary
private final Map<String, Author> knownPersons
knownPublishersback to summary
private final Map<String, String> knownPublishers
LOGGERback to summary
private static final Logger LOGGER

Hides org.jabref.logic.importer.Importer.LOGGER.

pagesFormatterback to summary
private final NormalizePagesFormatter pagesFormatter
QUOTATION_TYPESback to summary
private static final EnumSet<CitaviXmlImporter.QuotationTypeMapping> QUOTATION_TYPES
referencesback to summary
private final List<Reference> references
refIdWithAuthorIdsback to summary
private final Map<String, List<String>> refIdWithAuthorIds
refIdWithEditorIdsback to summary
private final Map<String, List<String>> refIdWithEditorIds
refIdWithKeywordsIdsback to summary
private final Map<String, List<String>> refIdWithKeywordsIds
refIdWithPublisherIdsback to summary
private final Map<String, List<String>> refIdWithPublisherIds
UUID_LENGTHback to summary
private static final byte UUID_LENGTH
UUID_SEMICOLON_OFFSET_INDEXback to summary
private static final byte UUID_SEMICOLON_OFFSET_INDEX
xmlInputFactoryback to summary
private final XMLInputFactory xmlInputFactory

Constructor Detail

CitaviXmlImporterback to summary
public CitaviXmlImporter()

Method Detail

buildBibItemsback to summary
private List<BibEntry> buildBibItems()
cleanback to summary
private String clean(String input)
cleanUpTextback to summary
pack-priv String cleanUpText(String text)
consumeElementback to summary
private void consumeElement(XMLStreamReader reader) throws XMLStreamException
convertRefNameToTypeback to summary
private static EntryType convertRefNameToType(String refName)
getDescriptionback to summary
public String getDescription()

Implements abstract org.jabref.logic.importer.Importer.getDescription.

Doc from org.jabref.logic.importer.Importer.getDescription.

Returns the description of the import format.

The description should specify
what kind of entries from what sources and based on what specification it is able to import

by what criteria it isRecognizedFormat(BufferedReader) recognizes an import format

Annotations
@Override
getFileTypeback to summary
public StandardFileType getFileType()

Implements abstract org.jabref.logic.importer.Importer.getFileType.

Doc from org.jabref.logic.importer.Importer.getFileType.

Returns the type of files that this importer can read

Annotations
@Override
getIdback to summary
public String getId()

Implements abstract org.jabref.logic.importer.Importer.getId.

Doc from org.jabref.logic.importer.Importer.getId.

Returns a slug, which identifies this importer. Used, for example, to identify the importer in CLI.

Typically, this name should be short, in English, and should not contain special characters like #, %, etc.

Annotations
@Override
getKnowledgeItemback to summary
private String getKnowledgeItem(Map<String, List<KnowledgeItem>> groupedKnowledgeItemMap, Reference reference)
getNameback to summary
public String getName()

Implements abstract org.jabref.logic.importer.Importer.getName.

Doc from org.jabref.logic.importer.Importer.getName.

Returns the name of this import format. Typically, this is a string that denotes file type or format. It can also be localized, like "XMP-annotated PDF".

Annotations
@Override
getPagesback to summary
private String getPages(String pageRange, String pageCount)

PageRange and PageCount tags contain text with additional markers that need to be discarded.

Example PageCount:

<PageCount> <c>113</c> <in>true</in> <os>113</os> <ps>113</ps> </PageCount>
<PageCount>
<c>113</c> <in>true</in> <os>113</os> <ps>113</ps>
</PageCount>

Contents of PageCount after parsing above example data:

<c>113</c> <in>true</in> <os>113</os> <ps>113</ps>
<c>113</c> <in>true</in> <os>113</os> <ps>113</ps>

Content of "ps" tag is returned by getPages.

Example PageRange:

<PageRange> <![CDATA[ <sp> <n>34165</n> <in>true</in> <os>34165</os> <ps>34165</ps> </sp> <ep> <n>34223</n> <in>true</in> <os>34223</os> <ps>34223</ps> </ep> <os>34165-223</os> ]]> </PageRange>
<PageRange>
<![CDATA[
<sp> <n>34165</n> <in>true</in> <os>34165</os> <ps>34165</ps> </sp>
<ep> <n>34223</n> <in>true</in> <os>34223</os> <ps>34223</ps> </ep>
<os>34165-223</os>
]]>
</PageRange>

Contents of PageRange after parsing above example data:

<sp> <n>24</n> <in>true</in> <os>24</os> <ps>24</ps> </sp> <ep> <n>31</n> <in>true</in> <os>31</os> <ps>31</ps> </ep> <os>24-31</os>
<sp> <n>24</n> <in>true</in> <os>24</os> <ps>24</ps> </sp>
<ep> <n>31</n> <in>true</in> <os>31</os> <ps>31</ps> </ep>
<os>24-31</os>

Content of "os" tag is returned by getPages.

getReaderFromZipback to summary
private BufferedReader getReaderFromZip(Path filePath) throws IOException
getTypeback to summary
private EntryType getType(Reference reference)
importDatabaseback to summary
public ParserResult importDatabase(@NonNull Path filePath) throws IOException

Overrides org.jabref.logic.importer.Importer.importDatabase.

Doc from org.jabref.logic.importer.Importer.importDatabase.

Parse the database in the specified file.

Annotations
@Override
importDatabaseback to summary
public ParserResult importDatabase(@NonNull BufferedReader reader) throws IOException

Implements abstract org.jabref.logic.importer.Importer.importDatabase.

Doc from org.jabref.logic.importer.Importer.importDatabase.

Parse the database in the source.

This method can be called in two different contexts - either when importing in a specified format, or when importing in unknown format. In the latter case, JabRef cycles through all available import formats. No error messages or feedback is displayed from individual import formats in this case.

If importing in a specified format and an empty library is returned, JabRef reports that no entries were found.

If your format is binary-based (PDF, ZIP-based, or others), then you should not solely override this method. For binary formats do this:

  1. Throw UnsupportedOperationException in this method.
  2. Override the method Importer#importDatabase(Path). Example of this workaround is in: org.jabref.logic.importer.fileformat.pdf.PdfImporter.
Annotations
@Override
isRecognizedFormatback to summary
public boolean isRecognizedFormat(@NonNull Reader reader) throws IOException

Overrides org.jabref.logic.importer.Importer.isRecognizedFormat.

Doc from org.jabref.logic.importer.Importer.isRecognizedFormat.

#isRecognizedFormat(BufferedReader) without the requirement to reset

Annotations
@Override
isRecognizedFormatback to summary
public boolean isRecognizedFormat(@NonNull Path filePath) throws IOException

Overrides org.jabref.logic.importer.Importer.isRecognizedFormat.

Doc from org.jabref.logic.importer.Importer.isRecognizedFormat.

Check whether the source is in the correct format for this importer.

Annotations
@Override
Exceptions
IOException:
Signals that an I/O exception has occurred.
parseCitaviDataback to summary
private void parseCitaviData(XMLStreamReader reader) throws XMLStreamException
parseEntriesback to summary
public List<BibEntry> parseEntries(InputStream inputStream)

Implements org.jabref.logic.importer.Parser.parseEntries.

Annotations
@Override
parseKeywordback to summary
private void parseKeyword(XMLStreamReader reader) throws XMLStreamException
parseKeywordsback to summary
private void parseKeywords(XMLStreamReader reader) throws XMLStreamException
parseKnowledgeItemback to summary
private void parseKnowledgeItem(XMLStreamReader reader) throws XMLStreamException
parseKnowledgeItemsback to summary
private void parseKnowledgeItems(XMLStreamReader reader) throws XMLStreamException
parsePersonback to summary
private void parsePerson(XMLStreamReader reader) throws XMLStreamException
parsePersonsback to summary
private void parsePersons(XMLStreamReader reader) throws XMLStreamException
parsePublisherback to summary
private void parsePublisher(XMLStreamReader reader) throws XMLStreamException
parsePublishersback to summary
private void parsePublishers(XMLStreamReader reader) throws XMLStreamException
parseReferenceback to summary
private void parseReference(XMLStreamReader reader) throws XMLStreamException
parseReferencesback to summary
private void parseReferences(XMLStreamReader reader) throws XMLStreamException
removeSpacesBeforeLineBreakback to summary
private String removeSpacesBeforeLineBreak(String string)
resolveKeywordMapback to summary
private Map<String, String> resolveKeywordMap(Map<String, List<String>> referenceIdMap, Map<String, Keyword> keywordMap)
resolvePersonMapback to summary
private Map<String, String> resolvePersonMap(Map<String, List<String>> referenceIdMap, Map<String, Author> personMap)
resolvePublisherMapback to summary
private Map<String, String> resolvePublisherMap(Map<String, List<String>> referenceIdMap, Map<String, String> publisherMap)
sanitizeCitationKeyback to summary
private static String sanitizeCitationKey(String key)
setEntryFieldsFromReferenceback to summary
private void setEntryFieldsFromReference(BibEntry entry, Reference reference)
org.jabref.logic.importer.fileformat back to summary

pack-priv final Enum CitaviXmlImporter.QuotationTypeMapping

extends Enum<CitaviXmlImporter.QuotationTypeMapping>
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final int
public static final CitaviXmlImporter.QuotationTypeMapping
public static final CitaviXmlImporter.QuotationTypeMapping
public static final CitaviXmlImporter.QuotationTypeMapping
public static final CitaviXmlImporter.QuotationTypeMapping
public static final CitaviXmlImporter.QuotationTypeMapping
public static final CitaviXmlImporter.QuotationTypeMapping
pack-priv final String
public static final CitaviXmlImporter.QuotationTypeMapping

Constructor Summary

AccessConstructor and Description
private
QuotationTypeMapping(int citaviType, String name)

Method Summary

Modifier and TypeMethod and Description
pack-priv int
pack-priv String
public static CitaviXmlImporter.QuotationTypeMapping
public static CitaviXmlImporter.QuotationTypeMapping[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

citaviTypeback to summary
pack-priv final int citaviType
COMMENTback to summary
public static final CitaviXmlImporter.QuotationTypeMapping COMMENT
DIRECT_QUOTATIONback to summary
public static final CitaviXmlImporter.QuotationTypeMapping DIRECT_QUOTATION
HIGHLIGHTback to summary
public static final CitaviXmlImporter.QuotationTypeMapping HIGHLIGHT
HIGHLIGHT_REDback to summary
public static final CitaviXmlImporter.QuotationTypeMapping HIGHLIGHT_RED
IMAGE_QUOTATIONback to summary
public static final CitaviXmlImporter.QuotationTypeMapping IMAGE_QUOTATION
INDIRECT_QUOTATIONback to summary
public static final CitaviXmlImporter.QuotationTypeMapping INDIRECT_QUOTATION
nameback to summary
pack-priv final String name

Hides java.lang.Enum.name.

SUMMARYback to summary
public static final CitaviXmlImporter.QuotationTypeMapping SUMMARY

Constructor Detail

QuotationTypeMappingback to summary
private QuotationTypeMapping(int citaviType, String name)

Method Detail

getCitaviIndexTypeback to summary
pack-priv int getCitaviIndexType()
getNameback to summary
pack-priv String getName()
valueOfback to summary
public static CitaviXmlImporter.QuotationTypeMapping valueOf(String name)
valuesback to summary
public static CitaviXmlImporter.QuotationTypeMapping[] values()