KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > util > CloneableObject


1 /***************************************
2  * *
3  * JBoss: The OpenSource J2EE WebOS *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  ***************************************/

9
10 package org.jboss.util;
11
12 /**
13  * A simple base-class for classes which need to be cloneable.
14  *
15  * @version <tt>$Revision: 1.2 $</tt>
16  * @author <a HREF="mailto:jason@planet57.com">Jason Dillon</a>
17  */

18 public class CloneableObject
19    implements java.lang.Cloneable JavaDoc
20 {
21    /**
22     * Clone the object via {@link Object#clone}. This will return
23     * and object of the correct type, with all fields shallowly
24     * cloned.
25     */

26    public Object JavaDoc clone()
27    {
28       try {
29          return super.clone();
30       }
31       catch (CloneNotSupportedException JavaDoc e) {
32          throw new InternalError JavaDoc();
33       }
34    }
35
36    /**
37     * An interface which exposes a <em>public</em> clone method,
38     * unlike {@link Object#clone} which is protected and throws
39     * exceptions... how useless is that?
40     */

41    public static interface Cloneable
42       extends java.lang.Cloneable JavaDoc
43    {
44       Object JavaDoc clone();
45    }
46 }
47
Popular Tags