org.jdtaus.banking.dtaus.PhysicalFileException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jdtaus-banking-api Show documentation
Show all versions of jdtaus-banking-api Show documentation
jDTAUS banking application programming interface.
/*
* jDTAUS Banking API
* Copyright (C) 2005 Christian Schulte
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
package org.jdtaus.banking.dtaus;
import java.util.Locale;
import org.jdtaus.core.container.ContainerFactory;
import org.jdtaus.core.text.Message;
/**
* Gets thrown by methods prepared to handle invalid files.
*
* @author Christian Schulte
* @version $JDTAUS: PhysicalFileException.java 8661 2012-09-27 11:29:58Z schulte $
*/
public class PhysicalFileException extends Exception
{
/** Serial version UID for backwards compatibility with 1.0.x classes. */
private static final long serialVersionUID = -8624765386920924529L;
/** Empty {@code Message} array. */
private static final Message[] NO_MESSAGES =
{
};
/**
* Messages describing the exception.
* @serial
*/
private final Message[] messages;
/**
* Creates a new {@code PhysicalFileException} instance taking an array of messages describing the exception.
*
* @param messages array of messages describing the exception or {@code null} if no information is available.
*/
public PhysicalFileException( final Message[] messages )
{
super();
this.messages = messages == null ? NO_MESSAGES : messages;
}
/**
* Getter for property {@code messages}.
*
* @return Messages describing the exception or an empty array if no information is available.
*/
public final Message[] getMessages()
{
return this.messages;
}
/**
* Returns the message of the exception.
*
* @return The message of the exception.
*/
public String getMessage()
{
return this.getPhysicalFileExceptionMessage( this.getLocale() );
}
/**
* Returns a string representation of the object.
*
* @return A string representation of the object.
*/
public String toString()
{
return super.toString() + this.internalString();
}
/**
* Creates a string representing the properties of the instance.
*
* @return A string representing the properties of the instance.
*/
private String internalString()
{
final StringBuffer buf = new StringBuffer( 200 ).append( '{' );
final Message[] msgs = this.getMessages();
for ( int i = 0; i < msgs.length; i++ )
{
buf.append( "[" ).append( i ).append( "]=" ).append( msgs[i].getText( Locale.getDefault() ) );
if ( i + 1 < msgs.length )
{
buf.append( ", " );
}
}
return buf.append( '}' ).toString();
}
//--Dependencies------------------------------------------------------------
// //GEN-BEGIN:jdtausDependencies
// This section is managed by jdtaus-container-mojo.
/**
* Gets the configured Locale
implementation.
*
* @return The configured Locale
implementation.
*/
private Locale getLocale()
{
return (Locale) ContainerFactory.getContainer().
getDependency( this, "Locale" );
}
// //GEN-END:jdtausDependencies
//------------------------------------------------------------Dependencies--
//--Messages----------------------------------------------------------------
// //GEN-BEGIN:jdtausMessages
// This section is managed by jdtaus-container-mojo.
/**
* Gets the text of message physicalFileException
.
* Datei-Fehler.
* File error.
*
* @param locale The locale of the message instance to return.
*
* @return the text of message physicalFileException
.
*/
private String getPhysicalFileExceptionMessage( final Locale locale )
{
return ContainerFactory.getContainer().
getMessage( this, "physicalFileException", locale, null );
}
// //GEN-END:jdtausMessages
//----------------------------------------------------------------Messages--
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy