// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
package dyndi.params;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.springframework.stereotype.Component;

@Component
public class ParamIFactory implements ParamFactory {
    private static Pattern valueI = Pattern.compile("(\\d+)");
    private Matcher m;
    public void init(String allvalues) {
        m = valueI.matcher(allvalues);
    }
    public boolean isMatch() {
        return m.matches();
    }
    public Param createParam(String name) {
        return new Param1Value<Integer>(name, Integer.parseInt(m.group(1)));
    }
}
