Package net.sf.jabref

Examples of net.sf.jabref.AuthorList


public class BibtexNameFormatterTest extends TestCase {

  public void testFormatName() {
    {
      AuthorList al = AuthorList
        .getAuthorList("Charles Louis Xavier Joseph de la Vall{\\'e}e Poussin");

      assertEquals("de~laVall{\\'e}e~PoussinCharles Louis Xavier~Joseph", BibtexNameFormatter.formatName(al
        .getAuthor(0), "{vv}{ll}{jj}{ff}", new Warn() {
        public void warn(String s) {
          fail(s);
        }
      }));
    }
   
    {
      AuthorList al = AuthorList
        .getAuthorList("Charles Louis Xavier Joseph de la Vall{\\'e}e Poussin");

      assertEquals("de~la Vall{\\'e}e~Poussin, C.~L. X.~J.", BibtexNameFormatter.formatName(al
        .getAuthor(0), "{vv~}{ll}{, jj}{, f.}", new Warn() {
        public void warn(String s) {
          fail(s);
        }
      }));
    }

    {
      AuthorList al = AuthorList
        .getAuthorList("Charles Louis Xavier Joseph de la Vall{\\'e}e Poussin");

      assertEquals("de~la Vall{\\'e}e~Poussin, C.~L. X.~J?", BibtexNameFormatter.formatName(al
        .getAuthor(0), "{vv~}{ll}{, jj}{, f}?", new Warn() {
        public void warn(String s) {
          fail(s);
        }
      }));
    }

    {
      AuthorList al = AuthorList
        .getAuthorList("Charles Louis Xavier Joseph de la Vall{\\'e}e Poussin");

      assertEquals("dlVP", BibtexNameFormatter.formatName(al.getAuthor(0), "{v{}}{l{}}",
        new Warn() {
          public void warn(String s) {
            fail(s);
          }
        }));
View Full Code Here


    for (String field : expected.getAllFields()){
   
      if (field.toString().toLowerCase().equals("author")
          || field.toString().toLowerCase().equals("editor")) {

        AuthorList expectedAuthors = AuthorList.getAuthorList(expected
            .getField(field.toString()).toString());
        AuthorList actualAuthors = AuthorList.getAuthorList(actual
            .getField(field.toString()).toString());
        assertEquals(expectedAuthors, actualAuthors);
      } else {
        assertEquals(
            "" + field.toString(),
View Full Code Here

        "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());
View Full Code Here

        + "John Smith and Black Brown, Peter"));
  }

  public void testGetAuthorList() {
    // Test caching in authorCache.
    AuthorList al = AuthorList.getAuthorList("John Smith");
    assertTrue(al == AuthorList.getAuthorList("John Smith"));
    assertFalse(al == AuthorList.getAuthorList("Smith"));
  }
View Full Code Here

     */
    assertEquals("Last-Name et al.", AuthorList.getAuthorList(
      "First Second Last-Name" + " and John Smith and Black Brown, Peter").getAuthorsNatbib());

    // Test caching
    AuthorList al = AuthorList
      .getAuthorList("John von Neumann and John Smith and Black Brown, Peter");
    assertTrue(al.getAuthorsNatbib() == al.getAuthorsNatbib());
  }
View Full Code Here

    }
  }

  public void testGetAuthorsLastFirst() {
    { // No commas before and
      AuthorList al;

      al = AuthorList.getAuthorList("");
      assertEquals("", al.getAuthorsLastFirst(true, false));
      assertEquals("", al.getAuthorsLastFirst(false, false));

      al = AuthorList.getAuthorList("John Smith");
      assertEquals("Smith, John", al.getAuthorsLastFirst(false, false));
      assertEquals("Smith, J.", al.getAuthorsLastFirst(true, false));

      al = AuthorList.getAuthorList("John Smith and Black Brown, Peter");
      assertEquals("Smith, John and Black Brown, Peter", al.getAuthorsLastFirst(false, false));
      assertEquals("Smith, J. and Black Brown, P.", al.getAuthorsLastFirst(true, false));

      al = AuthorList.getAuthorList("John von Neumann and John Smith and Black Brown, Peter");
      // Method description is different than code -> additional comma
      // there
      assertEquals("von Neumann, John, Smith, John and Black Brown, Peter", al
        .getAuthorsLastFirst(false, false));
      assertEquals("von Neumann, J., Smith, J. and Black Brown, P.", al.getAuthorsLastFirst(
        true, false));

      al = AuthorList.getAuthorList("John Peter von Neumann");
      assertEquals("von Neumann, J. P.", al.getAuthorsLastFirst(true, false));
    }
    { // Oxford comma
      AuthorList al;

      al = AuthorList.getAuthorList("");
      assertEquals("", al.getAuthorsLastFirst(true, true));
      assertEquals("", al.getAuthorsLastFirst(false, true));

      al = AuthorList.getAuthorList("John Smith");
      assertEquals("Smith, John", al.getAuthorsLastFirst(false, true));
      assertEquals("Smith, J.", al.getAuthorsLastFirst(true, true));

      al = AuthorList.getAuthorList("John Smith and Black Brown, Peter");
      assertEquals("Smith, John and Black Brown, Peter", al.getAuthorsLastFirst(false, true));
      assertEquals("Smith, J. and Black Brown, P.", al.getAuthorsLastFirst(true, true));

      al = AuthorList.getAuthorList("John von Neumann and John Smith and Black Brown, Peter");
      assertEquals("von Neumann, John, Smith, John, and Black Brown, Peter", al
        .getAuthorsLastFirst(false, true));
      assertEquals("von Neumann, J., Smith, J., and Black Brown, P.", al.getAuthorsLastFirst(
        true, true));

      al = AuthorList.getAuthorList("John Peter von Neumann");
      assertEquals("von Neumann, J. P.", al.getAuthorsLastFirst(true, true));
    }
  }
