![JAR search and dependency download from the Maven repository](/logo.png)
net.sf.gluebooster.java.booster.basic.container.IteratorByMatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gb-basic Show documentation
Show all versions of gb-basic Show documentation
Basic classes to support the development of applications. There should be as few dependencies on other frameworks as possible.
The newest version!
package net.sf.gluebooster.java.booster.basic.container;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.regex.Matcher;
/**
* Iterates over match results.
*
* @author cbauer
*
*/
public class IteratorByMatcher implements Iterator {
/**
* The input sequence used by the matcher
*/
private String input;
/**
* The matcher
*/
private Matcher matcher;
/**
* The result of the last find invocation.
*/
private Boolean lastFindResult = null;
/**
*
* @param matcher
* @param input
* the matcher must already be reset to the input
*/
public IteratorByMatcher(Matcher matcher, CharSequence input) {
this.input = input.toString();
this.matcher = matcher;
}
@Override
public boolean hasNext() {
if (lastFindResult == null) {
lastFindResult = matcher.find();
}
return lastFindResult;
}
@Override
public Object next() {
if (!hasNext()) {
throw new NoSuchElementException("no next element");
}
return input.substring(matcher.start(), matcher.end());
}
@Override
public void remove() {
throw new UnsupportedOperationException("remove not yet supported");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy