001    // PriorityParameters.java, created by cata
002    // Copyright (C) 2001 Catalin Francu <cata@mit.edu>
003    // Licensed under the terms of the GNU GPL; see COPYING for details.
004    
005    package javax.realtime;
006    
007    /** Instances of this class should be assigned to threads that are
008     *  managed by schedulers which use a single integer to determine
009     *  execution order. The base scheduler required by this specification
010     *  and represented by the class <code>PriorityScheduler</code> is
011     *  such a scheduler.
012     */
013    public class PriorityParameters extends SchedulingParameters {
014        
015        private int priority;
016    
017        /** Create an instance of <code>SchedulingParameters</code> with
018         *  the given priority.
019         *
020         *  @param priority The priority assigned to a thread. This value
021         *                   is used in place of the value returned by
022         *                   <code>java.langThread.setPriority(int)</code>.
023         */
024        public PriorityParameters(int priority) {
025            this.priority = priority;
026        }
027    
028        /** Gets the priority value.
029         *
030         *  @return The priority.
031         */
032        public int getPriority() {
033            return priority;
034        }
035    
036        /** Sets the priority value.
037         *
038         *  @param priority The value to which priority is set.
039         *  @throws java.lang.IllegalArgumentException Thrown if the given
040         *                                             priority value is less
041         *                                             than the minimum priority
042         *                                             of the scheduler of any of
043         *                                             the associated threads of
044         *                                             greater then the maximum
045         *                                             priority of the scheduler
046         *                                             of any of the associated threads.
047         */
048        public void setPriority(int priority)
049            throws IllegalArgumentException {
050            this.priority = priority;
051        }
052        
053        /** Converts the priority value to a string.
054         *
055         *  @return The string representing the value of priority.
056         */
057        public String toString() {
058            return String.valueOf(priority);
059        }
060    }