| Code with Finding: |
class Document {
/**
* <p>Removes all fields with the given name from the document.
* If there is no field with the specified name, the document remains unchanged.</p>
* <p> Note that the removeField(s) methods like the add method only make sense
* prior to adding a document to an index. These methods cannot
* be used to change the content of an existing index! In order to achieve this,
* a document has to be deleted from an index and a new changed version of that
* document has to be added.</p>
*/
public final void removeFields(String name) {
Iterator it = fields.iterator();
while (it.hasNext()) {
Fieldable field = (Fieldable)it.next();
if (field.name().equals(name)) {
it.remove();
}
}
}
}
|