CustomXmlPropertyCollection
Inheritance: java.lang.Object
All Implemented Interfaces: java.lang.Iterable
public class CustomXmlPropertyCollection implements Iterable
Represents a collection of custom XML attributes or smart tag properties.
To learn more, visit the Structured Document Tags or Content Control documentation article.
Remarks:
Items are CustomXmlProperty objects.
Examples:
Shows how to work with smart tag properties to get in depth information about smart tags.
Document doc = new Document(getMyDir() + "Smart tags.doc");
// A smart tag appears in a document with Microsoft Word recognizes a part of its text as some form of data,
// such as a name, date, or address, and converts it to a hyperlink that displays a purple dotted underline.
// In Word 2003, we can enable smart tags via "Tools" -> "AutoCorrect options..." -> "SmartTags".
// In our input document, there are three objects that Microsoft Word registered as smart tags.
// Smart tags may be nested, so this collection contains more.
List smartTags = Arrays.stream(doc.getChildNodes(NodeType.SMART_TAG, true).toArray())
.filter(SmartTag.class::isInstance)
.map(SmartTag.class::cast)
.collect(Collectors.toList());
Assert.assertEquals(8, smartTags.size());
// The "Properties" member of a smart tag contains its metadata, which will be different for each type of smart tag.
// The properties of a "date"-type smart tag contain its year, month, and day.
CustomXmlPropertyCollection properties = smartTags.get(7).getProperties();
Assert.assertEquals(4, properties.getCount());
Iterator enumerator = properties.iterator();
while (enumerator.hasNext()) {
CustomXmlProperty customXmlProperty = enumerator.next();
System.out.println(MessageFormat.format("Property name: {0}, value: {1}", customXmlProperty.getName(), customXmlProperty.getValue()));
Assert.assertEquals("", enumerator.next().getUri());
}
// We can also access the properties in various ways, such as a key-value pair.
Assert.assertTrue(properties.contains("Day"));
Assert.assertEquals("22", properties.get("Day").getValue());
Assert.assertEquals("2003", properties.get(2).getValue());
Assert.assertEquals(1, properties.indexOfKey("Month"));
// Below are three ways of removing elements from the properties collection.
// 1 - Remove by index:
properties.removeAt(3);
Assert.assertEquals(3, properties.getCount());
// 2 - Remove by name:
properties.remove("Year");
Assert.assertEquals(2, properties.getCount());
// 3 - Clear the entire collection at once:
properties.clear();
Assert.assertEquals(0, properties.getCount());
Methods
Method | Description |
---|---|
add(CustomXmlProperty property) | Adds a property to the collection. |
clear() | Removes all elements from the collection. |
contains(String name) | Determines whether the collection contains a property with the given name. |
get(int index) | Gets a property at the specified index. |
get(String name) | Provides access to the collection items. |
getCount() | Gets the number of elements contained in the collection. |
indexOfKey(String name) | Returns the zero-based index of the specified property in the collection. |
iterator() | Returns an iterator object that can be used to iterate over all items in the collection. |
remove(String name) | Removes a property with the specified name from the collection. |
removeAt(int index) | Removes a property at the specified index. |
add(CustomXmlProperty property)
public void add(CustomXmlProperty property)
Adds a property to the collection.
Examples:
Shows how to work with smart tag properties to get in depth information about smart tags.
Document doc = new Document(getMyDir() + "Smart tags.doc");
// A smart tag appears in a document with Microsoft Word recognizes a part of its text as some form of data,
// such as a name, date, or address, and converts it to a hyperlink that displays a purple dotted underline.
// In Word 2003, we can enable smart tags via "Tools" -> "AutoCorrect options..." -> "SmartTags".
// In our input document, there are three objects that Microsoft Word registered as smart tags.
// Smart tags may be nested, so this collection contains more.
List smartTags = Arrays.stream(doc.getChildNodes(NodeType.SMART_TAG, true).toArray())
.filter(SmartTag.class::isInstance)
.map(SmartTag.class::cast)
.collect(Collectors.toList());
Assert.assertEquals(8, smartTags.size());
// The "Properties" member of a smart tag contains its metadata, which will be different for each type of smart tag.
// The properties of a "date"-type smart tag contain its year, month, and day.
CustomXmlPropertyCollection properties = smartTags.get(7).getProperties();
Assert.assertEquals(4, properties.getCount());
Iterator enumerator = properties.iterator();
while (enumerator.hasNext()) {
CustomXmlProperty customXmlProperty = enumerator.next();
System.out.println(MessageFormat.format("Property name: {0}, value: {1}", customXmlProperty.getName(), customXmlProperty.getValue()));
Assert.assertEquals("", enumerator.next().getUri());
}
// We can also access the properties in various ways, such as a key-value pair.
Assert.assertTrue(properties.contains("Day"));
Assert.assertEquals("22", properties.get("Day").getValue());
Assert.assertEquals("2003", properties.get(2).getValue());
Assert.assertEquals(1, properties.indexOfKey("Month"));
// Below are three ways of removing elements from the properties collection.
// 1 - Remove by index:
properties.removeAt(3);
Assert.assertEquals(3, properties.getCount());
// 2 - Remove by name:
properties.remove("Year");
Assert.assertEquals(2, properties.getCount());
// 3 - Clear the entire collection at once:
properties.clear();
Assert.assertEquals(0, properties.getCount());
Parameters:
Parameter | Type | Description |
---|---|---|
property | CustomXmlProperty | The property to add. |
clear()
public void clear()
Removes all elements from the collection.
Examples:
Shows how to work with smart tag properties to get in depth information about smart tags.
Document doc = new Document(getMyDir() + "Smart tags.doc");
// A smart tag appears in a document with Microsoft Word recognizes a part of its text as some form of data,
// such as a name, date, or address, and converts it to a hyperlink that displays a purple dotted underline.
// In Word 2003, we can enable smart tags via "Tools" -> "AutoCorrect options..." -> "SmartTags".
// In our input document, there are three objects that Microsoft Word registered as smart tags.
// Smart tags may be nested, so this collection contains more.
List smartTags = Arrays.stream(doc.getChildNodes(NodeType.SMART_TAG, true).toArray())
.filter(SmartTag.class::isInstance)
.map(SmartTag.class::cast)
.collect(Collectors.toList());
Assert.assertEquals(8, smartTags.size());
// The "Properties" member of a smart tag contains its metadata, which will be different for each type of smart tag.
// The properties of a "date"-type smart tag contain its year, month, and day.
CustomXmlPropertyCollection properties = smartTags.get(7).getProperties();
Assert.assertEquals(4, properties.getCount());
Iterator enumerator = properties.iterator();
while (enumerator.hasNext()) {
CustomXmlProperty customXmlProperty = enumerator.next();
System.out.println(MessageFormat.format("Property name: {0}, value: {1}", customXmlProperty.getName(), customXmlProperty.getValue()));
Assert.assertEquals("", enumerator.next().getUri());
}
// We can also access the properties in various ways, such as a key-value pair.
Assert.assertTrue(properties.contains("Day"));
Assert.assertEquals("22", properties.get("Day").getValue());
Assert.assertEquals("2003", properties.get(2).getValue());
Assert.assertEquals(1, properties.indexOfKey("Month"));
// Below are three ways of removing elements from the properties collection.
// 1 - Remove by index:
properties.removeAt(3);
Assert.assertEquals(3, properties.getCount());
// 2 - Remove by name:
properties.remove("Year");
Assert.assertEquals(2, properties.getCount());
// 3 - Clear the entire collection at once:
properties.clear();
Assert.assertEquals(0, properties.getCount());
contains(String name)
public boolean contains(String name)
Determines whether the collection contains a property with the given name.
Examples:
Shows how to work with smart tag properties to get in depth information about smart tags.
Document doc = new Document(getMyDir() + "Smart tags.doc");
// A smart tag appears in a document with Microsoft Word recognizes a part of its text as some form of data,
// such as a name, date, or address, and converts it to a hyperlink that displays a purple dotted underline.
// In Word 2003, we can enable smart tags via "Tools" -> "AutoCorrect options..." -> "SmartTags".
// In our input document, there are three objects that Microsoft Word registered as smart tags.
// Smart tags may be nested, so this collection contains more.
List smartTags = Arrays.stream(doc.getChildNodes(NodeType.SMART_TAG, true).toArray())
.filter(SmartTag.class::isInstance)
.map(SmartTag.class::cast)
.collect(Collectors.toList());
Assert.assertEquals(8, smartTags.size());
// The "Properties" member of a smart tag contains its metadata, which will be different for each type of smart tag.
// The properties of a "date"-type smart tag contain its year, month, and day.
CustomXmlPropertyCollection properties = smartTags.get(7).getProperties();
Assert.assertEquals(4, properties.getCount());
Iterator enumerator = properties.iterator();
while (enumerator.hasNext()) {
CustomXmlProperty customXmlProperty = enumerator.next();
System.out.println(MessageFormat.format("Property name: {0}, value: {1}", customXmlProperty.getName(), customXmlProperty.getValue()));
Assert.assertEquals("", enumerator.next().getUri());
}
// We can also access the properties in various ways, such as a key-value pair.
Assert.assertTrue(properties.contains("Day"));
Assert.assertEquals("22", properties.get("Day").getValue());
Assert.assertEquals("2003", properties.get(2).getValue());
Assert.assertEquals(1, properties.indexOfKey("Month"));
// Below are three ways of removing elements from the properties collection.
// 1 - Remove by index:
properties.removeAt(3);
Assert.assertEquals(3, properties.getCount());
// 2 - Remove by name:
properties.remove("Year");
Assert.assertEquals(2, properties.getCount());
// 3 - Clear the entire collection at once:
properties.clear();
Assert.assertEquals(0, properties.getCount());
Parameters:
Parameter | Type | Description |
---|---|---|
name | java.lang.String | Case-sensitive name of the property to locate. |
Returns: boolean - true if the item is found in the collection; otherwise, false .
get(int index)
public CustomXmlProperty get(int index)
Gets a property at the specified index.
Examples:
Shows how to work with smart tag properties to get in depth information about smart tags.
Document doc = new Document(getMyDir() + "Smart tags.doc");
// A smart tag appears in a document with Microsoft Word recognizes a part of its text as some form of data,
// such as a name, date, or address, and converts it to a hyperlink that displays a purple dotted underline.
// In Word 2003, we can enable smart tags via "Tools" -> "AutoCorrect options..." -> "SmartTags".
// In our input document, there are three objects that Microsoft Word registered as smart tags.
// Smart tags may be nested, so this collection contains more.
List smartTags = Arrays.stream(doc.getChildNodes(NodeType.SMART_TAG, true).toArray())
.filter(SmartTag.class::isInstance)
.map(SmartTag.class::cast)
.collect(Collectors.toList());
Assert.assertEquals(8, smartTags.size());
// The "Properties" member of a smart tag contains its metadata, which will be different for each type of smart tag.
// The properties of a "date"-type smart tag contain its year, month, and day.
CustomXmlPropertyCollection properties = smartTags.get(7).getProperties();
Assert.assertEquals(4, properties.getCount());
Iterator enumerator = properties.iterator();
while (enumerator.hasNext()) {
CustomXmlProperty customXmlProperty = enumerator.next();
System.out.println(MessageFormat.format("Property name: {0}, value: {1}", customXmlProperty.getName(), customXmlProperty.getValue()));
Assert.assertEquals("", enumerator.next().getUri());
}
// We can also access the properties in various ways, such as a key-value pair.
Assert.assertTrue(properties.contains("Day"));
Assert.assertEquals("22", properties.get("Day").getValue());
Assert.assertEquals("2003", properties.get(2).getValue());
Assert.assertEquals(1, properties.indexOfKey("Month"));
// Below are three ways of removing elements from the properties collection.
// 1 - Remove by index:
properties.removeAt(3);
Assert.assertEquals(3, properties.getCount());
// 2 - Remove by name:
properties.remove("Year");
Assert.assertEquals(2, properties.getCount());
// 3 - Clear the entire collection at once:
properties.clear();
Assert.assertEquals(0, properties.getCount());
Parameters:
Parameter | Type | Description |
---|---|---|
index | int | Zero-based index of the property. |
Returns: CustomXmlProperty - A property at the specified index.
get(String name)
public CustomXmlProperty get(String name)
Provides access to the collection items. Gets a property with the specified name.
Examples:
Shows how to work with smart tag properties to get in depth information about smart tags.
Document doc = new Document(getMyDir() + "Smart tags.doc");
// A smart tag appears in a document with Microsoft Word recognizes a part of its text as some form of data,
// such as a name, date, or address, and converts it to a hyperlink that displays a purple dotted underline.
// In Word 2003, we can enable smart tags via "Tools" -> "AutoCorrect options..." -> "SmartTags".
// In our input document, there are three objects that Microsoft Word registered as smart tags.
// Smart tags may be nested, so this collection contains more.
List smartTags = Arrays.stream(doc.getChildNodes(NodeType.SMART_TAG, true).toArray())
.filter(SmartTag.class::isInstance)
.map(SmartTag.class::cast)
.collect(Collectors.toList());
Assert.assertEquals(8, smartTags.size());
// The "Properties" member of a smart tag contains its metadata, which will be different for each type of smart tag.
// The properties of a "date"-type smart tag contain its year, month, and day.
CustomXmlPropertyCollection properties = smartTags.get(7).getProperties();
Assert.assertEquals(4, properties.getCount());
Iterator enumerator = properties.iterator();
while (enumerator.hasNext()) {
CustomXmlProperty customXmlProperty = enumerator.next();
System.out.println(MessageFormat.format("Property name: {0}, value: {1}", customXmlProperty.getName(), customXmlProperty.getValue()));
Assert.assertEquals("", enumerator.next().getUri());
}
// We can also access the properties in various ways, such as a key-value pair.
Assert.assertTrue(properties.contains("Day"));
Assert.assertEquals("22", properties.get("Day").getValue());
Assert.assertEquals("2003", properties.get(2).getValue());
Assert.assertEquals(1, properties.indexOfKey("Month"));
// Below are three ways of removing elements from the properties collection.
// 1 - Remove by index:
properties.removeAt(3);
Assert.assertEquals(3, properties.getCount());
// 2 - Remove by name:
properties.remove("Year");
Assert.assertEquals(2, properties.getCount());
// 3 - Clear the entire collection at once:
properties.clear();
Assert.assertEquals(0, properties.getCount());
Parameters:
Parameter | Type | Description |
---|---|---|
name | java.lang.String | Case-sensitive name of the property to locate. |
Returns: CustomXmlProperty - The corresponding CustomXmlProperty value.
getCount()
public int getCount()
Gets the number of elements contained in the collection.
Examples:
Shows how to work with smart tag properties to get in depth information about smart tags.
Document doc = new Document(getMyDir() + "Smart tags.doc");
// A smart tag appears in a document with Microsoft Word recognizes a part of its text as some form of data,
// such as a name, date, or address, and converts it to a hyperlink that displays a purple dotted underline.
// In Word 2003, we can enable smart tags via "Tools" -> "AutoCorrect options..." -> "SmartTags".
// In our input document, there are three objects that Microsoft Word registered as smart tags.
// Smart tags may be nested, so this collection contains more.
List smartTags = Arrays.stream(doc.getChildNodes(NodeType.SMART_TAG, true).toArray())
.filter(SmartTag.class::isInstance)
.map(SmartTag.class::cast)
.collect(Collectors.toList());
Assert.assertEquals(8, smartTags.size());
// The "Properties" member of a smart tag contains its metadata, which will be different for each type of smart tag.
// The properties of a "date"-type smart tag contain its year, month, and day.
CustomXmlPropertyCollection properties = smartTags.get(7).getProperties();
Assert.assertEquals(4, properties.getCount());
Iterator enumerator = properties.iterator();
while (enumerator.hasNext()) {
CustomXmlProperty customXmlProperty = enumerator.next();
System.out.println(MessageFormat.format("Property name: {0}, value: {1}", customXmlProperty.getName(), customXmlProperty.getValue()));
Assert.assertEquals("", enumerator.next().getUri());
}
// We can also access the properties in various ways, such as a key-value pair.
Assert.assertTrue(properties.contains("Day"));
Assert.assertEquals("22", properties.get("Day").getValue());
Assert.assertEquals("2003", properties.get(2).getValue());
Assert.assertEquals(1, properties.indexOfKey("Month"));
// Below are three ways of removing elements from the properties collection.
// 1 - Remove by index:
properties.removeAt(3);
Assert.assertEquals(3, properties.getCount());
// 2 - Remove by name:
properties.remove("Year");
Assert.assertEquals(2, properties.getCount());
// 3 - Clear the entire collection at once:
properties.clear();
Assert.assertEquals(0, properties.getCount());
Returns: int - The number of elements contained in the collection.
indexOfKey(String name)
public int indexOfKey(String name)
Returns the zero-based index of the specified property in the collection.
Examples:
Shows how to work with smart tag properties to get in depth information about smart tags.
Document doc = new Document(getMyDir() + "Smart tags.doc");
// A smart tag appears in a document with Microsoft Word recognizes a part of its text as some form of data,
// such as a name, date, or address, and converts it to a hyperlink that displays a purple dotted underline.
// In Word 2003, we can enable smart tags via "Tools" -> "AutoCorrect options..." -> "SmartTags".
// In our input document, there are three objects that Microsoft Word registered as smart tags.
// Smart tags may be nested, so this collection contains more.
List smartTags = Arrays.stream(doc.getChildNodes(NodeType.SMART_TAG, true).toArray())
.filter(SmartTag.class::isInstance)
.map(SmartTag.class::cast)
.collect(Collectors.toList());
Assert.assertEquals(8, smartTags.size());
// The "Properties" member of a smart tag contains its metadata, which will be different for each type of smart tag.
// The properties of a "date"-type smart tag contain its year, month, and day.
CustomXmlPropertyCollection properties = smartTags.get(7).getProperties();
Assert.assertEquals(4, properties.getCount());
Iterator enumerator = properties.iterator();
while (enumerator.hasNext()) {
CustomXmlProperty customXmlProperty = enumerator.next();
System.out.println(MessageFormat.format("Property name: {0}, value: {1}", customXmlProperty.getName(), customXmlProperty.getValue()));
Assert.assertEquals("", enumerator.next().getUri());
}
// We can also access the properties in various ways, such as a key-value pair.
Assert.assertTrue(properties.contains("Day"));
Assert.assertEquals("22", properties.get("Day").getValue());
Assert.assertEquals("2003", properties.get(2).getValue());
Assert.assertEquals(1, properties.indexOfKey("Month"));
// Below are three ways of removing elements from the properties collection.
// 1 - Remove by index:
properties.removeAt(3);
Assert.assertEquals(3, properties.getCount());
// 2 - Remove by name:
properties.remove("Year");
Assert.assertEquals(2, properties.getCount());
// 3 - Clear the entire collection at once:
properties.clear();
Assert.assertEquals(0, properties.getCount());
Parameters:
Parameter | Type | Description |
---|---|---|
name | java.lang.String | The case-sensitive name of the property. |
Returns: int - The zero based index. Negative value if not found.
iterator()
public Iterator iterator()
Returns an iterator object that can be used to iterate over all items in the collection.
Examples:
Shows how to work with smart tag properties to get in depth information about smart tags.
Document doc = new Document(getMyDir() + "Smart tags.doc");
// A smart tag appears in a document with Microsoft Word recognizes a part of its text as some form of data,
// such as a name, date, or address, and converts it to a hyperlink that displays a purple dotted underline.
// In Word 2003, we can enable smart tags via "Tools" -> "AutoCorrect options..." -> "SmartTags".
// In our input document, there are three objects that Microsoft Word registered as smart tags.
// Smart tags may be nested, so this collection contains more.
List smartTags = Arrays.stream(doc.getChildNodes(NodeType.SMART_TAG, true).toArray())
.filter(SmartTag.class::isInstance)
.map(SmartTag.class::cast)
.collect(Collectors.toList());
Assert.assertEquals(8, smartTags.size());
// The "Properties" member of a smart tag contains its metadata, which will be different for each type of smart tag.
// The properties of a "date"-type smart tag contain its year, month, and day.
CustomXmlPropertyCollection properties = smartTags.get(7).getProperties();
Assert.assertEquals(4, properties.getCount());
Iterator enumerator = properties.iterator();
while (enumerator.hasNext()) {
CustomXmlProperty customXmlProperty = enumerator.next();
System.out.println(MessageFormat.format("Property name: {0}, value: {1}", customXmlProperty.getName(), customXmlProperty.getValue()));
Assert.assertEquals("", enumerator.next().getUri());
}
// We can also access the properties in various ways, such as a key-value pair.
Assert.assertTrue(properties.contains("Day"));
Assert.assertEquals("22", properties.get("Day").getValue());
Assert.assertEquals("2003", properties.get(2).getValue());
Assert.assertEquals(1, properties.indexOfKey("Month"));
// Below are three ways of removing elements from the properties collection.
// 1 - Remove by index:
properties.removeAt(3);
Assert.assertEquals(3, properties.getCount());
// 2 - Remove by name:
properties.remove("Year");
Assert.assertEquals(2, properties.getCount());
// 3 - Clear the entire collection at once:
properties.clear();
Assert.assertEquals(0, properties.getCount());
Returns: java.util.Iterator
remove(String name)
public void remove(String name)
Removes a property with the specified name from the collection.
Examples:
Shows how to work with smart tag properties to get in depth information about smart tags.
Document doc = new Document(getMyDir() + "Smart tags.doc");
// A smart tag appears in a document with Microsoft Word recognizes a part of its text as some form of data,
// such as a name, date, or address, and converts it to a hyperlink that displays a purple dotted underline.
// In Word 2003, we can enable smart tags via "Tools" -> "AutoCorrect options..." -> "SmartTags".
// In our input document, there are three objects that Microsoft Word registered as smart tags.
// Smart tags may be nested, so this collection contains more.
List smartTags = Arrays.stream(doc.getChildNodes(NodeType.SMART_TAG, true).toArray())
.filter(SmartTag.class::isInstance)
.map(SmartTag.class::cast)
.collect(Collectors.toList());
Assert.assertEquals(8, smartTags.size());
// The "Properties" member of a smart tag contains its metadata, which will be different for each type of smart tag.
// The properties of a "date"-type smart tag contain its year, month, and day.
CustomXmlPropertyCollection properties = smartTags.get(7).getProperties();
Assert.assertEquals(4, properties.getCount());
Iterator enumerator = properties.iterator();
while (enumerator.hasNext()) {
CustomXmlProperty customXmlProperty = enumerator.next();
System.out.println(MessageFormat.format("Property name: {0}, value: {1}", customXmlProperty.getName(), customXmlProperty.getValue()));
Assert.assertEquals("", enumerator.next().getUri());
}
// We can also access the properties in various ways, such as a key-value pair.
Assert.assertTrue(properties.contains("Day"));
Assert.assertEquals("22", properties.get("Day").getValue());
Assert.assertEquals("2003", properties.get(2).getValue());
Assert.assertEquals(1, properties.indexOfKey("Month"));
// Below are three ways of removing elements from the properties collection.
// 1 - Remove by index:
properties.removeAt(3);
Assert.assertEquals(3, properties.getCount());
// 2 - Remove by name:
properties.remove("Year");
Assert.assertEquals(2, properties.getCount());
// 3 - Clear the entire collection at once:
properties.clear();
Assert.assertEquals(0, properties.getCount());
Parameters:
Parameter | Type | Description |
---|---|---|
name | java.lang.String | The case-sensitive name of the property. |
removeAt(int index)
public void removeAt(int index)
Removes a property at the specified index.
Examples:
Shows how to work with smart tag properties to get in depth information about smart tags.
Document doc = new Document(getMyDir() + "Smart tags.doc");
// A smart tag appears in a document with Microsoft Word recognizes a part of its text as some form of data,
// such as a name, date, or address, and converts it to a hyperlink that displays a purple dotted underline.
// In Word 2003, we can enable smart tags via "Tools" -> "AutoCorrect options..." -> "SmartTags".
// In our input document, there are three objects that Microsoft Word registered as smart tags.
// Smart tags may be nested, so this collection contains more.
List smartTags = Arrays.stream(doc.getChildNodes(NodeType.SMART_TAG, true).toArray())
.filter(SmartTag.class::isInstance)
.map(SmartTag.class::cast)
.collect(Collectors.toList());
Assert.assertEquals(8, smartTags.size());
// The "Properties" member of a smart tag contains its metadata, which will be different for each type of smart tag.
// The properties of a "date"-type smart tag contain its year, month, and day.
CustomXmlPropertyCollection properties = smartTags.get(7).getProperties();
Assert.assertEquals(4, properties.getCount());
Iterator enumerator = properties.iterator();
while (enumerator.hasNext()) {
CustomXmlProperty customXmlProperty = enumerator.next();
System.out.println(MessageFormat.format("Property name: {0}, value: {1}", customXmlProperty.getName(), customXmlProperty.getValue()));
Assert.assertEquals("", enumerator.next().getUri());
}
// We can also access the properties in various ways, such as a key-value pair.
Assert.assertTrue(properties.contains("Day"));
Assert.assertEquals("22", properties.get("Day").getValue());
Assert.assertEquals("2003", properties.get(2).getValue());
Assert.assertEquals(1, properties.indexOfKey("Month"));
// Below are three ways of removing elements from the properties collection.
// 1 - Remove by index:
properties.removeAt(3);
Assert.assertEquals(3, properties.getCount());
// 2 - Remove by name:
properties.remove("Year");
Assert.assertEquals(2, properties.getCount());
// 3 - Clear the entire collection at once:
properties.clear();
Assert.assertEquals(0, properties.getCount());
Parameters:
Parameter | Type | Description |
---|---|---|
index | int | The zero based index. |