View Full Code Here

  }

  public void testGetAuthorsFirstFirst() {

    AuthorList al;

    al = AuthorList.getAuthorList("");
    assertEquals("", al.getAuthorsFirstFirst(true, false));
    assertEquals("", al.getAuthorsFirstFirst(false, false));
    assertEquals("", al.getAuthorsFirstFirst(true, true));
    assertEquals("", al.getAuthorsFirstFirst(false, true));

    al = AuthorList.getAuthorList("John Smith");
    assertEquals("John Smith", al.getAuthorsFirstFirst(false, false));
    assertEquals("J. Smith", al.getAuthorsFirstFirst(true, false));
    assertEquals("John Smith", al.getAuthorsFirstFirst(false, true));
    assertEquals("J. Smith", al.getAuthorsFirstFirst(true, true));

    al = AuthorList.getAuthorList("John Smith and Black Brown, Peter");
    assertEquals("John Smith and Peter Black Brown", al.getAuthorsFirstFirst(false, false));
    assertEquals("J. Smith and P. Black Brown", al.getAuthorsFirstFirst(true, false));
    assertEquals("John Smith and Peter Black Brown", al.getAuthorsFirstFirst(false, true));
    assertEquals("J. Smith and P. Black Brown", al.getAuthorsFirstFirst(true, true));

    al = AuthorList.getAuthorList("John von Neumann and John Smith and Black Brown, Peter");
    assertEquals("John von Neumann, John Smith and Peter Black Brown", al.getAuthorsFirstFirst(
      false, false));
    assertEquals("J. von Neumann, J. Smith and P. Black Brown", al.getAuthorsFirstFirst(true,
      false));
    assertEquals("John von Neumann, John Smith, and Peter Black Brown", al
      .getAuthorsFirstFirst(false, true));
    assertEquals("J. von Neumann, J. Smith, and P. Black Brown", al.getAuthorsFirstFirst(true,
      true));

    al = AuthorList.getAuthorList("John Peter von Neumann");
    assertEquals("John Peter von Neumann", al.getAuthorsFirstFirst(false, false));
    assertEquals("John Peter von Neumann", al.getAuthorsFirstFirst(false, true));
    assertEquals("J. P. von Neumann", al.getAuthorsFirstFirst(true, false));
    assertEquals("J. P. von Neumann", al.getAuthorsFirstFirst(true, true));
  }
View Full Code Here

   
  }
 
  public String format(String toFormat, String parameters, BibtexEntry currentEntry) {
   
    AuthorList al = AuthorList.getAuthorList(toFormat);
   
    if (parameters == null || parameters.length() == 0){
      parameters = "*:*:\"{ff}{vv}{ll}{,jj} \"";
    }
   
    String[] cases = parameters.split("@@");
    for (int i = 0; i < cases.length; i++){
      String[] formatString = cases[i].split("@");
     
      if (formatString.length < 3){
        // Error
        return toFormat;
      }
     
      if (formatString[0].equals("*")){
        return format(toFormat, al, formatString);
      } else {
        if (al.size() <= Integer.parseInt(formatString[0])){
          return format(toFormat, al, formatString);
        }
      }
    }
    return toFormat;
View Full Code Here

*
*/
public class AuthorOrgSci implements LayoutFormatter {

  public String format(String fieldText) {
    AuthorList a = AuthorList.getAuthorList(fieldText);
    if (a.size() == 0) {
      return fieldText;
    }
    Author first = a.getAuthor(0);
    StringBuffer sb = new StringBuffer();
    sb.append(first.getLastFirst(true));
    for (int i = 1; i < a.size(); i++) {
      sb.append(", ").append(a.getAuthor(i).getFirstLast(true));
    }
    return sb.toString();
  }
View Full Code Here

    public String format(String fieldText)
    {
        //    <editor><firstname>L.</firstname><surname>Xue</surname></editor>
        StringBuilder sb = new StringBuilder(100);
        AuthorList al = AuthorList.getAuthorList(fieldText);
        addBody(sb, al, "editor");
        return sb.toString();
       
    }
View Full Code Here

TOP

Related Classes of net.sf.jabref.AuthorList

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.