public class PersonCollection extends Contributor implements java.lang.Iterable
Examples:
Shows how to get bibliography sources available in the document.
Document document = new Document(getMyDir() + "Bibliography sources.docx");
Bibliography bibliography = document.getBibliography();
Assert.assertEquals(12, bibliography.getSources().size());
// Get default data from bibliography sources.
Collection<Source> sources = bibliography.getSources();
Source source = (Source)sources.toArray()[0];
Assert.assertEquals("Book 0 (No LCID)", source.getTitle());
Assert.assertEquals(SourceType.BOOK, source.getSourceType());
Assert.assertNull(source.getAbbreviatedCaseNumber());
Assert.assertNull(source.getAlbumTitle());
Assert.assertNull(source.getBookTitle());
Assert.assertNull(source.getBroadcaster());
Assert.assertNull(source.getBroadcastTitle());
Assert.assertNull(source.getCaseNumber());
Assert.assertNull(source.getChapterNumber());
Assert.assertNull(source.getComments());
Assert.assertNull(source.getConferenceName());
Assert.assertNull(source.getCountryOrRegion());
Assert.assertNull(source.getCourt());
Assert.assertNull(source.getDay());
Assert.assertNull(source.getDayAccessed());
Assert.assertNull(source.getDepartment());
Assert.assertNull(source.getDistributor());
Assert.assertNull(source.getDoi());
Assert.assertNull(source.getEdition());
Assert.assertNull(source.getGuid());
Assert.assertNull(source.getInstitution());
Assert.assertNull(source.getInternetSiteTitle());
Assert.assertNull(source.getIssue());
Assert.assertNull(source.getJournalName());
Assert.assertNull(source.getLcid());
Assert.assertNull(source.getMedium());
Assert.assertNull(source.getMonth());
Assert.assertNull(source.getMonthAccessed());
Assert.assertNull(source.getNumberVolumes());
Assert.assertNull(source.getPages());
Assert.assertNull(source.getPatentNumber());
Assert.assertNull(source.getPeriodicalTitle());
Assert.assertNull(source.getProductionCompany());
Assert.assertNull(source.getPublicationTitle());
Assert.assertNull(source.getPublisher());
Assert.assertNull(source.getRecordingNumber());
Assert.assertNull(source.getRefOrder());
Assert.assertNull(source.getReporter());
Assert.assertNull(source.getShortTitle());
Assert.assertNull(source.getStandardNumber());
Assert.assertNull(source.getStateOrProvince());
Assert.assertNull(source.getStation());
Assert.assertEquals("BookNoLCID", source.getTag());
Assert.assertNull(source.getTheater());
Assert.assertNull(source.getThesisType());
Assert.assertNull(source.getType());
Assert.assertNull(source.getUrl());
Assert.assertNull(source.getVersion());
Assert.assertNull(source.getVolume());
Assert.assertNull(source.getYear());
Assert.assertNull(source.getYearAccessed());
// Also, you can create a new source.
Source newSource = new Source("New source", SourceType.MISC);
ContributorCollection contributors = source.getContributors();
Assert.assertNull(contributors.getArtist());
Assert.assertNull(contributors.getBookAuthor());
Assert.assertNull(contributors.getCompiler());
Assert.assertNull(contributors.getComposer());
Assert.assertNull(contributors.getConductor());
Assert.assertNull(contributors.getCounsel());
Assert.assertNull(contributors.getDirector());
Assert.assertNotNull(contributors.getEditor());
Assert.assertNull(contributors.getInterviewee());
Assert.assertNull(contributors.getInterviewer());
Assert.assertNull(contributors.getInventor());
Assert.assertNull(contributors.getPerformer());
Assert.assertNull(contributors.getProducer());
Assert.assertNotNull(contributors.getTranslator());
Assert.assertNull(contributors.getWriter());
Contributor editor = contributors.getEditor();
Assert.assertEquals(2, ((PersonCollection)editor).getCount());
PersonCollection authors = (PersonCollection)contributors.getAuthor();
Assert.assertEquals(2, authors.getCount());
Person person = authors.get(0);
Assert.assertEquals("Roxanne", person.getFirst());
Assert.assertEquals("Brielle", person.getMiddle());
Assert.assertEquals("Tejeda", person.getLast());
| Constructor and Description |
|---|
PersonCollection()
Initialize a new instance of the
PersonCollection class. |
PersonCollection(java.lang.Iterable persons)
Initializes a new instance of this class.
|
PersonCollection(Person... persons)
Initialize a new instance of the
PersonCollection class. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(Person person)
Adds a
Person to the collection. |
void |
clear()
Removes all items from the collection.
|
boolean |
contains(Person person)
Determines whether the collection contains a specific person.
|
Person |
get(int index)
Gets a person at the specified index.
|
int |
getCount()
Gets the number of persons contained in the collection.
|
java.util.Iterator |
iterator() |
boolean |
remove(Person person)
Removes the person from the collection.
|
void |
removeAt(int index)
Removes the person at the specified index.
|
void |
set(int index,
Person value)
Sets a person at the specified index.
|
public PersonCollection()
PersonCollection class.
Examples:
Shows how to work with person collection.
// Create a new person collection.
PersonCollection persons = new PersonCollection();
Person person = new Person("Roxanne", "Brielle", "Tejeda_updated");
// Add new person to the collection.
persons.add(person);
Assert.assertEquals(1, persons.getCount());
// Remove person from the collection if it exists.
if (persons.contains(person))
persons.remove(person);
Assert.assertEquals(0, persons.getCount());
// Create person collection with two persons.
persons = new PersonCollection(new Person[] { new Person("Roxanne_1", "Brielle_1", "Tejeda_1"), new Person("Roxanne_2", "Brielle_2", "Tejeda_2") });
Assert.assertEquals(2, persons.getCount());
// Remove person from the collection by the index.
persons.removeAt(0);
Assert.assertEquals(1, persons.getCount());
// Remove all persons from the collection.
persons.clear();
Assert.assertEquals(0, persons.getCount());
public PersonCollection(java.lang.Iterable persons)
public PersonCollection(Person... persons)
PersonCollection class.
Examples:
Shows how to work with person collection.
// Create a new person collection.
PersonCollection persons = new PersonCollection();
Person person = new Person("Roxanne", "Brielle", "Tejeda_updated");
// Add new person to the collection.
persons.add(person);
Assert.assertEquals(1, persons.getCount());
// Remove person from the collection if it exists.
if (persons.contains(person))
persons.remove(person);
Assert.assertEquals(0, persons.getCount());
// Create person collection with two persons.
persons = new PersonCollection(new Person[] { new Person("Roxanne_1", "Brielle_1", "Tejeda_1"), new Person("Roxanne_2", "Brielle_2", "Tejeda_2") });
Assert.assertEquals(2, persons.getCount());
// Remove person from the collection by the index.
persons.removeAt(0);
Assert.assertEquals(1, persons.getCount());
// Remove all persons from the collection.
persons.clear();
Assert.assertEquals(0, persons.getCount());
public void add(Person person)
Person to the collection.
Examples:
Shows how to work with person collection.
// Create a new person collection.
PersonCollection persons = new PersonCollection();
Person person = new Person("Roxanne", "Brielle", "Tejeda_updated");
// Add new person to the collection.
persons.add(person);
Assert.assertEquals(1, persons.getCount());
// Remove person from the collection if it exists.
if (persons.contains(person))
persons.remove(person);
Assert.assertEquals(0, persons.getCount());
// Create person collection with two persons.
persons = new PersonCollection(new Person[] { new Person("Roxanne_1", "Brielle_1", "Tejeda_1"), new Person("Roxanne_2", "Brielle_2", "Tejeda_2") });
Assert.assertEquals(2, persons.getCount());
// Remove person from the collection by the index.
persons.removeAt(0);
Assert.assertEquals(1, persons.getCount());
// Remove all persons from the collection.
persons.clear();
Assert.assertEquals(0, persons.getCount());
person - The person to add to the collection.public boolean remove(Person person)
Examples:
Shows how to work with person collection.
// Create a new person collection.
PersonCollection persons = new PersonCollection();
Person person = new Person("Roxanne", "Brielle", "Tejeda_updated");
// Add new person to the collection.
persons.add(person);
Assert.assertEquals(1, persons.getCount());
// Remove person from the collection if it exists.
if (persons.contains(person))
persons.remove(person);
Assert.assertEquals(0, persons.getCount());
// Create person collection with two persons.
persons = new PersonCollection(new Person[] { new Person("Roxanne_1", "Brielle_1", "Tejeda_1"), new Person("Roxanne_2", "Brielle_2", "Tejeda_2") });
Assert.assertEquals(2, persons.getCount());
// Remove person from the collection by the index.
persons.removeAt(0);
Assert.assertEquals(1, persons.getCount());
// Remove all persons from the collection.
persons.clear();
Assert.assertEquals(0, persons.getCount());
person - The person to remove from the collection.public void removeAt(int index)
Examples:
Shows how to work with person collection.
// Create a new person collection.
PersonCollection persons = new PersonCollection();
Person person = new Person("Roxanne", "Brielle", "Tejeda_updated");
// Add new person to the collection.
persons.add(person);
Assert.assertEquals(1, persons.getCount());
// Remove person from the collection if it exists.
if (persons.contains(person))
persons.remove(person);
Assert.assertEquals(0, persons.getCount());
// Create person collection with two persons.
persons = new PersonCollection(new Person[] { new Person("Roxanne_1", "Brielle_1", "Tejeda_1"), new Person("Roxanne_2", "Brielle_2", "Tejeda_2") });
Assert.assertEquals(2, persons.getCount());
// Remove person from the collection by the index.
persons.removeAt(0);
Assert.assertEquals(1, persons.getCount());
// Remove all persons from the collection.
persons.clear();
Assert.assertEquals(0, persons.getCount());
index - The zero-based index of the person to remove.public void clear()
Examples:
Shows how to work with person collection.
// Create a new person collection.
PersonCollection persons = new PersonCollection();
Person person = new Person("Roxanne", "Brielle", "Tejeda_updated");
// Add new person to the collection.
persons.add(person);
Assert.assertEquals(1, persons.getCount());
// Remove person from the collection if it exists.
if (persons.contains(person))
persons.remove(person);
Assert.assertEquals(0, persons.getCount());
// Create person collection with two persons.
persons = new PersonCollection(new Person[] { new Person("Roxanne_1", "Brielle_1", "Tejeda_1"), new Person("Roxanne_2", "Brielle_2", "Tejeda_2") });
Assert.assertEquals(2, persons.getCount());
// Remove person from the collection by the index.
persons.removeAt(0);
Assert.assertEquals(1, persons.getCount());
// Remove all persons from the collection.
persons.clear();
Assert.assertEquals(0, persons.getCount());
public boolean contains(Person person)
Examples:
Shows how to work with person collection.
// Create a new person collection.
PersonCollection persons = new PersonCollection();
Person person = new Person("Roxanne", "Brielle", "Tejeda_updated");
// Add new person to the collection.
persons.add(person);
Assert.assertEquals(1, persons.getCount());
// Remove person from the collection if it exists.
if (persons.contains(person))
persons.remove(person);
Assert.assertEquals(0, persons.getCount());
// Create person collection with two persons.
persons = new PersonCollection(new Person[] { new Person("Roxanne_1", "Brielle_1", "Tejeda_1"), new Person("Roxanne_2", "Brielle_2", "Tejeda_2") });
Assert.assertEquals(2, persons.getCount());
// Remove person from the collection by the index.
persons.removeAt(0);
Assert.assertEquals(1, persons.getCount());
// Remove all persons from the collection.
persons.clear();
Assert.assertEquals(0, persons.getCount());
person - The person to locate in the collection.public int getCount()
Examples:
Shows how to get bibliography sources available in the document.
Document document = new Document(getMyDir() + "Bibliography sources.docx");
Bibliography bibliography = document.getBibliography();
Assert.assertEquals(12, bibliography.getSources().size());
// Get default data from bibliography sources.
Collection<Source> sources = bibliography.getSources();
Source source = (Source)sources.toArray()[0];
Assert.assertEquals("Book 0 (No LCID)", source.getTitle());
Assert.assertEquals(SourceType.BOOK, source.getSourceType());
Assert.assertNull(source.getAbbreviatedCaseNumber());
Assert.assertNull(source.getAlbumTitle());
Assert.assertNull(source.getBookTitle());
Assert.assertNull(source.getBroadcaster());
Assert.assertNull(source.getBroadcastTitle());
Assert.assertNull(source.getCaseNumber());
Assert.assertNull(source.getChapterNumber());
Assert.assertNull(source.getComments());
Assert.assertNull(source.getConferenceName());
Assert.assertNull(source.getCountryOrRegion());
Assert.assertNull(source.getCourt());
Assert.assertNull(source.getDay());
Assert.assertNull(source.getDayAccessed());
Assert.assertNull(source.getDepartment());
Assert.assertNull(source.getDistributor());
Assert.assertNull(source.getDoi());
Assert.assertNull(source.getEdition());
Assert.assertNull(source.getGuid());
Assert.assertNull(source.getInstitution());
Assert.assertNull(source.getInternetSiteTitle());
Assert.assertNull(source.getIssue());
Assert.assertNull(source.getJournalName());
Assert.assertNull(source.getLcid());
Assert.assertNull(source.getMedium());
Assert.assertNull(source.getMonth());
Assert.assertNull(source.getMonthAccessed());
Assert.assertNull(source.getNumberVolumes());
Assert.assertNull(source.getPages());
Assert.assertNull(source.getPatentNumber());
Assert.assertNull(source.getPeriodicalTitle());
Assert.assertNull(source.getProductionCompany());
Assert.assertNull(source.getPublicationTitle());
Assert.assertNull(source.getPublisher());
Assert.assertNull(source.getRecordingNumber());
Assert.assertNull(source.getRefOrder());
Assert.assertNull(source.getReporter());
Assert.assertNull(source.getShortTitle());
Assert.assertNull(source.getStandardNumber());
Assert.assertNull(source.getStateOrProvince());
Assert.assertNull(source.getStation());
Assert.assertEquals("BookNoLCID", source.getTag());
Assert.assertNull(source.getTheater());
Assert.assertNull(source.getThesisType());
Assert.assertNull(source.getType());
Assert.assertNull(source.getUrl());
Assert.assertNull(source.getVersion());
Assert.assertNull(source.getVolume());
Assert.assertNull(source.getYear());
Assert.assertNull(source.getYearAccessed());
// Also, you can create a new source.
Source newSource = new Source("New source", SourceType.MISC);
ContributorCollection contributors = source.getContributors();
Assert.assertNull(contributors.getArtist());
Assert.assertNull(contributors.getBookAuthor());
Assert.assertNull(contributors.getCompiler());
Assert.assertNull(contributors.getComposer());
Assert.assertNull(contributors.getConductor());
Assert.assertNull(contributors.getCounsel());
Assert.assertNull(contributors.getDirector());
Assert.assertNotNull(contributors.getEditor());
Assert.assertNull(contributors.getInterviewee());
Assert.assertNull(contributors.getInterviewer());
Assert.assertNull(contributors.getInventor());
Assert.assertNull(contributors.getPerformer());
Assert.assertNull(contributors.getProducer());
Assert.assertNotNull(contributors.getTranslator());
Assert.assertNull(contributors.getWriter());
Contributor editor = contributors.getEditor();
Assert.assertEquals(2, ((PersonCollection)editor).getCount());
PersonCollection authors = (PersonCollection)contributors.getAuthor();
Assert.assertEquals(2, authors.getCount());
Person person = authors.get(0);
Assert.assertEquals("Roxanne", person.getFirst());
Assert.assertEquals("Brielle", person.getMiddle());
Assert.assertEquals("Tejeda", person.getLast());
public Person get(int index)
Examples:
Shows how to get bibliography sources available in the document.
Document document = new Document(getMyDir() + "Bibliography sources.docx");
Bibliography bibliography = document.getBibliography();
Assert.assertEquals(12, bibliography.getSources().size());
// Get default data from bibliography sources.
Collection<Source> sources = bibliography.getSources();
Source source = (Source)sources.toArray()[0];
Assert.assertEquals("Book 0 (No LCID)", source.getTitle());
Assert.assertEquals(SourceType.BOOK, source.getSourceType());
Assert.assertNull(source.getAbbreviatedCaseNumber());
Assert.assertNull(source.getAlbumTitle());
Assert.assertNull(source.getBookTitle());
Assert.assertNull(source.getBroadcaster());
Assert.assertNull(source.getBroadcastTitle());
Assert.assertNull(source.getCaseNumber());
Assert.assertNull(source.getChapterNumber());
Assert.assertNull(source.getComments());
Assert.assertNull(source.getConferenceName());
Assert.assertNull(source.getCountryOrRegion());
Assert.assertNull(source.getCourt());
Assert.assertNull(source.getDay());
Assert.assertNull(source.getDayAccessed());
Assert.assertNull(source.getDepartment());
Assert.assertNull(source.getDistributor());
Assert.assertNull(source.getDoi());
Assert.assertNull(source.getEdition());
Assert.assertNull(source.getGuid());
Assert.assertNull(source.getInstitution());
Assert.assertNull(source.getInternetSiteTitle());
Assert.assertNull(source.getIssue());
Assert.assertNull(source.getJournalName());
Assert.assertNull(source.getLcid());
Assert.assertNull(source.getMedium());
Assert.assertNull(source.getMonth());
Assert.assertNull(source.getMonthAccessed());
Assert.assertNull(source.getNumberVolumes());
Assert.assertNull(source.getPages());
Assert.assertNull(source.getPatentNumber());
Assert.assertNull(source.getPeriodicalTitle());
Assert.assertNull(source.getProductionCompany());
Assert.assertNull(source.getPublicationTitle());
Assert.assertNull(source.getPublisher());
Assert.assertNull(source.getRecordingNumber());
Assert.assertNull(source.getRefOrder());
Assert.assertNull(source.getReporter());
Assert.assertNull(source.getShortTitle());
Assert.assertNull(source.getStandardNumber());
Assert.assertNull(source.getStateOrProvince());
Assert.assertNull(source.getStation());
Assert.assertEquals("BookNoLCID", source.getTag());
Assert.assertNull(source.getTheater());
Assert.assertNull(source.getThesisType());
Assert.assertNull(source.getType());
Assert.assertNull(source.getUrl());
Assert.assertNull(source.getVersion());
Assert.assertNull(source.getVolume());
Assert.assertNull(source.getYear());
Assert.assertNull(source.getYearAccessed());
// Also, you can create a new source.
Source newSource = new Source("New source", SourceType.MISC);
ContributorCollection contributors = source.getContributors();
Assert.assertNull(contributors.getArtist());
Assert.assertNull(contributors.getBookAuthor());
Assert.assertNull(contributors.getCompiler());
Assert.assertNull(contributors.getComposer());
Assert.assertNull(contributors.getConductor());
Assert.assertNull(contributors.getCounsel());
Assert.assertNull(contributors.getDirector());
Assert.assertNotNull(contributors.getEditor());
Assert.assertNull(contributors.getInterviewee());
Assert.assertNull(contributors.getInterviewer());
Assert.assertNull(contributors.getInventor());
Assert.assertNull(contributors.getPerformer());
Assert.assertNull(contributors.getProducer());
Assert.assertNotNull(contributors.getTranslator());
Assert.assertNull(contributors.getWriter());
Contributor editor = contributors.getEditor();
Assert.assertEquals(2, ((PersonCollection)editor).getCount());
PersonCollection authors = (PersonCollection)contributors.getAuthor();
Assert.assertEquals(2, authors.getCount());
Person person = authors.get(0);
Assert.assertEquals("Roxanne", person.getFirst());
Assert.assertEquals("Brielle", person.getMiddle());
Assert.assertEquals("Tejeda", person.getLast());
index - An index into the collection.public void set(int index,
Person value)
Examples:
Shows how to get bibliography sources available in the document.
Document document = new Document(getMyDir() + "Bibliography sources.docx");
Bibliography bibliography = document.getBibliography();
Assert.assertEquals(12, bibliography.getSources().size());
// Get default data from bibliography sources.
Collection<Source> sources = bibliography.getSources();
Source source = (Source)sources.toArray()[0];
Assert.assertEquals("Book 0 (No LCID)", source.getTitle());
Assert.assertEquals(SourceType.BOOK, source.getSourceType());
Assert.assertNull(source.getAbbreviatedCaseNumber());
Assert.assertNull(source.getAlbumTitle());
Assert.assertNull(source.getBookTitle());
Assert.assertNull(source.getBroadcaster());
Assert.assertNull(source.getBroadcastTitle());
Assert.assertNull(source.getCaseNumber());
Assert.assertNull(source.getChapterNumber());
Assert.assertNull(source.getComments());
Assert.assertNull(source.getConferenceName());
Assert.assertNull(source.getCountryOrRegion());
Assert.assertNull(source.getCourt());
Assert.assertNull(source.getDay());
Assert.assertNull(source.getDayAccessed());
Assert.assertNull(source.getDepartment());
Assert.assertNull(source.getDistributor());
Assert.assertNull(source.getDoi());
Assert.assertNull(source.getEdition());
Assert.assertNull(source.getGuid());
Assert.assertNull(source.getInstitution());
Assert.assertNull(source.getInternetSiteTitle());
Assert.assertNull(source.getIssue());
Assert.assertNull(source.getJournalName());
Assert.assertNull(source.getLcid());
Assert.assertNull(source.getMedium());
Assert.assertNull(source.getMonth());
Assert.assertNull(source.getMonthAccessed());
Assert.assertNull(source.getNumberVolumes());
Assert.assertNull(source.getPages());
Assert.assertNull(source.getPatentNumber());
Assert.assertNull(source.getPeriodicalTitle());
Assert.assertNull(source.getProductionCompany());
Assert.assertNull(source.getPublicationTitle());
Assert.assertNull(source.getPublisher());
Assert.assertNull(source.getRecordingNumber());
Assert.assertNull(source.getRefOrder());
Assert.assertNull(source.getReporter());
Assert.assertNull(source.getShortTitle());
Assert.assertNull(source.getStandardNumber());
Assert.assertNull(source.getStateOrProvince());
Assert.assertNull(source.getStation());
Assert.assertEquals("BookNoLCID", source.getTag());
Assert.assertNull(source.getTheater());
Assert.assertNull(source.getThesisType());
Assert.assertNull(source.getType());
Assert.assertNull(source.getUrl());
Assert.assertNull(source.getVersion());
Assert.assertNull(source.getVolume());
Assert.assertNull(source.getYear());
Assert.assertNull(source.getYearAccessed());
// Also, you can create a new source.
Source newSource = new Source("New source", SourceType.MISC);
ContributorCollection contributors = source.getContributors();
Assert.assertNull(contributors.getArtist());
Assert.assertNull(contributors.getBookAuthor());
Assert.assertNull(contributors.getCompiler());
Assert.assertNull(contributors.getComposer());
Assert.assertNull(contributors.getConductor());
Assert.assertNull(contributors.getCounsel());
Assert.assertNull(contributors.getDirector());
Assert.assertNotNull(contributors.getEditor());
Assert.assertNull(contributors.getInterviewee());
Assert.assertNull(contributors.getInterviewer());
Assert.assertNull(contributors.getInventor());
Assert.assertNull(contributors.getPerformer());
Assert.assertNull(contributors.getProducer());
Assert.assertNotNull(contributors.getTranslator());
Assert.assertNull(contributors.getWriter());
Contributor editor = contributors.getEditor();
Assert.assertEquals(2, ((PersonCollection)editor).getCount());
PersonCollection authors = (PersonCollection)contributors.getAuthor();
Assert.assertEquals(2, authors.getCount());
Person person = authors.get(0);
Assert.assertEquals("Roxanne", person.getFirst());
Assert.assertEquals("Brielle", person.getMiddle());
Assert.assertEquals("Tejeda", person.getLast());
index - An index into the collection.value - A person at the specified index.public java.util.Iterator iterator()
iterator in interface java.lang.Iterable