fr.vergne.parsing.samples.xml.layer.Fields Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of parsing-samples Show documentation
Show all versions of parsing-samples Show documentation
Examples of uses of the parsing features.
package fr.vergne.parsing.samples.xml.layer;
import java.util.NoSuchElementException;
import fr.vergne.parsing.layer.impl.Loop;
public class Fields extends Loop {
public Fields() {
super(new Generator() {
@Override
public Field generates() {
return new Field();
}
});
}
public Field getField(String name) {
for (Field field : this) {
if (field.getName().getContent().equals(name)) {
return field;
} else {
// continue searching
}
}
throw new NoSuchElementException("No " + name
+ " field has been found.");
}
}