public class AuthorList
extends java.lang.Object
author
or editor
field in bibtex record.
Constructor performs parsing of raw field text and stores preformatted data. Various accessor methods return author/editor field in different formats.
Parsing algorithm is designed to satisfy two requirements: (a) when author's name is typed correctly, the result should coincide with the one of BiBTeX; (b) for erroneous names, output should be reasonable (but may differ from BiBTeX output). The following rules are used:
Character.isWhitespace(c)==true
),
commas (,), dashes (-), and tildas (~);
Character.isLetter(c)==true
)
that does not belong to a sequence of letters that immediately follows "\"
character, with one exception: if "\" is followed by "aa", "AA", "ae", "AE",
"l", "L", "o", "O", "oe", "OE", "i", or "j" followed by non-letter, the
'first letter' of a token is a letter that follows "\"; for example: in
"a{x}b" 'first letter' is "a", in "{\"{U}}bel" 'first letter' is "U", in
"{\noopsort{\"o}}xyz" 'first letter' is "o", in "{\AE}x" 'first letter' is
"A", in "\aex\ijk\Oe\j" 'first letter' is "j"; if there is no letter
satisfying the above rule, 'first letter' is undefined;
Character.isLowerCase(c)==true
), and token is
"upper-case" token otherwise;
Testcases for this class.
Modifier and Type | Class and Description |
---|---|
static class |
AuthorList.Author
This is an immutable class that keeps information regarding single
author.
|
Modifier | Constructor and Description |
---|---|
protected |
AuthorList(java.lang.String bibtex_authors)
Parses the parameter strings and stores preformatted author information.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o)
Compare this object with the given one.
|
static java.lang.String |
fixAuthor_firstNameFirst(java.lang.String authors)
This is a convenience method for getAuthorsFirstFirstAnds()
|
static java.lang.String |
fixAuthor_firstNameFirstCommas(java.lang.String authors,
boolean abbr,
boolean oxfordComma)
This is a convenience method for getAuthorsFirstFirst()
|
static java.lang.String |
fixAuthor_lastNameFirst(java.lang.String authors)
This is a convenience method for getAuthorsLastFirstAnds(true)
|
static java.lang.String |
fixAuthor_lastNameFirst(java.lang.String authors,
boolean abbreviate)
This is a convenience method for getAuthorsLastFirstAnds()
|
static java.lang.String |
fixAuthor_lastNameFirstCommas(java.lang.String authors,
boolean abbr,
boolean oxfordComma)
This is a convenience method for getAuthorsLastFirst()
|
static java.lang.String |
fixAuthor_lastNameOnlyCommas(java.lang.String authors,
boolean oxfordComma)
This is a convenience method for getAuthorsLastOnly()
|
static java.lang.String |
fixAuthor_Natbib(java.lang.String authors)
This is a convenience method for getAuthorsNatbib()
|
static java.lang.String |
fixAuthorForAlphabetization(java.lang.String authors)
This is a convenience method for getAuthorsForAlphabetization()
|
AuthorList.Author |
getAuthor(int i)
Returns the
Author object for the i-th author. |
static AuthorList |
getAuthorList(java.lang.String authors)
Retrieve an AuthorList for the given string of authors or editors.
|
java.lang.String |
getAuthorsFirstFirst(boolean abbr,
boolean oxfordComma)
Returns the list of authors separated by commas with first names before
last name; first names are abbreviated or not depending on parameter.
|
java.lang.String |
getAuthorsFirstFirstAnds()
Returns the list of authors separated by "and"s with first names before
last name; first names are not abbreviated.
|
java.lang.String |
getAuthorsForAlphabetization()
Returns the list of authors in a form suitable for alphabetization.
|
java.lang.String |
getAuthorsLastFirst(boolean abbreviate,
boolean oxfordComma)
Returns the list of authors separated by commas with first names after
last name; first names are abbreviated or not depending on parameter.
|
java.lang.String |
getAuthorsLastFirstAnds(boolean abbreviate)
Returns the list of authors separated by "and"s with first names after
last name; first names are not abbreviated.
|
java.lang.String |
getAuthorsLastFirstFirstLastAnds(boolean abbreviate) |
java.lang.String |
getAuthorsLastOnly(boolean oxfordComma)
Returns the list of authors separated by commas with last name only; If
the list consists of three or more authors, "and" is inserted before the
last author's name.
|
java.lang.String |
getAuthorsNatbib()
Returns the list of authors in "natbib" format.
|
static void |
main(java.lang.String[] args) |
int |
size()
Returns the number of author names in this object.
|
java.lang.String |
toString() |
protected AuthorList(java.lang.String bibtex_authors)
bibtex_authors
- contents of either author
or editor
bibtex field.public static AuthorList getAuthorList(java.lang.String authors)
authors
- The string of authors or editors in bibtex format to parse.public static java.lang.String fixAuthor_firstNameFirstCommas(java.lang.String authors, boolean abbr, boolean oxfordComma)
getAuthorsFirstFirst(boolean, boolean)
public static java.lang.String fixAuthor_firstNameFirst(java.lang.String authors)
getAuthorsFirstFirstAnds()
public static java.lang.String fixAuthor_lastNameFirstCommas(java.lang.String authors, boolean abbr, boolean oxfordComma)
getAuthorsLastFirst(boolean, boolean)
public static java.lang.String fixAuthor_lastNameFirst(java.lang.String authors)
getAuthorsLastFirstAnds(boolean)
public static java.lang.String fixAuthor_lastNameFirst(java.lang.String authors, boolean abbreviate)
getAuthorsLastFirstAnds(boolean)
public static java.lang.String fixAuthor_lastNameOnlyCommas(java.lang.String authors, boolean oxfordComma)
getAuthorsLastOnly(boolean)
public static java.lang.String fixAuthorForAlphabetization(java.lang.String authors)
getAuthorsForAlphabetization()
public static java.lang.String fixAuthor_Natbib(java.lang.String authors)
getAuthorsNatbib()
public int size()
public AuthorList.Author getAuthor(int i)
Author
object for the i-th author.i
- Index of the author (from 0 to size()-1
).Author
object.public java.lang.String getAuthorsNatbib()
public java.lang.String getAuthorsLastOnly(boolean oxfordComma)
oxfordComma
- Whether to put a comma before the and at the end.For an detailed
explaination about the Oxford comma.
public java.lang.String getAuthorsLastFirst(boolean abbreviate, boolean oxfordComma)
abbreviate
- whether to abbreivate first names.oxfordComma
- Whether to put a comma before the and at the end.For an detailed
explaination about the Oxford comma.
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getAuthorsLastFirstAnds(boolean abbreviate)
public java.lang.String getAuthorsLastFirstFirstLastAnds(boolean abbreviate)
public java.lang.String getAuthorsFirstFirst(boolean abbr, boolean oxfordComma)
abbr
- whether to abbreivate first names.oxfordComma
- Whether to put a comma before the and at the end.For an detailed
explaination about the Oxford comma.
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public java.lang.String getAuthorsFirstFirstAnds()
public java.lang.String getAuthorsForAlphabetization()
public static void main(java.lang.String[] args)