001/* 002 * jDTAUS Banking API 003 * Copyright (C) 2005 Christian Schulte 004 * <cs@schulte.it> 005 * 006 * This library is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 2.1 of the License, or any later version. 010 * 011 * This library is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public 017 * License along with this library; if not, write to the Free Software 018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 019 * 020 */ 021package org.jdtaus.banking.dtaus; 022 023import java.util.Locale; 024import org.jdtaus.core.container.ContainerFactory; 025import org.jdtaus.core.text.Message; 026 027/** 028 * Gets thrown whenever an illegal transaction is passed to a method expecting a legal transaction. 029 * <p>Example: Catching an {@code IllegalTransactionException}<br/><blockquote> 030 * <pre> 031 * catch(IllegalTransactionException e) 032 * { 033 * if(e.getMessages().length > 0) 034 * { 035 * <i>Fetch messages for well-known properties first (optional).</i> 036 * e.getMessages(Transaction.PROP_<i>XYZ</i>); 037 * ... 038 * <i>Fetch all remaining messages.</i> 039 * e.getMessages(); 040 * ... 041 * } 042 * }</pre></blockquote></p> 043 * 044 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 045 * @version $JDTAUS: IllegalTransactionException.java 8661 2012-09-27 11:29:58Z schulte $ 046 */ 047public abstract class IllegalTransactionException extends IllegalArgumentException 048{ 049 050 /** Serial version UID for backwards compatibility with 1.0.x classes. */ 051 private static final long serialVersionUID = 2094280705320453233L; 052 053 /** Creates a new {@code IllegalTransactionException} instance. */ 054 public IllegalTransactionException() 055 { 056 super(); 057 } 058 059 /** 060 * Gets all messages describing the exception. 061 * 062 * @return An array of messages describing the exception or an empty array if the instance does not hold any 063 * messages. 064 */ 065 public abstract Message[] getMessages(); 066 067 /** 068 * Gets messages bound to a property removing these messages from the instance. 069 * 070 * @param propertyName the name of a property to return any messages for. 071 * 072 * @return All messages bound to a property with name {@code propertyName} or an empty array if the instance does 073 * not hold messages for a property with name {@code propertyName}. 074 * 075 * @throws NullPointerException if {@code propertyName} is {@code null}. 076 */ 077 public abstract Message[] getMessages( final String propertyName ); 078 079 /** 080 * Gets the names of all properties for which the exception holds messages. 081 * 082 * @return An array of the names of all properties for which the exception holds messages or an empty array if the 083 * exception does not hold any message bound to a property. 084 */ 085 public abstract String[] getPropertyNames(); 086 087 /** 088 * Returns the message of the exception. 089 * 090 * @return The message of the exception. 091 */ 092 public String getMessage() 093 { 094 return this.getIllegalTransactionMessage( this.getLocale() ); 095 } 096 097 //--Dependencies------------------------------------------------------------ 098 099// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausDependencies 100 // This section is managed by jdtaus-container-mojo. 101 102 /** 103 * Gets the configured <code>Locale</code> implementation. 104 * 105 * @return The configured <code>Locale</code> implementation. 106 */ 107 private Locale getLocale() 108 { 109 return (Locale) ContainerFactory.getContainer(). 110 getDependency( this, "Locale" ); 111 112 } 113 114// </editor-fold>//GEN-END:jdtausDependencies 115 116 //------------------------------------------------------------Dependencies-- 117 //--Messages---------------------------------------------------------------- 118 119// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausMessages 120 // This section is managed by jdtaus-container-mojo. 121 122 /** 123 * Gets the text of message <code>illegalTransaction</code>. 124 * <blockquote><pre>Ungültiger "C" Datensatz.</pre></blockquote> 125 * <blockquote><pre>Illegal "C" record.</pre></blockquote> 126 * 127 * @param locale The locale of the message instance to return. 128 * 129 * @return the text of message <code>illegalTransaction</code>. 130 */ 131 private String getIllegalTransactionMessage( final Locale locale ) 132 { 133 return ContainerFactory.getContainer(). 134 getMessage( this, "illegalTransaction", locale, null ); 135 136 } 137 138// </editor-fold>//GEN-END:jdtausMessages 139 140 //----------------------------------------------------------------Messages-- 141}