Skip to content

Commit

Permalink
Introduce new Fetcher interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez committed Jul 16, 2016
1 parent 622a0da commit c73592c
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/main/java/net/sf/jabref/importer/fetcher/IdBasedFetcher.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (C) 2003-2016 JabRef contributors.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

package net.sf.jabref.importer.fetcher;

import java.util.Optional;

import net.sf.jabref.model.entry.BibEntry;

/**
* Searches web resources for bibliographic information based on an identifier.
*/
public interface IdBasedFetcher extends WebFetcher {

/**
* Looks for bibliographic information associated to the given identifier.
*
* @param identifier a string which uniquely identifies the item
* @return a {@link BibEntry} containing the bibliographic information (or an empty optional if no data was found)
*/
Optional<BibEntry> performSearch(String identifier);
}
36 changes: 36 additions & 0 deletions src/main/java/net/sf/jabref/importer/fetcher/IdFetcher.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (C) 2003-2016 JabRef contributors.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

package net.sf.jabref.importer.fetcher;

import net.sf.jabref.model.entry.BibEntry;

/**
* Looks for article identifier based on already present bibliographic information.
*/
public interface IdFetcher {

/**
* Looks for an identifier based on the information stored in the given {@link BibEntry} and
* then updates the {@link BibEntry} with the found id.
*
* @param entry the {@link BibEntry} for which an identifier should be found
* @return an updated {@link BibEntry} containing the identifier (if an ID was found, otherwise the {@link BibEntry}
* is left unchanged)
*/
BibEntry updateIdentfier(BibEntry entry);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (C) 2003-2016 JabRef contributors.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

package net.sf.jabref.importer.fetcher;

import java.util.List;

import net.sf.jabref.model.entry.BibEntry;

/**
* Searches web resources for bibliographic information based on a free-text query.
* May return multiple search hits.
*/
public interface SearchBasedFetcher extends WebFetcher {

/**
* Looks for hits which are matched by the given free-text query.
* This is the first step in the search procedure and we are mainly interested in the authors, title and the URL.
*
* @param query search string
* @return a list of {@link BibEntry}, which are matched by the query (may be empty)
*/
List<BibEntry> performShallowSearch(String query);

/**
* Enriches the given {@link BibEntry} (which is usually an entry found by
* {@link #performShallowSearch(String)}) by additional information.
*
* @param entry the entry to be completed
* @return a {@link BibEntry} containing the enriched bibliographic information
*/
BibEntry performDeepSearch(BibEntry entry);
}
41 changes: 41 additions & 0 deletions src/main/java/net/sf/jabref/importer/fetcher/WebFetcher.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (C) 2003-2016 JabRef contributors.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

package net.sf.jabref.importer.fetcher;

import net.sf.jabref.gui.help.HelpFile;

/**
* Searches web resources for bibliographic information.
*/
public interface WebFetcher {

/**
* Returns the localized name of this fetcher.
* The title can be used to display the fetcher in the menu and in the side pane.
*
* @return the localized name
*/
String getName();

/**
* Returns the help page for this fetcher.
*
* @return the {@link HelpFile} enum constant for the help page
*/
HelpFile getHelpPage();
}

0 comments on commit c73592c

Please sign in to comment.