public class DropDownItemCollection
Example:
Shows how to insert a combo box field and manipulate the elements in its item collection.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Use a document builder to create and populate a combo box String[] items = {"One", "Two", "Three"}; FormField comboBoxField = builder.insertComboBox("DropDown", items, 0); // Get the list of drop down items DropDownItemCollection dropDownItems = comboBoxField.getDropDownItems(); Assert.assertEquals(dropDownItems.getCount(), 3); Assert.assertEquals(dropDownItems.get(0), "One"); Assert.assertEquals(dropDownItems.indexOf("Two"), 1); Assert.assertTrue(dropDownItems.contains("Three")); // We can add an item to the end of the collection or insert it at a desired index dropDownItems.add("Four"); dropDownItems.insert(3, "Three and a half"); Assert.assertEquals(dropDownItems.getCount(), 5); // Iterate over the collection and print every element Iterator<String> dropDownCollectionEnumerator = dropDownItems.iterator(); try { while (dropDownCollectionEnumerator.hasNext()) { String currentItem = dropDownCollectionEnumerator.next(); System.out.println(currentItem); } } finally { if (dropDownCollectionEnumerator != null) { dropDownCollectionEnumerator.remove(); } } // We can remove elements in the same way we added them dropDownItems.remove("Four"); dropDownItems.removeAt(3); Assert.assertFalse(dropDownItems.contains("Three and a half")); Assert.assertFalse(dropDownItems.contains("Four")); doc.save(getArtifactsDir() + "Fields.DropDownItems.docx");
Property Getters/Setters Summary | ||
---|---|---|
int | getCount() | |
Gets the number of elements contained in the collection.
|
||
java.lang.String | get(int index) | |
void | set(intindex, java.lang.Stringvalue) | |
Gets or sets the element at the specified index. |
Method Summary | ||
---|---|---|
boolean | add(java.lang.String s) | |
Adds a string to the end of the collection.
|
||
void | clear() | |
Removes all elements from the collection.
|
||
boolean | contains(java.lang.String value) | |
Determines whether the collection contains the specified value.
|
||
int | indexOf(java.lang.String value) | |
Returns the zero-based index of the specified value in the collection.
|
||
void | insert(int index, java.lang.String value) | |
Inserts a string into the collection at the specified index.
|
||
java.util.Iterator<java.lang.String> | iterator() | |
Returns an iterator object that can be used to iterate over all items in the collection.
|
||
void | remove(java.lang.String name) | |
Removes the specified value from the collection.
|
||
void | removeAt(int index) | |
Removes a value at the specified index.
|
public int getCount()
Example:
Shows how to insert a combo box field and manipulate the elements in its item collection.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Use a document builder to create and populate a combo box String[] items = {"One", "Two", "Three"}; FormField comboBoxField = builder.insertComboBox("DropDown", items, 0); // Get the list of drop down items DropDownItemCollection dropDownItems = comboBoxField.getDropDownItems(); Assert.assertEquals(dropDownItems.getCount(), 3); Assert.assertEquals(dropDownItems.get(0), "One"); Assert.assertEquals(dropDownItems.indexOf("Two"), 1); Assert.assertTrue(dropDownItems.contains("Three")); // We can add an item to the end of the collection or insert it at a desired index dropDownItems.add("Four"); dropDownItems.insert(3, "Three and a half"); Assert.assertEquals(dropDownItems.getCount(), 5); // Iterate over the collection and print every element Iterator<String> dropDownCollectionEnumerator = dropDownItems.iterator(); try { while (dropDownCollectionEnumerator.hasNext()) { String currentItem = dropDownCollectionEnumerator.next(); System.out.println(currentItem); } } finally { if (dropDownCollectionEnumerator != null) { dropDownCollectionEnumerator.remove(); } } // We can remove elements in the same way we added them dropDownItems.remove("Four"); dropDownItems.removeAt(3); Assert.assertFalse(dropDownItems.contains("Three and a half")); Assert.assertFalse(dropDownItems.contains("Four")); doc.save(getArtifactsDir() + "Fields.DropDownItems.docx");
public java.lang.String get(int index) / public void set(int index, java.lang.String value)
Example:
Shows how to insert a combo box field and manipulate the elements in its item collection.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Use a document builder to create and populate a combo box String[] items = {"One", "Two", "Three"}; FormField comboBoxField = builder.insertComboBox("DropDown", items, 0); // Get the list of drop down items DropDownItemCollection dropDownItems = comboBoxField.getDropDownItems(); Assert.assertEquals(dropDownItems.getCount(), 3); Assert.assertEquals(dropDownItems.get(0), "One"); Assert.assertEquals(dropDownItems.indexOf("Two"), 1); Assert.assertTrue(dropDownItems.contains("Three")); // We can add an item to the end of the collection or insert it at a desired index dropDownItems.add("Four"); dropDownItems.insert(3, "Three and a half"); Assert.assertEquals(dropDownItems.getCount(), 5); // Iterate over the collection and print every element Iterator<String> dropDownCollectionEnumerator = dropDownItems.iterator(); try { while (dropDownCollectionEnumerator.hasNext()) { String currentItem = dropDownCollectionEnumerator.next(); System.out.println(currentItem); } } finally { if (dropDownCollectionEnumerator != null) { dropDownCollectionEnumerator.remove(); } } // We can remove elements in the same way we added them dropDownItems.remove("Four"); dropDownItems.removeAt(3); Assert.assertFalse(dropDownItems.contains("Three and a half")); Assert.assertFalse(dropDownItems.contains("Four")); doc.save(getArtifactsDir() + "Fields.DropDownItems.docx");
public boolean add(java.lang.String s)
value
- The string to add to the end of the collection.Example:
Shows how to insert a combo box field and manipulate the elements in its item collection.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Use a document builder to create and populate a combo box String[] items = {"One", "Two", "Three"}; FormField comboBoxField = builder.insertComboBox("DropDown", items, 0); // Get the list of drop down items DropDownItemCollection dropDownItems = comboBoxField.getDropDownItems(); Assert.assertEquals(dropDownItems.getCount(), 3); Assert.assertEquals(dropDownItems.get(0), "One"); Assert.assertEquals(dropDownItems.indexOf("Two"), 1); Assert.assertTrue(dropDownItems.contains("Three")); // We can add an item to the end of the collection or insert it at a desired index dropDownItems.add("Four"); dropDownItems.insert(3, "Three and a half"); Assert.assertEquals(dropDownItems.getCount(), 5); // Iterate over the collection and print every element Iterator<String> dropDownCollectionEnumerator = dropDownItems.iterator(); try { while (dropDownCollectionEnumerator.hasNext()) { String currentItem = dropDownCollectionEnumerator.next(); System.out.println(currentItem); } } finally { if (dropDownCollectionEnumerator != null) { dropDownCollectionEnumerator.remove(); } } // We can remove elements in the same way we added them dropDownItems.remove("Four"); dropDownItems.removeAt(3); Assert.assertFalse(dropDownItems.contains("Three and a half")); Assert.assertFalse(dropDownItems.contains("Four")); doc.save(getArtifactsDir() + "Fields.DropDownItems.docx");
public void clear()
Example:
Shows how to insert a combo box field and manipulate the elements in its item collection.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Use a document builder to create and populate a combo box String[] items = {"One", "Two", "Three"}; FormField comboBoxField = builder.insertComboBox("DropDown", items, 0); // Get the list of drop down items DropDownItemCollection dropDownItems = comboBoxField.getDropDownItems(); Assert.assertEquals(dropDownItems.getCount(), 3); Assert.assertEquals(dropDownItems.get(0), "One"); Assert.assertEquals(dropDownItems.indexOf("Two"), 1); Assert.assertTrue(dropDownItems.contains("Three")); // We can add an item to the end of the collection or insert it at a desired index dropDownItems.add("Four"); dropDownItems.insert(3, "Three and a half"); Assert.assertEquals(dropDownItems.getCount(), 5); // Iterate over the collection and print every element Iterator<String> dropDownCollectionEnumerator = dropDownItems.iterator(); try { while (dropDownCollectionEnumerator.hasNext()) { String currentItem = dropDownCollectionEnumerator.next(); System.out.println(currentItem); } } finally { if (dropDownCollectionEnumerator != null) { dropDownCollectionEnumerator.remove(); } } // We can remove elements in the same way we added them dropDownItems.remove("Four"); dropDownItems.removeAt(3); Assert.assertFalse(dropDownItems.contains("Three and a half")); Assert.assertFalse(dropDownItems.contains("Four")); doc.save(getArtifactsDir() + "Fields.DropDownItems.docx");
public boolean contains(java.lang.String value)
value
- Case-sensitive value to locate.Example:
Shows how to insert a combo box field and manipulate the elements in its item collection.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Use a document builder to create and populate a combo box String[] items = {"One", "Two", "Three"}; FormField comboBoxField = builder.insertComboBox("DropDown", items, 0); // Get the list of drop down items DropDownItemCollection dropDownItems = comboBoxField.getDropDownItems(); Assert.assertEquals(dropDownItems.getCount(), 3); Assert.assertEquals(dropDownItems.get(0), "One"); Assert.assertEquals(dropDownItems.indexOf("Two"), 1); Assert.assertTrue(dropDownItems.contains("Three")); // We can add an item to the end of the collection or insert it at a desired index dropDownItems.add("Four"); dropDownItems.insert(3, "Three and a half"); Assert.assertEquals(dropDownItems.getCount(), 5); // Iterate over the collection and print every element Iterator<String> dropDownCollectionEnumerator = dropDownItems.iterator(); try { while (dropDownCollectionEnumerator.hasNext()) { String currentItem = dropDownCollectionEnumerator.next(); System.out.println(currentItem); } } finally { if (dropDownCollectionEnumerator != null) { dropDownCollectionEnumerator.remove(); } } // We can remove elements in the same way we added them dropDownItems.remove("Four"); dropDownItems.removeAt(3); Assert.assertFalse(dropDownItems.contains("Three and a half")); Assert.assertFalse(dropDownItems.contains("Four")); doc.save(getArtifactsDir() + "Fields.DropDownItems.docx");
public int indexOf(java.lang.String value)
value
- The case-sensitive value to locate.Example:
Shows how to insert a combo box field and manipulate the elements in its item collection.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Use a document builder to create and populate a combo box String[] items = {"One", "Two", "Three"}; FormField comboBoxField = builder.insertComboBox("DropDown", items, 0); // Get the list of drop down items DropDownItemCollection dropDownItems = comboBoxField.getDropDownItems(); Assert.assertEquals(dropDownItems.getCount(), 3); Assert.assertEquals(dropDownItems.get(0), "One"); Assert.assertEquals(dropDownItems.indexOf("Two"), 1); Assert.assertTrue(dropDownItems.contains("Three")); // We can add an item to the end of the collection or insert it at a desired index dropDownItems.add("Four"); dropDownItems.insert(3, "Three and a half"); Assert.assertEquals(dropDownItems.getCount(), 5); // Iterate over the collection and print every element Iterator<String> dropDownCollectionEnumerator = dropDownItems.iterator(); try { while (dropDownCollectionEnumerator.hasNext()) { String currentItem = dropDownCollectionEnumerator.next(); System.out.println(currentItem); } } finally { if (dropDownCollectionEnumerator != null) { dropDownCollectionEnumerator.remove(); } } // We can remove elements in the same way we added them dropDownItems.remove("Four"); dropDownItems.removeAt(3); Assert.assertFalse(dropDownItems.contains("Three and a half")); Assert.assertFalse(dropDownItems.contains("Four")); doc.save(getArtifactsDir() + "Fields.DropDownItems.docx");
public void insert(int index, java.lang.String value)
index
- The zero-based index at which value is inserted.value
- The string to insert.Example:
Shows how to insert a combo box field and manipulate the elements in its item collection.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Use a document builder to create and populate a combo box String[] items = {"One", "Two", "Three"}; FormField comboBoxField = builder.insertComboBox("DropDown", items, 0); // Get the list of drop down items DropDownItemCollection dropDownItems = comboBoxField.getDropDownItems(); Assert.assertEquals(dropDownItems.getCount(), 3); Assert.assertEquals(dropDownItems.get(0), "One"); Assert.assertEquals(dropDownItems.indexOf("Two"), 1); Assert.assertTrue(dropDownItems.contains("Three")); // We can add an item to the end of the collection or insert it at a desired index dropDownItems.add("Four"); dropDownItems.insert(3, "Three and a half"); Assert.assertEquals(dropDownItems.getCount(), 5); // Iterate over the collection and print every element Iterator<String> dropDownCollectionEnumerator = dropDownItems.iterator(); try { while (dropDownCollectionEnumerator.hasNext()) { String currentItem = dropDownCollectionEnumerator.next(); System.out.println(currentItem); } } finally { if (dropDownCollectionEnumerator != null) { dropDownCollectionEnumerator.remove(); } } // We can remove elements in the same way we added them dropDownItems.remove("Four"); dropDownItems.removeAt(3); Assert.assertFalse(dropDownItems.contains("Three and a half")); Assert.assertFalse(dropDownItems.contains("Four")); doc.save(getArtifactsDir() + "Fields.DropDownItems.docx");
public java.util.Iterator<java.lang.String> iterator()
Example:
Shows how to insert a combo box field and manipulate the elements in its item collection.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Use a document builder to create and populate a combo box String[] items = {"One", "Two", "Three"}; FormField comboBoxField = builder.insertComboBox("DropDown", items, 0); // Get the list of drop down items DropDownItemCollection dropDownItems = comboBoxField.getDropDownItems(); Assert.assertEquals(dropDownItems.getCount(), 3); Assert.assertEquals(dropDownItems.get(0), "One"); Assert.assertEquals(dropDownItems.indexOf("Two"), 1); Assert.assertTrue(dropDownItems.contains("Three")); // We can add an item to the end of the collection or insert it at a desired index dropDownItems.add("Four"); dropDownItems.insert(3, "Three and a half"); Assert.assertEquals(dropDownItems.getCount(), 5); // Iterate over the collection and print every element Iterator<String> dropDownCollectionEnumerator = dropDownItems.iterator(); try { while (dropDownCollectionEnumerator.hasNext()) { String currentItem = dropDownCollectionEnumerator.next(); System.out.println(currentItem); } } finally { if (dropDownCollectionEnumerator != null) { dropDownCollectionEnumerator.remove(); } } // We can remove elements in the same way we added them dropDownItems.remove("Four"); dropDownItems.removeAt(3); Assert.assertFalse(dropDownItems.contains("Three and a half")); Assert.assertFalse(dropDownItems.contains("Four")); doc.save(getArtifactsDir() + "Fields.DropDownItems.docx");
public void remove(java.lang.String name)
name
- The case-sensitive value to remove.Example:
Shows how to insert a combo box field and manipulate the elements in its item collection.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Use a document builder to create and populate a combo box String[] items = {"One", "Two", "Three"}; FormField comboBoxField = builder.insertComboBox("DropDown", items, 0); // Get the list of drop down items DropDownItemCollection dropDownItems = comboBoxField.getDropDownItems(); Assert.assertEquals(dropDownItems.getCount(), 3); Assert.assertEquals(dropDownItems.get(0), "One"); Assert.assertEquals(dropDownItems.indexOf("Two"), 1); Assert.assertTrue(dropDownItems.contains("Three")); // We can add an item to the end of the collection or insert it at a desired index dropDownItems.add("Four"); dropDownItems.insert(3, "Three and a half"); Assert.assertEquals(dropDownItems.getCount(), 5); // Iterate over the collection and print every element Iterator<String> dropDownCollectionEnumerator = dropDownItems.iterator(); try { while (dropDownCollectionEnumerator.hasNext()) { String currentItem = dropDownCollectionEnumerator.next(); System.out.println(currentItem); } } finally { if (dropDownCollectionEnumerator != null) { dropDownCollectionEnumerator.remove(); } } // We can remove elements in the same way we added them dropDownItems.remove("Four"); dropDownItems.removeAt(3); Assert.assertFalse(dropDownItems.contains("Three and a half")); Assert.assertFalse(dropDownItems.contains("Four")); doc.save(getArtifactsDir() + "Fields.DropDownItems.docx");
public void removeAt(int index)
index
- The zero based index.Example:
Shows how to insert a combo box field and manipulate the elements in its item collection.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Use a document builder to create and populate a combo box String[] items = {"One", "Two", "Three"}; FormField comboBoxField = builder.insertComboBox("DropDown", items, 0); // Get the list of drop down items DropDownItemCollection dropDownItems = comboBoxField.getDropDownItems(); Assert.assertEquals(dropDownItems.getCount(), 3); Assert.assertEquals(dropDownItems.get(0), "One"); Assert.assertEquals(dropDownItems.indexOf("Two"), 1); Assert.assertTrue(dropDownItems.contains("Three")); // We can add an item to the end of the collection or insert it at a desired index dropDownItems.add("Four"); dropDownItems.insert(3, "Three and a half"); Assert.assertEquals(dropDownItems.getCount(), 5); // Iterate over the collection and print every element Iterator<String> dropDownCollectionEnumerator = dropDownItems.iterator(); try { while (dropDownCollectionEnumerator.hasNext()) { String currentItem = dropDownCollectionEnumerator.next(); System.out.println(currentItem); } } finally { if (dropDownCollectionEnumerator != null) { dropDownCollectionEnumerator.remove(); } } // We can remove elements in the same way we added them dropDownItems.remove("Four"); dropDownItems.removeAt(3); Assert.assertFalse(dropDownItems.contains("Three and a half")); Assert.assertFalse(dropDownItems.contains("Four")); doc.save(getArtifactsDir() + "Fields.DropDownItems.docx");