edu.northwestern.at.wordhoard.swing.calculator.modelutils
Class AuthorUtils

java.lang.Object
  extended by edu.northwestern.at.wordhoard.swing.calculator.modelutils.AuthorUtils

public class AuthorUtils
extends java.lang.Object

Author utilities.


Constructor Summary
protected AuthorUtils()
          Don't allow instantiation but do allow overrides.
 
Method Summary
static Author getAuthor(java.lang.String authorName)
          Get an author by name.
static Author[] getAuthors()
          Get array of all available authors.
static Author[] getContemporaries(Author author, int yearsBefore, int yearsAfter)
          Get contemporaries of an author.
static Author[] getContemporaries(java.lang.String authorName, int yearsBefore, int yearsAfter)
          Get contemporaries of an author.
static Work[] getEarliestAndLatestWork(Author author)
          Get earliest and latest works for an author.
static int[] getEarliestAndLatestWorkDates(Author author)
          Get earliest and latest work dates for an author.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AuthorUtils

protected AuthorUtils()
Don't allow instantiation but do allow overrides.

Method Detail

getContemporaries

public static Author[] getContemporaries(Author author,
                                         int yearsBefore,
                                         int yearsAfter)
Get contemporaries of an author.

Parameters:
author - The author for whom to find contemporaries.
yearsBefore - Number of years before the author was born to consider as a lower bound on the birth date for a contemporary.
yearsAfter - Number of years after the author died to consider as an upper bound on the death date for a contemporary.
Returns:
Array of author entries for contemporaries of the specified author. May be null if author has no contemporaries.

A contemporary is defined as an author who was born up to author's birth date - yearsBefore years before the subject author, and died up to author's death date + yearsAfter after the subject author.


getContemporaries

public static Author[] getContemporaries(java.lang.String authorName,
                                         int yearsBefore,
                                         int yearsAfter)
Get contemporaries of an author.

Parameters:
authorName - Name of author for whom to find contemporaries.
yearsBefore - Number of years before the author was born to consider as a lower bound on the birth date for a contemporary.
yearsAfter - Number of years after the author died to consider as an upper bound on the death date for a contemporary.
Returns:
Array of author entries for contemporaries of the specified author. May be null if author has no contemporaries.

A contemporary is defined as an author who was born up to author's birth date - yearsBefore years before the subject author, and died up to author's death date + yearsAfter after the subject author.


getAuthor

public static Author getAuthor(java.lang.String authorName)
Get an author by name.

Parameters:
authorName - The author's name.
Returns:
An Author object for a matching author. If there are two or more authors with the same name, only the first is returned. Null is returned if no matching author is found.

getAuthors

public static Author[] getAuthors()
Get array of all available authors.

Returns:
Array of Author for all available authors.

getEarliestAndLatestWork

public static Work[] getEarliestAndLatestWork(Author author)
Get earliest and latest works for an author.

Parameters:
author - The author.
Returns:
A two-element Work array as follows. result[0] = earliest work by author. result[1] = latest work by author.

If an author exists but has no works, the result is null.


getEarliestAndLatestWorkDates

public static int[] getEarliestAndLatestWorkDates(Author author)
Get earliest and latest work dates for an author.

Parameters:
author - The author.
Returns:
A two-element integer array as follows. result[0] = year of earliest work by author. result[1] = year of latest work by author.

If an author exists but has no works, both years are returned as Integer.MIN_VALUE .