Examples of ParserResult


Examples of net.sf.jabref.imports.ParserResult

      XMPUtil.main(new String[] { pdfFile.getAbsolutePath() });
      System.setOut(oldOut);
      s.close();
      String bibtex = s.toString();

      ParserResult result = BibtexParser.parse(new StringReader(bibtex));
      Collection<BibtexEntry> c = result.getDatabase().getEntries();
      assertEquals(1, c.size());
      BibtexEntry x = c.iterator().next();

      assertEquals(e, x);
    }
View Full Code Here

Examples of net.sf.jabref.imports.ParserResult

   * Test that readXMP and writeXMP work together.
   *
   * @throws Exception
   */
  public void testResolveStrings() throws Exception {
    ParserResult original = BibtexParser
        .parse(new StringReader(
            "@string{ crow = \"Crowston, K.\"}\n"
                + "@string{ anna = \"Annabi, H.\"}\n"
                + "@string{ howi = \"Howison, J.\"}\n"
                + "@string{ masa = \"Masango, C.\"}\n"
                + "@article{canh05,"
                + "  author = {#crow# and #anna# and #howi# and #masa#},"
                + "\n"
                + "  title = {Effective work practices for floss development: A model and propositions},"
                + "\n"
                + "  booktitle = {Hawaii International Conference On System Sciences (HICSS)},"
                + "\n"
                + "  year = {2005},"
                + "\n"
                + "  owner = {oezbek},"
                + "\n"
                + "  timestamp = {2006.05.29},"
                + "\n"
                + "  url = {http://james.howison.name/publications.html}"
                + "\n" + "}"));

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

    BibtexEntry e = c.iterator().next();

    XMPUtil.writeXMP(pdfFile, e, original.getDatabase());

    List<BibtexEntry> l = XMPUtil.readXMP(pdfFile.getAbsoluteFile());
    assertEquals(1, l.size());
    BibtexEntry x = l.get(0);

View Full Code Here

Examples of net.sf.jabref.imports.ParserResult

   */
  @SuppressWarnings("unchecked")
  public void testResolveStrings2() throws FileNotFoundException,
      IOException, TransformerException {

    ParserResult result = BibtexParser.parse(new FileReader(
        "src/tests/net/sf/jabref/util/twente.bib"));

    assertEquals("Arvind", result.getDatabase().resolveForStrings(
        "#Arvind#"));

    AuthorList originalAuthors = AuthorList
        .getAuthorList("Patterson, David and Arvind and Asanov\\'\\i{}c, Krste and Chiou, Derek and Hoe, James and Kozyrakis, Christos and Lu, S{hih-Lien} and Oskin, Mark and Rabaey, Jan and Wawrzynek, John");

    try {
      XMPUtil.writeXMP(pdfFile, result.getDatabase().getEntryByKey(
          "Patterson06"), result.getDatabase());

      // Test whether we the main function can load the bibtex correctly
      BibtexEntry b = XMPUtil.readXMP(pdfFile).get(0);

      assertEquals(originalAuthors, AuthorList.getAuthorList(b.getField(
View Full Code Here

Examples of net.sf.jabref.imports.ParserResult

    assertEquals(new Integer(3), vm.getStack().pop());
    assertEquals("Hallo", vm.getStack().pop());
  }

  public static BibtexEntry bibtexString2BibtexEntry(String s) throws IOException {
    ParserResult result = BibtexParser.parse(new StringReader(s));
    Collection<BibtexEntry> c = result.getDatabase().getEntries();
    assertEquals(1, c.size());
    return c.iterator().next();
  }
View Full Code Here

Examples of net.sf.jabref.imports.ParserResult

        "  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];
   
    assertNotNull(database);
    assertNotNull(entry);
  }
View Full Code Here

Examples of net.sf.jabref.imports.ParserResult

   * @throws FileNotFoundException
   * @throws IOException
   */
  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#"));
   
View Full Code Here

Examples of net.sf.jabref.imports.ParserResult

          + "  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];
    }
    return entry;
  }
View Full Code Here

Examples of net.sf.jabref.imports.ParserResult

        try {
            //long startTime = System.currentTimeMillis();

            // Parse the temporary file.
            File tempFile = Globals.fileUpdateMonitor.getTempFile(panel.fileMonitorHandle());
            ParserResult pr = OpenDatabaseAction.loadDatabase(tempFile,
            Globals.prefs.get("defaultEncoding"));
            inTemp = pr.getDatabase();
            mdInTemp = new MetaData(pr.getMetaData(),inTemp);
            // Parse the modified file.
            pr = OpenDatabaseAction.loadDatabase(f, Globals.prefs.get("defaultEncoding"));
            BibtexDatabase onDisk = pr.getDatabase();
            MetaData mdOnDisk = new MetaData(pr.getMetaData(),onDisk);

            // Sort both databases according to a common sort key.
            EntryComparator comp = new EntryComparator(false, true, sortBy[2]);
            comp = new EntryComparator(false, true, sortBy[1], comp);
            comp = new EntryComparator(false, true, sortBy[0], comp);
View Full Code Here

Examples of net.sf.jabref.imports.ParserResult

        fileType = Globals.prefs.getExternalFileTypeByExt(extension);
      }
      if (extension.equals("bib")) {
        File f = new File(fileNames[i]);
        try {
          ParserResult pr = OpenDatabaseAction.loadDatabase(f, encoding);
          if ((pr == null) || (pr == ParserResult.INVALID_FORMAT)) {
            notBibFiles.add(fileNames[i]);
          } else {
            openAction.addNewDatabase(pr, f, true);
                        frame.getFileHistory().newFile(fileNames[i]);
View Full Code Here

Examples of net.sf.jabref.imports.ParserResult

        }

      } else if (args[0].endsWith(".bib")) {
        // Read from bib and write as XMP

        ParserResult result = BibtexParser
            .parse(new FileReader(args[0]));
        Collection<BibtexEntry> entries = result.getDatabase()
            .getEntries();

        if (entries.size() == 0) {
          System.err.println("Could not find BibtexEntry in "
              + args[0]);
        } else {
          System.out.println(XMPUtil.toXMP(entries, result
              .getDatabase()));
        }

      } else {
        usage();
      }
      break;
    }
    case 2: {
      if (args[0].equals("-x") && args[1].endsWith(".pdf")) {
        // Read from pdf and write as BibTex
        XMPMetadata meta = XMPUtil.readRawXMP(new File(args[1]));

        if (meta == null) {
          System.err
              .println("The given pdf does not contain any XMP-metadata.");
        } else {
          XMLUtil.save(meta.getXMPDocument(), System.out, "UTF-8");
        }
        break;
      }

      if (args[0].endsWith(".bib") && args[1].endsWith(".pdf")) {
        ParserResult result = BibtexParser
            .parse(new FileReader(args[0]));

        Collection<BibtexEntry> entries = result.getDatabase()
            .getEntries();

        if (entries.size() == 0) {
          System.err.println("Could not find BibtexEntry in "
              + args[0]);
        } else {
          XMPUtil.writeXMP(new File(args[1]), entries, result
              .getDatabase(), false);
          System.out.println("XMP written.");
        }
        break;
      }

      usage();
      break;
    }
    case 3: {
      if (!args[1].endsWith(".bib") && !args[2].endsWith(".pdf")) {
        usage();
        break;
      }

      ParserResult result = BibtexParser.parse(new FileReader(args[1]));

      BibtexEntry e = result.getDatabase().getEntryByKey(args[0]);

      if (e == null) {
        System.err.println("Could not find BibtexEntry " + args[0]
            + " in " + args[0]);
      } else {
        XMPUtil.writeXMP(new File(args[2]), e, result.getDatabase());

        System.out.println("XMP written.");
      }
      break;
    }
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.