KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > cglib > core > GeneratorStrategy


1 /*
2  * Copyright 2003 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package net.sf.cglib.core;
17
18 /**
19  * The <code>GeneratorStrategy</code. is responsible for taking a
20  * {@link ClassGenerator} and producing a byte array containing the
21  * data for the generated <code>Class</code>. By providing your
22  * own strategy you may examine or modify the generated class before
23  * it is loaded. Typically this will be accomplished by subclassing
24  * {@link DefaultGeneratorStrategy} and overriding the appropriate
25  * protected method.
26  * @see AbstractClassGenerator#setStrategy
27  */

28 public interface GeneratorStrategy {
29     /**
30      * Generate the class.
31      * @param cg a class generator on which you can call {@link ClassGenerator#generateClass}
32      * @return a byte array containing the bits of a valid Class
33      */

34     byte[] generate(ClassGenerator cg) throws Exception JavaDoc;
35
36     /**
37      * The <code>GeneratorStrategy</code> in use does not currently, but may
38      * in the future, affect the caching of classes generated by {@link
39      * AbstractClassGenerator}, so this is a reminder that you should
40      * correctly implement <code>equals</code> and <code>hashCode</code>
41      * to avoid generating too many classes.
42      */

43     boolean equals(Object JavaDoc o);
44 }
45
Popular Tags