📄 isobasevalidatingpackager.java
字号:
/* * jPOS Project [http://jpos.org] * Copyright (C) 2000-2008 Alejandro P. Revilla * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */package org.jpos.iso.packager;import java.util.Hashtable;import org.jpos.iso.ISOBasePackager;import org.jpos.iso.ISOBaseValidator;import org.jpos.iso.ISOComponent;import org.jpos.iso.ISOException;import org.jpos.iso.ISOFieldValidator;import org.jpos.iso.ISOMsg;import org.jpos.iso.ISOValidator;import org.jpos.iso.validator.ISOVException;import org.jpos.util.LogEvent;import org.jpos.util.Logger;/** * Base Packager class envolving validators. It implements * ISOValidator interface and define an implementation for validate method. * Validation is for composed components. * <p>Title: jPOS</p> * <p>Description: Java Framework for Financial Systems</p> * <p>Copyright: Copyright (c) 2000 jPOS.org. All rights reserved.</p> * <p>Company: www.jPOS.org</p> * @author Jose Eduardo Leon * @version 1.0 */public class ISOBaseValidatingPackager extends ISOBasePackager implements ISOValidator { public ISOBaseValidatingPackager() { super(); } public ISOComponent validate(ISOComponent m) throws ISOException { LogEvent evt = new LogEvent( this, "validate" ); try { ISOComponent c; Hashtable fields = ((ISOMsg)m).getChildren(); /** Field validations **/ for (int i=0; i<fldVld.length; i++) { if ( fldVld[i] != null && (c=(ISOComponent) fields.get (new Integer ( ((ISOFieldValidator)fldVld[i]).getFieldId() ))) != null ){ try { m.set( fldVld[i].validate( c ) ); } catch ( ISOVException e ) { if ( !e.treated() ) { m.set( e.getErrComponent() ); e.setTreated( true ); } evt.addMessage( "Component Validation Error." ); throw e; } } } /** msg validations **/ try { if ( msgVld != null ){ for (int i = 0; i < this.msgVld.length; i++) { if ( msgVld[i] != null ) m = msgVld[i].validate( m ); } } } catch (ISOVException ex) { evt.addMessage( "Component Validation Error." ); throw ex; } return m; } finally { Logger.log( evt ); } }// public void setFieldValidator( ISOFieldValidator[] fvlds ){// this.fldVld = fvlds;// } public void setFieldValidator( ISOValidator[] fvlds ){ this.fldVld = fvlds; } public void setMsgValidator( ISOBaseValidator[] msgVlds ){ this.msgVld = msgVlds; } /** Message level validators **/ protected ISOBaseValidator[] msgVld; /** field validator array. **/// protected ISOFieldValidator[] fldVld; protected ISOValidator[] fldVld;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -