KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > enhancer > DefinedClass


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: DefinedClass.java 77 2006-03-01 13:02:50Z benoitf $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.enhancer;
26
27 /**
28  * This class is used to define class in classloader.
29  * @author Florent Benoit
30  */

31 public class DefinedClass {
32
33     /**
34      * Name of the class to define.
35      */

36     private String JavaDoc className;
37
38     /**
39      * Bytecode of the class.
40      */

41     private byte[] bytes;
42
43     /**
44      * Build a new object with a given class name and the bytecode in an
45      * array of bytes.
46      * @param className name of the class
47      * @param bytes bytecode
48      */

49     public DefinedClass(final String JavaDoc className, final byte[] bytes) {
50         this.className = className;
51         this.bytes = bytes;
52     }
53
54     /**
55      * @return bytecode of the class
56      */

57     public byte[] getBytes() {
58         return bytes;
59     }
60
61     /**
62      * @return the name of the class
63      */

64     public String JavaDoc getClassName() {
65         return className;
66     }
67
68     /**
69      * Equals.
70      * @param o object to compare
71      * @return true if given object is the same
72      */

73     @Override JavaDoc
74     public boolean equals(final Object JavaDoc o) {
75         if (o instanceof DefinedClass) {
76             DefinedClass other = (DefinedClass) o;
77             return className.equals(other.getClassName());
78         }
79         return false;
80     }
81
82     /**
83      * @return hashcode
84      */

85     @Override JavaDoc
86     public int hashCode() {
87         return className.hashCode();
88     }
89
90 }
91
Popular Tags