001/* 002 * jPOS Project [http://jpos.org] 003 * Copyright (C) 2000-2026 jPOS Software SRL 004 * 005 * This program is free software: you can redistribute it and/or modify 006 * it under the terms of the GNU Affero General Public License as 007 * published by the Free Software Foundation, either version 3 of the 008 * License, or (at your option) any later version. 009 * 010 * This program is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 * GNU Affero General Public License for more details. 014 * 015 * You should have received a copy of the GNU Affero General Public License 016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 017 */ 018 019package org.jpos.iso; 020 021import org.jpos.core.Configuration; 022import org.jpos.core.ConfigurationException; 023import org.jpos.core.Configurable; 024import org.jpos.util.LogSource; 025import org.jpos.util.Logger; 026 027/** 028 * Base Validator class for jPOS composed ISOComponents (ISOMsg). 029 * <p>Title: jPOS</p> 030 * <p>Description: Java Framework for Financial Systems</p> 031 * <p>Copyright: Copyright (c) 2000 jPOS.org. All rights reserved.</p> 032 * <p>Company: www.jPOS.org</p> 033 * @author Jose Eduardo Leon 034 * @version 1.0 035 */ 036public class ISOBaseValidator implements ISOValidator, LogSource, Configurable { 037 038 public ISOBaseValidator() { 039 super(); 040 } 041 042 /** 043 * Creates the validator. 044 * @param breakOnError flag indicating validation abort condition 045 */ 046 public ISOBaseValidator( boolean breakOnError ) { 047 this.breakOnError = breakOnError; 048 } 049 050 public void setConfiguration(Configuration cfg) throws ConfigurationException { 051 this.cfg = cfg; 052 } 053 054 public boolean breakOnError(){ 055 return breakOnError; 056 } 057 058 public void setBreakOnError( boolean breakOnErr ){ 059 this.breakOnError = breakOnErr; 060 } 061 062 /** 063 * Validate field-interdependency. 064 * @param m Component to validate 065 * @return ISOComponent or ISOVComponent resulting of validation process. 066 * @throws ISOException if break-on-error is true and an error succedd. 067 */ 068 public ISOComponent validate( ISOComponent m ) throws ISOException{ 069 if ( m.getComposite() != m ) 070 throw new ISOException ( "Can't call validate on non Composite" ); 071 return m; 072 } 073 074 public void setLogger( Logger logger, String realm ){ 075 this.logger = logger; 076 this.realm = realm; 077 } 078 079 public Logger getLogger(){ 080 return logger; 081 } 082 083 public String getRealm() { 084 return realm; 085 } 086 087 protected Logger logger = null; 088 protected String realm = null; 089 /** Flag used to indicate if validat process break 090 * on first error or keep an error set **/ 091 protected boolean breakOnError = false; 092 protected Configuration cfg; 093}