Package net.sf.jabref.imports

Examples of net.sf.jabref.imports.BibtexParser


                            } catch (IOException ex) {
                                ex.printStackTrace();
                            }
                        } else if (content.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                           try {
                                  BibtexParser bp = new BibtexParser
                                      (new java.io.StringReader( (String) (content.getTransferData(
                                      DataFlavor.stringFlavor))));
                                  BibtexDatabase db = bp.parse().getDatabase();
                                  Util.pr("Parsed " + db.getEntryCount() + " entries from clipboard text");
                                  if(db.getEntryCount()>0) {
                                      bes = db.getEntries().toArray(new BibtexEntry[db.getEntryCount()]);
                                  }
                              } catch (UnsupportedFlavorException ex) {
View Full Code Here


    assertEquals("Ed von Test", e.getField("author"));
  }

  public void testBibtexParser() {
    try {
      new BibtexParser(null);
      fail("Should not accept null.");
    } catch (NullPointerException npe) {

    }
  }
View Full Code Here

  }

  public void testParse() throws IOException {

    // Test Standard parsing
    BibtexParser parser = new BibtexParser(new StringReader(
      "@article{test,author={Ed von Test}}"));
    ParserResult result = parser.parse();

    Collection<BibtexEntry> c = result.getDatabase().getEntries();
    assertEquals(1, c.size());

    BibtexEntry e = c.iterator().next();
    assertEquals("test", e.getCiteKey());
    assertEquals(2, e.getAllFields().size());
    assertTrue(e.getAllFields().contains("author"));
    assertEquals("Ed von Test", e.getField("author"));

    // Calling parse again will return the same result
    assertEquals(result, parser.parse());
  }
View Full Code Here

    assertEquals(result, parser.parse());
  }

  public void testParse2() throws IOException {

    BibtexParser parser = new BibtexParser(new StringReader(
      "@article{test,author={Ed von Test}}"));
    ParserResult result = parser.parse();

    BibtexEntry e = new BibtexEntry("", BibtexEntryType.ARTICLE);
    e.setField("author", "Ed von Test");
    e.setField("bibtexkey", "test");
View Full Code Here

        "  doi = {http://dx.doi.org/10.1287/orsc.14.2.209.14992}," + "\n" +
        "  issn = {1526-5455}," + "\n" +
        "  publisher = {INFORMS}" + "\n" +
        "}");

    BibtexParser parser = new BibtexParser(reader);
    ParserResult result = null;
    try {
      result = parser.parse();
    } catch (Exception e){
      fail();
    }
    database = result.getDatabase();
    entry = database.getEntriesByKey("HipKro03")[0];
View Full Code Here

          + "  number = {2},\n"
          + "  address = {Institute for Operations Research and the Management Sciences (INFORMS), Linthicum, Maryland, USA},\n"
          + "  doi = {http://dx.doi.org/10.1287/orsc.14.2.209.14992}," + "\n"
          + "  issn = {1526-5455}," + "\n" + "  publisher = {INFORMS}\n" + "}");

      BibtexParser parser = new BibtexParser(reader);
      ParserResult result = null;
      try {
        result = parser.parse();
      } catch (Exception e) {
        fail();
      }
      database = result.getDatabase();
      entry = database.getEntriesByKey("HipKro03")[0];
View Full Code Here

     * public boolean storeSourceIfNeeded() { if (tabbed.getSelectedIndex() ==
     * sourceIndex) return storeSource(); else return true; }
     */
    public boolean storeSource(boolean showError) {
        // Store edited bibtex code.
        BibtexParser bp = new BibtexParser(new java.io.StringReader(source.getText()));

        try {
            BibtexDatabase db = bp.parse().getDatabase();

            if (db.getEntryCount() > 1)
                throw new Exception("More than one entry found.");

            if (db.getEntryCount() < 1)
View Full Code Here

TOP

Related Classes of net.sf.jabref.imports.BibtexParser

Copyright © 2018 www.massapicom. 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.