001 /* 002 * Copyright 2003-2004 The Apache Software Foundation 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.apache.commons.events.observable; 017 018 /** 019 * Exception thrown when a modification to a collection is vetoed. 020 * It extends IllegalArgumentException for compatibility with the collections API. 021 * 022 * @since Commons Events 1.0 023 * @version $Revision: 155443 $ $Date: 2005-02-26 13:19:51 +0000 (Sat, 26 Feb 2005) $ 024 * 025 * @author Stephen Colebourne 026 */ 027 public class ModificationVetoedException extends IllegalArgumentException { 028 029 /** The source event */ 030 protected final ModificationEvent event; 031 032 // Constructor 033 //----------------------------------------------------------------------- 034 /** 035 * Constructor. 036 * 037 * @param message the text message, may be null 038 * @param event the observed event, should not be null 039 */ 040 public ModificationVetoedException(final String message, final ModificationEvent event) { 041 super((message == null ? "Modification vetoed" : message)); 042 this.event = event; 043 } 044 045 // Event access 046 //----------------------------------------------------------------------- 047 /** 048 * Gets the event that caused the veto. 049 * 050 * @return the event 051 */ 052 public ModificationEvent getEvent() { 053 return event; 054 } 055 056 }