001: //
002: // This file is part of the prose package.
003: //
004: // The contents of this file are subject to the Mozilla Public License
005: // Version 1.1 (the "License"); you may not use this file except in
006: // compliance with the License. You may obtain a copy of the License at
007: // http://www.mozilla.org/MPL/
008: //
009: // Software distributed under the License is distributed on an "AS IS" basis,
010: // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
011: // for the specific language governing rights and limitations under the
012: // License.
013: //
014: // The Original Code is prose.
015: //
016: // The Initial Developer of the Original Code is Andrei Popovici. Portions
017: // created by Andrei Popovici are Copyright (C) 2002 Andrei Popovici.
018: // All Rights Reserved.
019: //
020: // Contributor(s):
021: // $Id: Wildcard.java,v 1.1.1.1 2003/07/02 15:30:51 apopovic Exp $
022: // =====================================================================
023: //
024: // (history at end)
025: //
026:
027: package ch.ethz.prose.crosscut;
028:
029: /**
030: * Interface Wildcard is a placeholder for serveral classes
031: * or class lists at a time.
032: * <p>
033: * <em>All classes implementing wildcard will have to provide
034: * a default constructor! </em>
035: * <p>
036: * This is the expected way to use wildcards: if <em>yourwildcard</em>
037: * extends <code>Wildcard</code>, then ask your wildcard whether it
038: * is assignable from something else using:
039: *
040: * <blockquote><pre>
041: * yourwildcard.newInstance().isAssignableFrom(String.class)
042: * </pre></blockquote>
043: *
044: * @version $Revision: 1.1.1.1 $
045: * @author Andrei Popovici
046: */
047: public abstract class Wildcard {
048: private Object contained;
049:
050: /** Return <code>true</code> if this object supports the operation
051: * <code>setObject</code> with a parameter being an instance of
052: * the class <code>cls</code>.
053: */
054: public abstract boolean isAssignableFrom(Class cls);
055:
056: /** Return <code>true</code> if this object supports the operation
057: * <code>setObject</code> with a parameter being an array of objects,
058: * each of them having the class of the corresponding class in
059: * <code>clsList</code>.
060: *
061: * @param clsList the types of an eventual <code>setObject</code> paramter
062: */
063: public abstract boolean isAssignableFrom(Class[] clsList);
064:
065: /** Set the contents of this wildcard. This should be used instead
066: * of assignments when using <code>Wildcard</code> classes.
067: */
068: public void setObject(Object obj) throws IllegalArgumentException {
069: // FIXME: no time for type check
070: contained = obj;
071: }
072:
073: /** Get the object last set with <code>setObject</code>.
074: *
075: * @return the object last "assigned" to this wildcard.
076: */
077: public Object getObject() {
078: return contained;
079: }
080:
081: }
082:
083: //======================================================================
084: //
085: // $Log: Wildcard.java,v $
086: // Revision 1.1.1.1 2003/07/02 15:30:51 apopovic
087: // Imported from ETH Zurich
088: //
089: // Revision 1.1 2003/05/05 13:58:16 popovici
090: // renaming from runes to prose
091: //
092: // Revision 1.2 2002/03/28 13:48:44 popovici
093: // Mozilla-ified
094: //
095: // Revision 1.1.1.1 2001/11/29 18:13:17 popovici
096: // Sources from runes
097: //
098: // Revision 1.1.2.1 2000/10/23 18:36:41 popovici
099: // Initial Revision
100: //
|