KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > DuplicateException


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans;
21
22 /** Exception indicating that a module with a given code name base
23  * is already being managed, and that it is not permitted to add
24  * another with the same name.
25  * @author Jesse Glick
26  */

27 public final class DuplicateException extends Exception JavaDoc {
28
29     private transient Module old, nue;
30
31     DuplicateException(Module old, Module nue) {
32         // XXX if nue.jarFile == old.jarFile, produce special message
33
super(getInfo(nue) + " is a duplicate of " + getInfo(old)); // NOI18N
34
this.old = old;
35         this.nue = nue;
36     }
37     private static String JavaDoc getInfo(Module m) {
38         if (m.getJarFile() != null) {
39             return m.getJarFile().getAbsolutePath();
40         } else {
41             return m.getCodeNameBase();
42         }
43     }
44     
45     /** Get the module which is already known to exist.
46      */

47     public Module getOldModule() {
48         return old;
49     }
50     
51     /** Get the module whose creation was attempted.
52      * <strong>Warning:</strong> this module will be invalid,
53      * so do not attempt to do anything with it beyond asking
54      * it for its version and things like that.
55      */

56     public Module getNewModule() {
57         return nue;
58     }
59     
60 }
61
Popular Tags