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

package com.fidufosyga.rules;

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

/**
 * 
 * @author 
 */
public class NoCoincideExpresionRegularNegandoOtroCampo extends AbstractRule {

	private Pattern pattern;

	public void setParams(Object[] params) {
		String patternStr = (String) params[2];
		pattern = Pattern.compile(patternStr);
		super.setParams(params);
	}

	public boolean performValidation(String field, String registro[],
			String nombreArchivo) {

		if(field.length() == 0)
		{
			field = " ";			
		}
		
		//System.out.println("Compara: " + registro[new Integer((String) getParams()[0]).intValue()]);
		//System.out.println("Con: " + getParams()[1]);
		
		
		if (!registro[new Integer((String) getParams()[0]).intValue()]
				.equals(getParams()[1])) {
		
			Matcher matcher = pattern.matcher(field);
 			//System.out.println("2 Matcher: " + pattern.matcher(field) + "Campo: " + field + " Resultado Evaluacion: " + matcher.find());

 			return !matcher.matches();

		}

		return false;
	}

}
