org.jdtaus.iso13616.IbanSyntaxException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ISO-13616 Show documentation
Show all versions of ISO-13616 Show documentation
ISO 13616-1:2007 specifies the elements of an international bank account
number (IBAN) used to facilitate the processing of data internationally
in data interchange, in financial environments as well as within and
between other industries. The IBAN is designed for automated processing,
but can also be used conveniently in other media interchange when
appropriate (e.g. paper document exchange, etc.).
ISO 13616-1:2007 does not specify internal procedures, file organization
techniques, storage media, languages, etc. to be used in its
implementation, nor is it designed to facilitate the routing of messages
within a network. It is applicable to the textual data which might be
conveyed through a system (network).
This project provides a general purpose ISO 13616-1:2007 compatible
IBAN Java class.
// SECTION-START[License Header]
//
/*
* jDTAUS ⁑ ISO-13616
* Copyright (C) Christian Schulte, 2013-222
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $JDTAUS: IbanSyntaxException.java 8825 2013-10-01 00:24:23Z schulte $
*
*/
//
// SECTION-END
package org.jdtaus.iso13616;
import java.util.Locale;
// SECTION-START[Documentation]
//
/**
* Gets thrown whenever parsing text to produce an international bank account number fails.
*
*
* - Identifier:
- jDTAUS ⁑ ISO-13616 ⁑ IBAN Syntax Exception
* - Name:
- jDTAUS ⁑ ISO-13616 ⁑ IBAN Syntax Exception
* - Abstract:
- No
* - Final:
- Yes
* - Stateless:
- No
*
*
* @author Christian Schulte
* @version 1.0
*/
//
// SECTION-END
// SECTION-START[Annotations]
//
@javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" )
//
// SECTION-END
public class IbanSyntaxException extends Exception
{
// SECTION-START[IbanSyntaxException]
/** Serial version UID for backwards compatibility with 2007.45.x classes. */
private static final long serialVersionUID = -475265309170567430L;
/**
* The malformed text.
* @serial
*/
private String malformedText;
/**
* The position at which parsing failed.
* @serial
*/
private int errorIndex;
/**
* Creates a new {@code IbanSyntaxException} instance taking malformed text and a position at which parsing failed.
*
* @param malformedText The malformed text.
* @param errorIndex The position at which parsing failed.
*/
public IbanSyntaxException( final String malformedText, final int errorIndex )
{
super();
this.malformedText = malformedText;
this.errorIndex = errorIndex;
}
/**
* Gets a message describing the exception.
*
* @return A message describing the exception.
*/
@Override
public String getMessage()
{
return getIbanSyntaxExceptionMessage( Locale.getDefault(), this.getMalformedText(), this.getErrorIndex() );
}
/**
* Gets a localized message describing the exception for a given locale.
*
* @param locale The locale of the localized message to get.
*
* @return A localized message describing the exception.
*
* @throws NullPointerException if {@code locale} is {@code null}.
*/
public String getLocalizedMessage( final Locale locale )
{
if ( locale == null )
{
throw new NullPointerException( "locale" );
}
return getIbanSyntaxExceptionMessage( locale, this.getMalformedText(), this.getErrorIndex() );
}
/**
* Gets the malformed text causing the exception.
*
* @return The malformed text causing the exception.
*/
public String getMalformedText()
{
return this.malformedText;
}
/**
* Gets the position at which parsing failed.
*
* @return The position at which parsing failed.
*/
public int getErrorIndex()
{
return this.errorIndex;
}
// SECTION-END
// SECTION-START[Dependencies]
// SECTION-END
// SECTION-START[Properties]
// SECTION-END
// SECTION-START[Messages]
//
/**
* Gets the text of the {@code } message.
*
* - Languages:
* - English (default)
* - Deutsch
* - Final:
- No
*
* @param locale The locale of the message to return.
* @param malformedText Format argument.
* @param errorIndex Format argument.
* @return The text of the {@code } message for {@code locale}.
*/
@SuppressWarnings("unused")
@javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" )
private static String getIbanSyntaxExceptionMessage( final java.util.Locale locale, final java.lang.String malformedText, final java.lang.Number errorIndex )
{
java.io.BufferedReader reader = null;
try
{
final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jdtaus.iso13616.IbanSyntaxException", locale ).getString( "IBAN Syntax Exception Message" ), malformedText, errorIndex, (Object) null );
final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() );
reader = new java.io.BufferedReader( new java.io.StringReader( message ) );
final String lineSeparator = System.getProperty( "line.separator", "\n" );
String line;
while ( ( line = reader.readLine() ) != null )
{
builder.append( lineSeparator ).append( line );
}
reader.close();
reader = null;
return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : "";
}
catch( final java.io.IOException e )
{
throw new java.lang.AssertionError( e );
}
finally
{
try
{
if( reader != null )
{
reader.close();
}
}
catch( final java.io.IOException e )
{
throw new java.lang.AssertionError( e );
}
}
}
//
// SECTION-END
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy