View Javadoc

1   /*
2    * The SmartWeb Framework
3    * Copyright (C) 2004-2006
4    *
5    * This library is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU Lesser General Public
7    * License as published by the Free Software Foundation; either
8    * version 2.1 of the License, or (at your option) any later version.
9    *
10   * This library is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   * Lesser General Public License for more details.
14   *
15   * You should have received a copy of the GNU Lesser General Public
16   * License along with this library; if not, write to the Free Software
17   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18   *
19   * For further informations on the SmartWeb Framework please visit
20   *
21   *                        http://smartweb.sourceforge.net
22   */
23  package net.smartlab.web;
24  
25  import java.io.Serializable;
26  
27  /**
28   * An UndefinedKeyException is thrown whenever an application tries to retrieve
29   * from a persistent storage an entity using the <i>unique identifier</i>, also
30   * known as <i>primary key</i> or simply <i>key</i>, and the requested
31   * identifing value is not present in the storage system.
32   * 
33   * @author rlogiacco
34   */
35  public class UndefinedKeyException extends DAOException {
36  
37  	private final static long serialVersionUID = 4418831216086543320L;
38  
39  	/**
40  	 * The key not found on the database.
41  	 * 
42  	 * @uml.property name="key"
43  	 */
44  	private Serializable key;
45  
46  	/**
47  	 * The class referred by the search.
48  	 * 
49  	 * @uml.property name="type"
50  	 */
51  	private Class type;
52  
53  
54  	/**
55  	 * Constructs a new instance with the key and type not found in the
56  	 * repository and originating exception.
57  	 * 
58  	 * @param key the key not found in the repository.
59  	 * @param type the class of the key not found in the repository.
60  	 * @param cause the originating exception.
61  	 */
62  	public UndefinedKeyException(Serializable key, Class type, Throwable cause) {
63  		super("persistence.error.select", cause);
64  		this.key = key;
65  		this.type = type;
66  	}
67  
68  	/**
69  	 * Constructs a new instance with the key and type not found in the
70  	 * repository.
71  	 * 
72  	 * @param key the key not found in the repository.
73  	 * @param type the class of the key not found in the repository.
74  	 */
75  	public UndefinedKeyException(Serializable key, Class type) {
76  		super("persistence.error.select");
77  		this.key = key;
78  		this.type = type;
79  	}
80  
81  	/**
82  	 * Returns the key.
83  	 * 
84  	 * @return the key.
85  	 * @uml.property name="key"
86  	 */
87  	public Serializable getKey() {
88  		return key;
89  	}
90  
91  	/**
92  	 * Returns the type.
93  	 * 
94  	 * @return the type.
95  	 * @uml.property name="type"
96  	 */
97  	public Class getType() {
98  		return type;
99  	}
100 }