/** * This handles a 3 part name * * @param nameParts * @return */ private PersonNameAuthority maxThreePartNameSplit(String[] fullNameParts) { PersonName personName = new PersonName(); PersonNameAuthority nameAuthority = new PersonNameAuthority(personName); int size = fullNameParts.length; if (size >= 1) { personName.setSurname(fullNameParts[0].trim()); } if (size >= 2) { String firstNameParts = fullNameParts[1].trim(); if (firstNameParts.indexOf("(") == -1) { secondPartWithoutParens(personName, fullNameParts[1].trim()); } else { secondPartWithParens(personName, fullNameParts[1].trim()); } } if (size >= 3) { int birthYear = getBirthYear(fullNameParts[2]); if (birthYear > 0) { nameAuthority.addBirthDate(birthYear); } int deathYear = getDeathYear(fullNameParts[2]); if (deathYear > 0) { nameAuthority.addDeathDate(deathYear); } } return nameAuthority; }
/** * Handles a name that has four parts. * * @param fullNameParts * @return */ private PersonNameAuthority fourPartNameSplit(String[] fullNameParts) { PersonName personName = new PersonName(); PersonNameAuthority nameAuthority = new PersonNameAuthority(personName); // set the last name personName.setSurname(fullNameParts[0].trim()); // take care of last/middle name String firstNameParts = fullNameParts[1].trim(); if (firstNameParts.indexOf("(") == -1) { secondPartWithoutParens(personName, fullNameParts[1].trim()); } else { secondPartWithParens(personName, fullNameParts[1].trim()); } String title = fullNameParts[2]; personName.addPersonNameTitle(title); int birthYear = getBirthYear(fullNameParts[3]); if (birthYear > 0) { nameAuthority.addBirthDate(birthYear); } int deathYear = getDeathYear(fullNameParts[3]); if (deathYear > 0) { nameAuthority.addDeathDate(deathYear); } return nameAuthority; }
/* (non-Javadoc) * @see edu.ur.dspace.load.AuthorNameSplitter#splitName(java.lang.String) */ public PersonNameAuthority splitName(String authorName) { PersonName personName = new PersonName(); PersonNameAuthority nameAuthority = new PersonNameAuthority(personName); // split on the name String[] fullNameParts = authorName.split(","); int size = fullNameParts.length; if (size < 4) { nameAuthority = maxThreePartNameSplit(fullNameParts); } if (size == 4) { nameAuthority = fourPartNameSplit(fullNameParts); } else { personName.setSurname(authorName); } return nameAuthority; }