Top Description Fields Constructors Methods
org.jabref.logic.importer.fileformat

public Class RepecNepImporter

extends Importer
Class Inheritance
Imports
java.io.BufferedReader, .IOException, java.util.ArrayList, .Arrays, .Collection, .List, .Objects, org.jabref.logic.importer.ImportFormatPreferences, .Importer, .ParserResult, org.jabref.logic.util.StandardFileType, org.jabref.model.entry.BibEntry, .Date, org.jabref.model.entry.field.StandardField, .UnknownField, org.jabref.model.entry.types.StandardEntryType, org.slf4j.Logger, .LoggerFactory

Imports a New Economics Papers-Message from the REPEC-NEP Service.

RePEc (Research Papers in Economics) is a collaborative effort of over 100 volunteers in 49 countries to enhance the dissemination of research in economics. The heart of the project is a decentralized database of working papers, journal articles and software components. All RePEc material is freely available.

At the time of writing RePEc holds over 300.000 items.

NEP (New Economic Papers) is an announcement service which filters information on new additions to RePEc into edited reports. The goal is to provide subscribers with up-to-date information to the research literature.

This importer is capable of importing NEP messages into JabRef.

There is no officially defined message format for NEP. NEP messages are assumed to have (and almost always have) the form given by the following semi-formal grammar:

NEPMessage:
      MessageSection NEPMessage
      MessageSection

MessageSection:
      OverviewMessageSection
      OtherMessageSection

# we skip the overview
OverviewMessageSection:
      'In this issue we have: ' SectionSeparator OtherStuff

OtherMessageSection:
      SectionSeparator  OtherMessageSectionContent

# we skip other stuff and read only full working paper references
OtherMessageSectionContent:
      WorkingPaper EmptyLine OtherMessageSectionContent
      OtherStuff EmptyLine OtherMessageSectionContent
      ''

OtherStuff:
      NonEmptyLine OtherStuff
      NonEmptyLine

NonEmptyLine:
      a non-empty String that does not start with a number followed by a '.'

# working papers are recognized by a number followed by a '.'
# in a non-overview section
WorkingPaper:
      Number'.' WhiteSpace TitleString EmptyLine Authors EmptyLine Abstract AdditionalFields
      Number'.' WhiteSpace TitleString AdditionalFields Abstract AdditionalFields

TitleString:
      a String that may span several lines and should be joined

# there must be at least one author
Authors:
      Author '\n' Authors
      Author '\n'

# optionally, an institution is given for an author
Author:
      AuthorName
      AuthorName '(' Institution ')'

# there are no rules about the name, it may be firstname lastname or lastname, firstname or anything else
AuthorName:
      a non-empty String without '(' or ')' characters, not spanning more that one line

Institution:
      a non-empty String that may span several lines

Abstract:
      a (possibly empty) String that may span several lines

AdditionalFields:
      AdditionalField '\n' AdditionalFields
      EmptyLine AdditionalFields
      ''

AdditionalField:
      'Keywords:' KeywordList
      'URL:' non-empty String
      'Date:' DateString
      'JEL:' JelClassificationList
      'By': Authors

KeywordList:
       Keyword ',' KeywordList
       Keyword ';' KeywordList
       Keyword

Keyword:
       non-empty String that does not contain ',' (may contain whitespace)

# if no date is given, the current year as given by the system clock is assumed
DateString:
       'yyyy-MM-dd'
       'yyyy-MM'
       'yyyy'

JelClassificationList:
       JelClassification JelClassificationList
       JelClassification

# the JEL Classifications are set into a new BIBTEX-field 'jel'
# they will appear if you add it as a field to one of the BIBTex Entry sections
JelClassification:
       one of the allowed classes, see http://ideas.repec.org/j/

SectionSeparator:
      '\n-----------------------------'

Field Summary

Modifier and TypeField and Description
private final ImportFormatPreferences
private boolean
private String
private int
private static final Logger
private String
private static final Collection<String>

Constructor Summary

AccessConstructor and Description
public
RepecNepImporter(ImportFormatPreferences importFormatPreferences)

Method Summary

Modifier and TypeMethod and Description
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()

Overrides org.jabref.logic.importer.Importer.getId.

