Examples of BibtexDatabase


Examples of net.sf.jabref.BibtexDatabase

  private BibtexDatabase getDatabse() {
    Globals.prefs = JabRefPreferences.getInstance();
    File fileToLoad = new File(PATH_TO_TEST_BIBTEX);
    ParserResult pr = JabRef.openBibFile(fileToLoad.getPath(), true);
    BibtexDatabase filledDatabase = pr.getDatabase();
    return filledDatabase;
  }
View Full Code Here

Examples of net.sf.jabref.BibtexDatabase

   */
  public void testResolveStrings() throws FileNotFoundException, IOException{
   
    ParserResult result = BibtexParser.parse(new FileReader("src/tests/net/sf/jabref/util/twente.bib"));
   
    BibtexDatabase db = result.getDatabase();
   
    assertEquals("Arvind", db.resolveForStrings("#Arvind#"));
    assertEquals("Patterson, David", db.resolveForStrings("#Patterson#"));
    assertEquals("Arvind and Patterson, David", db.resolveForStrings("#Arvind# and #Patterson#"));
   
    // Strings that are not found return just the given string.
    assertEquals("#unknown#", db.resolveForStrings("#unknown#"));
   
  }
View Full Code Here

Examples of net.sf.jabref.BibtexDatabase

   * Try to find an equivalent bibtex entry into reference database for all keys
   * (found in aux file). This methode will fill up some intern data structures.....
   */
  public final void resolveTags()
  {
    auxDB = new BibtexDatabase() ;
    notFoundList.clear();

    Iterator<String> it = mySet.iterator() ;

    // forall bibtex keys (found in aux-file) try to find an equivalent
View Full Code Here

Examples of net.sf.jabref.BibtexDatabase

    }

  public BibtexDatabase getGeneratedDatabase()
  {
    if (auxDB == null)
      auxDB = new BibtexDatabase() ;

    return auxDB ;
  }
View Full Code Here

