KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ch > ethz > prose > crosscut > Wildcard


1 //
2
// This file is part of the prose package.
3
//
4
// The contents of this file are subject to the Mozilla Public License
5
// Version 1.1 (the "License"); you may not use this file except in
6
// compliance with the License. You may obtain a copy of the License at
7
// http://www.mozilla.org/MPL/
8
//
9
// Software distributed under the License is distributed on an "AS IS" basis,
10
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
// for the specific language governing rights and limitations under the
12
// License.
13
//
14
// The Original Code is prose.
15
//
16
// The Initial Developer of the Original Code is Andrei Popovici. Portions
17
// created by Andrei Popovici are Copyright (C) 2002 Andrei Popovici.
18
// All Rights Reserved.
19
//
20
// Contributor(s):
21
// $Id: Wildcard.java,v 1.1.1.1 2003/07/02 15:30:51 apopovic Exp $
22
// =====================================================================
23
//
24
// (history at end)
25
//
26

27 package ch.ethz.prose.crosscut;
28
29 /**
30  * Interface Wildcard is a placeholder for serveral classes
31  * or class lists at a time.
32  * <p>
33  * <em>All classes implementing wildcard will have to provide
34  * a default constructor! </em>
35  * <p>
36  * This is the expected way to use wildcards: if <em>yourwildcard</em>
37  * extends <code>Wildcard</code>, then ask your wildcard whether it
38  * is assignable from something else using:
39  *
40  * <blockquote><pre>
41  * yourwildcard.newInstance().isAssignableFrom(String.class)
42  * </pre></blockquote>
43  *
44  * @version $Revision: 1.1.1.1 $
45  * @author Andrei Popovici
46  */

47 public
48 abstract class Wildcard {
49     private Object JavaDoc contained;
50
51     /** Return <code>true</code> if this object supports the operation
52      * <code>setObject</code> with a parameter being an instance of
53      * the class <code>cls</code>.
54      */

55     public abstract boolean isAssignableFrom(Class JavaDoc cls);
56
57     /** Return <code>true</code> if this object supports the operation
58      * <code>setObject</code> with a parameter being an array of objects,
59      * each of them having the class of the corresponding class in
60      * <code>clsList</code>.
61      *
62      * @param clsList the types of an eventual <code>setObject</code> paramter
63      */

64     public abstract boolean isAssignableFrom(Class JavaDoc[] clsList);
65
66     /** Set the contents of this wildcard. This should be used instead
67      * of assignments when using <code>Wildcard</code> classes.
68      */

69     public void setObject(Object JavaDoc obj) throws IllegalArgumentException JavaDoc
70     {
71     // FIXME: no time for type check
72
contained = obj;
73     }
74
75     /** Get the object last set with <code>setObject</code>.
76      *
77      * @return the object last "assigned" to this wildcard.
78      */

79     public Object JavaDoc getObject()
80     {
81     return contained;
82     }
83
84 }
85
86
87 //======================================================================
88
//
89
// $Log: Wildcard.java,v $
90
// Revision 1.1.1.1 2003/07/02 15:30:51 apopovic
91
// Imported from ETH Zurich
92
//
93
// Revision 1.1 2003/05/05 13:58:16 popovici
94
// renaming from runes to prose
95
//
96
// Revision 1.2 2002/03/28 13:48:44 popovici
97
// Mozilla-ified
98
//
99
// Revision 1.1.1.1 2001/11/29 18:13:17 popovici
100
// Sources from runes
101
//
102
// Revision 1.1.2.1 2000/10/23 18:36:41 popovici
103
// Initial Revision
104
//
105
Popular Tags