public Author createAuthorRandom() { int year = 2000 + new Random().nextInt( 8 ); return new AuthorImpl( randomString( boundRandom( 5, 10 ) ) + " et al." + " (" + year + ")" ); }
public static List<Author> splitAuthor(String column) throws IllegalFormatException { //TODO in the future add the year as a new field in the author //Now all is a string and we don not need split the author List<Author> objects = new ArrayList<Author>(); Author object = null; if (column != null && !column.isEmpty()) { String[] fields = MitabParserUtils.quoteAwareSplit(column, new char[]{'|'}, false); for (String field : fields) { if (field != null) { String[] result = MitabParserUtils.quoteAwareSplit(field, new char[]{':', '(', ')'}, true); if (result != null) { int length = result.length; // some exception handling if (length == 0 || length > 3) { throw new IllegalFormatException("String cannot be parsed to create an author (check the syntax): " + Arrays.asList(result).toString()); } if (!field.equalsIgnoreCase("-")) { object = new AuthorImpl(field); } if (object != null) { objects.add(object); } } } } } return objects; }
Author author = new AuthorImpl(authorNameYear.trim()); bi.getAuthors().add(author);
Author mitabAuthor = new AuthorImpl(authorDateValue); binary.getAuthors().add(mitabAuthor);