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.iso.validator.ISOVException; 022 023/** 024 * Validator for ASCII numeric and no-zero filled fields. 025 * <p>Title: jPOS</p> 026 * <p>Description: Java Framework for Financial Systems</p> 027 * <p>Copyright: Copyright (c) 2000 jPOS.org. All rights reserved.</p> 028 * <p>Company: www.jPOS.org</p> 029 * @author Jose Eduardo Leon 030 * @version 1.0 031 */ 032public class IVA_NUMNOZERO extends IVA_NUM { 033 034 public IVA_NUMNOZERO( ) { 035 super(); 036 } 037 038 public IVA_NUMNOZERO( int minLen, int maxLen, String Description, int radix ) { 039 super( minLen, maxLen, Description, radix ); 040 } 041 042 public IVA_NUMNOZERO( int minLen, int maxLen, String Description ) { 043 super( minLen, maxLen, Description ); 044 } 045 046 public IVA_NUMNOZERO( int minLen, String Description, int radix ) { 047 super( minLen, Description, radix ); 048 } 049 050 public IVA_NUMNOZERO( int maxLen, String Description ) { 051 super( maxLen, Description ); 052 } 053 054 public IVA_NUMNOZERO( String Description, int radix ) { 055 super( Description, radix ); 056 } 057 058 public IVA_NUMNOZERO( String Description ) { 059 super( Description ); 060 } 061 062 public IVA_NUMNOZERO( boolean breakOnError, String Description ) { 063 this( Description ); 064 this.breakOnError = breakOnError; 065 } 066 067 public IVA_NUMNOZERO( boolean breakOnError, String Description, int radix ) { 068 this( Description, radix ); 069 this.breakOnError = breakOnError; 070 } 071 072 public IVA_NUMNOZERO( boolean breakOnError, int maxLen, String Description ) { 073 this( maxLen, Description ); 074 this.breakOnError = breakOnError; 075 } 076 077 public IVA_NUMNOZERO( boolean breakOnError, int maxLen, String Description, int radix ) { 078 this( maxLen, Description, radix ); 079 this.breakOnError = breakOnError; 080 } 081 082 public IVA_NUMNOZERO( boolean breakOnError, int minLen, int maxLen, String Description ) { 083 this( minLen, maxLen, Description ); 084 this.breakOnError = breakOnError; 085 } 086 087 public IVA_NUMNOZERO( boolean breakOnError, int minLen, int maxLen, String Description, int radix ) { 088 this( minLen, maxLen, Description, radix ); 089 this.breakOnError = breakOnError; 090 } 091 092 093 /** 094 * Validate that component is not zero-filled. 095 */ 096 public ISOComponent validate ( ISOComponent f ) throws ISOException { 097 ISOField c = (ISOField)f; 098 try { 099 /** numeric **/ 100 c = (ISOField)super.validate( c ); 101 /** positive **/ 102 if (ISOUtil.isZero( (String)c.getValue() ) ){ 103 ISOVError e = new ISOVError( 104 "Invalid Value Error. It can not be zero-filled. (Current value: " + 105 c.getValue() + ") ", 106 getRejCode( ISOVError.ERR_INVALID_VALUE ) ); 107 if ( c instanceof ISOVField ) 108 ((ISOVField)c).addISOVError( e ); 109 else 110 c = new ISOVField( c, e ); 111 if ( breakOnError ) 112 throw new ISOVException ( "Error on field " + c.getKey(), c ); 113 } 114 return c; 115 } 116 catch (Exception ex) { 117 /** This catch is useful in case of error-dependencies. If 118 an error take place in super, and it imply second in child. **/ 119 if ( ex instanceof ISOVException ) throw (ISOVException)ex; 120 return c; 121 } 122 } 123}