/*
 * NoCoincideExpresionRegularsegunOtroCampoDep.java
 *
 * Created on 24 de marzo de 2007, 07:57 PM
 *
 * 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 Julian
 */
public class NoCoincideExpresionRegularsegunOtroCampoDep extends AbstractRule {

	private Pattern pattern;

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

	public boolean performValidation(String field, String registro[],
			String nombreArchivo) {
		String codigoNovedad = registro[new Integer((String) getParams()[0])
				.intValue()];

		if (codigoNovedad.equals((String) getParams()[1])) {
			if (registro[new Integer((String) getParams()[2]).intValue()]
					.equals(getParams()[3])) {

                            System.out.println("Field: " + field);
				Matcher matcher = pattern.matcher(field);
				return !matcher.find();

		
                        }
                        
		}
                
		return false;
	}

}