Returns a one-word ID which identifies this importer.

public String
getName()

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

Returns the name of this import format.

public ParserResult
importDatabase(BufferedReader
the input to read from
reader
)

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

Parse the database in the source.

public boolean
isRecognizedFormat(BufferedReader reader)

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

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

private boolean
isStartOfWorkingPaper()

if line starts with a string of the form 'x.

private void
parseAbstract(BibEntry be, BufferedReader in)

Implements grammar rule "Abstract".

private void
parseAdditionalFields(BibEntry be, boolean multilineUrlFieldAllowed, BufferedReader in)

Implements grammar rule "AdditionalFields".

private void
parseAuthors(BibEntry be, BufferedReader in)

Implements grammar rule "Authors"

private void
parseTitleString(BibEntry be, BufferedReader in)

Implements grammar rule "TitleString".

private void
private String

Returns:

result
readMultipleLines
(BufferedReader in)

Read multiple lines.

private boolean
Inherited from org.jabref.logic.importer.Importer:
compareToequalsgetCharsetgetReadergetReaderhashCodeimportDatabaseimportDatabaseisRecognizedFormatisRecognizedFormattoString

Field Detail

importFormatPreferencesback to summary
private final ImportFormatPreferences importFormatPreferences
inOverviewSectionback to summary
private boolean inOverviewSection
lastLineback to summary
private String lastLine
lineback to summary
private int line
LOGGERback to summary
private static final Logger LOGGER

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

preLineback to summary
private String preLine
RECOGNIZED_FIELDSback to summary
private static final Collection<String> RECOGNIZED_FIELDS

Constructor Detail

RepecNepImporterback to summary
public RepecNepImporter(ImportFormatPreferences importFormatPreferences)

Method Detail

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 recognizes an import format
Returns:String

description of the 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

Returns:StandardFileType

FileType corresponding to the importer

Annotations
@Override
getIdback to summary
public String getId()

Overrides org.jabref.logic.importer.Importer.getId.

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

Returns a one-word ID which identifies this importer. Used for example, to identify the importer when used from the command line.

Returns:String

ID, must be unique and not null

Annotations
@Override
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.

The name must be unique.

Returns:String

format name, must be unique and not null

Annotations
@Override
importDatabaseback to summary
public ParserResult importDatabase(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.

This method should never return null.

Parameters
reader:BufferedReader

the input to read from

Annotations
@Override
isRecognizedFormatback to summary
public boolean isRecognizedFormat(BufferedReader reader) throws IOException

Implements abstract 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.

The effect of this method is primarily to avoid unnecessary processing of files when searching for a suitable import format. If this method returns false, the import routine will move on to the next import format.

Thus, the correct behaviour is to return false if it is certain that the file is not of the suitable type, and true otherwise. Returning true is the safe choice if not certain.

Annotations
@Override
isStartOfWorkingPaperback to summary
private boolean isStartOfWorkingPaper()

if line starts with a string of the form 'x. ' and we are not in the overview section, we have a working paper entry we are interested in

parseAbstractback to summary
private void parseAbstract(BibEntry be, BufferedReader in) throws IOException

Implements grammar rule "Abstract".

Exceptions
IOException:
in case of error
parseAdditionalFieldsback to summary
private void parseAdditionalFields(BibEntry be, boolean multilineUrlFieldAllowed, BufferedReader in) throws IOException

Implements grammar rule "AdditionalFields".

parseAuthorsback to summary
private void parseAuthors(BibEntry be, BufferedReader in) throws IOException

Implements grammar rule "Authors"

Exceptions
IOException:
in case of error
parseTitleStringback to summary
private void parseTitleString(BibEntry be, BufferedReader in) throws IOException

Implements grammar rule "TitleString".

Exceptions
IOException:
in case of error
readLineback to summary
private void readLine(BufferedReader in) throws IOException
readMultipleLinesback to summary
private String readMultipleLines(BufferedReader in) throws IOException

Read multiple lines.

Reads multiple lines until either

  • an empty line
  • the end of file
  • the next working paper or
  • a keyword
is found. Whitespace at start or end of lines is trimmed except for one blank character.

Returns:String

result

startsWithKeywordback to summary
private boolean startsWithKeyword(Collection<String> keywords)