KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > betwixt > strategy > ClassNormalizer


1 /*
2  * Copyright 2001-2004 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 org.apache.commons.betwixt.strategy;
17
18 /**
19  * <p>Class normalization strategy.</p>
20  *
21  * <p>
22  * The normalized Class is the Class that Betwixt should
23  * introspect.
24  * This strategy class allows the introspected Class to be
25  * varied.
26  * This implementation simply returns the Class given.
27  * </p>
28  *
29  * <p>
30  * Used by Betwixt to allow superclasses or interfaces to be subsittuted
31  * before an object is introspected.
32  * This allows users to feed in logical interfaces and make Betwixt ignore
33  * properties other than those in the interface.
34  * It also allows support for <code>Proxy</code>'s.
35  * Together, these features allow Betwixt to deal with Entity Beans
36  * properly by viewing them through their remote interfaces.
37  * </p>
38  * @author Robert Burrell Donkin
39  * @since 0.5
40  */

41 public class ClassNormalizer {
42
43     /**
44       * Gets the normalized class for the given Object.
45       * The normalized Class is the Class that Betwixt should
46       * introspect.
47       * This strategy class allows the introspected Class to be
48       * varied.
49       *
50       * @param object the <code>Object</code>
51       * for which the normalized Class is to be returned.
52       * @return the normalized Class
53       */

54     public Class JavaDoc getNormalizedClass( Object JavaDoc object ) {
55         if ( object == null ) {
56             throw new IllegalArgumentException JavaDoc("Cannot get class for null object.");
57         }
58         return normalize( object.getClass() );
59     }
60
61     /**
62       * Normalize given class.
63       * The normalized Class is the Class that Betwixt should
64       * introspect.
65       * This strategy class allows the introspected Class to be
66       * varied.
67       *
68       * @param clazz the class to normalize, not null
69       * @return this implementation the same clazz,
70       * subclasses may return any compatible class.
71       */

72     public Class JavaDoc normalize( Class JavaDoc clazz ) {
73         return clazz;
74     }
75 }
76
Popular Tags