Examples of net.sf.jabref.BibtexDatabase

    bib = refDBase ;
  }

  public BibtexDatabase perform()
  {
    BibtexDatabase back = null ;
    if ( (auxName.length() > 0) && (bib != null) )
    {
      AuxSubGenerator auxParser = new AuxSubGenerator(bib) ;
      Vector<String> returnValue = auxParser.generate(auxName, bib) ;
      back = auxParser.getGeneratedDatabase() ;
View Full Code Here

Examples of net.sf.jabref.BibtexDatabase

    generateButton.setEnabled( false ) ;
    BasePanel bp = ( BasePanel ) parentTabbedPane.getComponentAt(
        dbChooser.getSelectedIndex() ) ;
    notFoundList.removeAll() ;
    statusInfos.setText( null ) ;
    BibtexDatabase refBase = bp.getDatabase() ;
    String auxName = auxFileField.getText() ;

    if ( auxName != null )
    {
      if ( ( refBase != null ) && ( auxName.length() > 0 ) )
      {
        auxParser.clear() ;
        notFoundList.setListData( auxParser.generate( auxName, refBase ) ) ;

        statusInfos.append( Globals.lang( "keys in database" ) + " " +
                            refBase.getEntryCount() ) ;
        statusInfos.append( "\n" + Globals.lang( "found in aux file" ) + " " +
                            auxParser.getFoundKeysInAux() ) ;
        statusInfos.append( "\n" + Globals.lang( "resolved" ) + " " +
                            auxParser.getResolvedKeysCount() ) ;
        statusInfos.append( "\n" + Globals.lang( "not found" ) + " " +
View Full Code Here

Examples of net.sf.jabref.BibtexDatabase

  public static void mergeFromBibtex(JabRefFrame frame, BasePanel panel, ParserResult pr,
                                boolean importEntries, boolean importStrings,
                                boolean importGroups, boolean importSelectorWords)
              throws KeyCollisionException {

          BibtexDatabase fromDatabase = pr.getDatabase();
          ArrayList<BibtexEntry> appendedEntries = new ArrayList<BibtexEntry>();
          ArrayList<BibtexEntry> originalEntries = new ArrayList<BibtexEntry>();
          BibtexDatabase database = panel.database();
          BibtexEntry originalEntry;
          NamedCompound ce = new NamedCompound(Globals.lang("Append database"));
          MetaData meta = new MetaData(pr.getMetaData(), pr.getDatabase());

          if (importEntries) { // Add entries
              boolean overwriteOwner = Globals.prefs.getBoolean("overwriteOwner");
              boolean overwriteTimeStamp = Globals.prefs.getBoolean("overwriteTimeStamp");

            for (String key : fromDatabase.getKeySet()){
                originalEntry = fromDatabase.getEntryById(key);
                  BibtexEntry be = (BibtexEntry) (originalEntry.clone());
                  be.setId(Util.createNeutralId());
                  Util.setAutomaticFields(be, overwriteOwner, overwriteTimeStamp);
                  database.insertEntry(be);
                  appendedEntries.add(be);
                  originalEntries.add(originalEntry);
                  ce.addEdit(new UndoableInsertEntry(database, be, panel));
              }
          }

          if (importStrings) {
              for (BibtexString bs : fromDatabase.getStringValues()){
                  if (!database.hasStringLabel(bs.getName())) {
                      database.addString(bs);
                      ce.addEdit(new UndoableInsertString(panel, database, bs));
                  }
              }
          }
View Full Code Here

Examples of net.sf.jabref.BibtexDatabase

  public boolean processQuery(String query, ImportInspector dialog,
                OutputPrinter frame) {
    try {
      frame.setStatus("Fetching entries from Spires");
      /* query the archive and load the results into the BibtexEntry */
      BibtexDatabase bd = importSpiresEntries(query,frame);

      /* addSpiresURLtoDatabase(bd); */

      frame.setStatus("Adding fetched entries");
      /* add the entry to the inspection dialog */
      if (bd.getEntryCount() > 0)
            for (BibtexEntry entry : bd.getEntries())
              dialog.addEntry(entry);

      /* update the dialogs progress bar */
      // dialog.setProgress(i + 1, keys.length);
      /* inform the inspection dialog, that we're done */
 
View Full Code Here

Examples of net.sf.jabref.BibtexDatabase

    public void generateKeySelectedEntry() {
        if (selectionModel.getSelected().size() != 1)
            return;
        BibtexEntry entry = selectionModel.getSelected().get(0);
        entries.getReadWriteLock().writeLock().lock();
        BibtexDatabase database = null;
        // Relate to the existing database, if any:
        if (panel != null)
            database = panel.database();
        // ... or create a temporary one:
        else
            database = new BibtexDatabase();
        try {
            entry.setId(Util.createNeutralId());
            // Add the entry to the database we are working with:
            database.insertEntry(entry);
        } catch (KeyCollisionException ex) {
            ex.printStackTrace();
        }
        // Generate a unique key:
        LabelPatternUtil.makeLabel(Globals.prefs.getKeyPattern(), database, entry);
        // Remove the entry from the database again, since we only added it in
        // order to
        // make sure the key was unique:
        database.removeEntry(entry.getId());

        entries.getReadWriteLock().writeLock().lock();
        glTable.repaint();
    }
View Full Code Here

Examples of net.sf.jabref.BibtexDatabase

     * one another, and, if they are destined for an existing database, with
     * respect to existing keys in the database.
     */
    public void generateKeys(boolean addColumn) {
        entries.getReadWriteLock().writeLock().lock();
        BibtexDatabase database = null;
        // Relate to the existing database, if any:
        if (panel != null)
            database = panel.database();
        // ... or create a temporary one:
        else
            database = new BibtexDatabase();
        List<String> keys = new ArrayList<String>(entries.size());
        // Iterate over the entries, add them to the database we are working
        // with,
        // and generate unique keys:
        for (Iterator<BibtexEntry> i = entries.iterator(); i.hasNext();) {
            BibtexEntry entry = i.next();
            // if (newDatabase) {
            try {
                entry.setId(Util.createNeutralId());
                database.insertEntry(entry);
            } catch (KeyCollisionException ex) {
                ex.printStackTrace();
            }
            // }
            LabelPatternUtil.makeLabel(Globals.prefs.getKeyPattern(), database, entry);
            // Add the generated key to our list:
            keys.add(entry.getCiteKey());
        }
        // Remove the entries from the database again, since they are not
        // supposed to
        // added yet. They only needed to be in it while we generated the keys,
        // to keep
        // control over key uniqueness.
        for (Iterator<BibtexEntry> i = entries.iterator(); i.hasNext();) {
            BibtexEntry entry = i.next();
            database.removeEntry(entry.getId());
        }
        entries.getReadWriteLock().writeLock().lock();
        glTable.repaint();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.