001/* The CompositeActor is not schedulable under a certain algorithm.
002
003 Copyright (c) 1998-2014 The Regents of the University of California.
004 All rights reserved.
005 Permission is hereby granted, without written agreement and without
006 license or royalty fees, to use, copy, modify, and distribute this
007 software and its documentation for any purpose, provided that the above
008 copyright notice and the following two paragraphs appear in all copies
009 of this software.
010
011 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
012 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
013 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
014 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
015 SUCH DAMAGE.
016
017 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
018 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
020 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
021 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
022 ENHANCEMENTS, OR MODIFICATIONS.
023
024 PT_COPYRIGHT_VERSION_2
025 COPYRIGHTENDKEY
026
027 saving the actors as an enumeration, but this value was not
028 used anywhere so I pulled out that code.
029 */
030package ptolemy.actor.sched;
031
032import java.util.ArrayList;
033import java.util.Collection;
034import java.util.Enumeration;
035import java.util.List;
036
037import ptolemy.kernel.util.InvalidStateException;
038import ptolemy.kernel.util.Nameable;
039
040///////////////////////////////////////////////////////////////////
041//// NotSchedulableException
042
043/**
044 This is a special case of the InvalidStateException such that a
045 CompositeActor is not schedulable by a certain scheduler.
046 @author Jie Liu, Christopher Hylands
047 @version $Id$
048 @since Ptolemy II 0.2
049 @Pt.ProposedRating Red (liuj)
050 @Pt.AcceptedRating Red (cxh) This class was
051 @see ptolemy.kernel.util.InvalidStateException
052 */
053@SuppressWarnings("serial")
054public class NotSchedulableException extends InvalidStateException {
055    /** Constructs an Exception with only a detail message.
056     *  @param detail The message.
057     *  @deprecated Use a NotSchedulableException constructor that
058     *  includes a Nameable so that the exception window includes
059     *  a "Go To Actor" button.
060     */
061    @Deprecated
062    public NotSchedulableException(String detail) {
063        super(detail);
064    }
065
066    /** Constructs an Exception with a detail message that includes the
067     *  name of the first argument and the second argument string.
068     *  @param nameable The object.
069     *  @param detail The message.
070     */
071    public NotSchedulableException(Nameable nameable, String detail) {
072        super(nameable, detail);
073    }
074
075    /** Constructs an Exception with a detail message that includes the
076     *  names of the first two arguments plus the third argument string.
077     *  @param nameable1 The first object.
078     *  @param nameable2 The second object.
079     *  @param detail The message.
080     */
081    public NotSchedulableException(Nameable nameable1, Nameable nameable2,
082            String detail) {
083        super(nameable1, nameable2, detail);
084    }
085
086    /** Constructs an Exception with a detail message that includes the
087     *  names of an enumeration of nameables and the detail argument.
088     *  @deprecated Use
089     *    NotSchedulableException(Collection, Throwable, String) instead.
090     *  @param actors The unschedulable actors.
091     *  @param detail The message.
092     */
093    @Deprecated
094    public NotSchedulableException(Enumeration actors, String detail) {
095        this(_list(actors), null, detail);
096    }
097
098    /** Constructs an Exception with a detail message that includes the
099     *  names of a Collection of nameables, the causing Throwable
100     *  and the detail argument.
101     *  @param actors The unschedulable actors.
102     *  @param cause The cause.
103     *  @param detail The message.
104     */
105    public NotSchedulableException(Collection actors, Throwable cause,
106            String detail) {
107        super(actors, cause, detail);
108    }
109
110    ///////////////////////////////////////////////////////////////////
111    ////                         private methods                   ////
112    // Convert from an Enumeration to a List.
113    //
114    // JDK1.4 has a Collections.list(Enumeration) method
115    // that would be good to use.
116    // For suggestions about converting from Enumerations to Lists,
117    // see
118    // http://download.oracle.com/javase/tutorial/collections/interoperability/compatibility.html
119    private static List _list(Enumeration objects) {
120        List list = new ArrayList();
121
122        while (objects.hasMoreElements()) {
123            list.add(objects.nextElement());
124        }
125
126        return list;
127    }
128}