/*
 * CaracterLongitudInicioFinIncorrecta.java
 *
 * Created on 24 de junio de 2005, 12:48 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

/*
 * AlfanumericoLongitudCaracteresEspEspacionInicioFinIncorrecta.java
 *
 * Created on 21 de marzo de 2007, 12:06 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.fidufosyga.rules;

/**
 * 
 * @author Julian
 */
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CaracterLongitudInicioFinIncorrecta extends AbstractRule {

	private final Pattern pattern;

	public CaracterLongitudInicioFinIncorrecta() {
		String patternStr = "[^A-Z/\\s@Ñ]";
		pattern = Pattern.compile(patternStr);

	}

        @Override
	public boolean performValidation(String field, String registro[],String nombreArchivo) {
            if (field.length() < new Integer((String) getParams()[0]).intValue()|| field.length() > new Integer((String) getParams()[1]).intValue())
                return true;
            if (field.trim().length() != field.length())
                return true;
            Matcher matcher = pattern.matcher(field);
            return matcher.find();

	}

}
