001/* Class used to test PtolemyThread. 002 003 Copyright (c) 2003-2013 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 */ 028package ptolemy.kernel.util.test; 029 030import ptolemy.kernel.util.DebugEvent; 031import ptolemy.kernel.util.PtolemyThread; 032 033/////////////////////////////////////////////////////////////////// 034//// TestPtolemyThread 035 036/** This class is used to test the protected _debug() method in 037 kernel.util.PtolemyThread. 038 @author Christopher Hylands 039 @version $Id$ 040 @since Ptolemy II 2.3 041 @Pt.ProposedRating Red (cxh) 042 @Pt.AcceptedRating Red (cxheecs.berkeley.edu) 043 */ 044public class TestPtolemyThread extends PtolemyThread { 045 /** Construct a new TestPtolemyThread object. This constructor has 046 * the same effect as TestPtolemyThread(null, null, 047 * <i>generatedName</i>), where <i>generatedName</i> is a newly 048 * generated name. Automatically generated names are of the form 049 * "Thread-"+n, where n is an integer. 050 */ 051 public TestPtolemyThread() { 052 super(); 053 } 054 055 /** Construct a new TestPtolemyThread object. This constructor has the same 056 * effect as TestPtolemyThread(null, target, <i>generatedName</i>), where 057 * <i>generatedName</i> is a newly generated name. Automatically generated 058 * names are of the form "Thread-"+n, where n is an integer. 059 * @param target The object whose run method is called. 060 */ 061 public TestPtolemyThread(Runnable target) { 062 super(target); 063 } 064 065 /** Construct a new TestPtolemyThread object. This constructor has the 066 * same effect as TestPtolemyThread(null, target, name) 067 * @param target The object whose run method is called. 068 * @param name The name of the new thread. 069 * 070 */ 071 public TestPtolemyThread(Runnable target, String name) { 072 super(target, name); 073 } 074 075 /** Construct a new TestPtolemyThread object. This constructor has the 076 * same effect as TestPtolemyThread(null, null, name) 077 * @param name The name of the new thread. 078 */ 079 public TestPtolemyThread(String name) { 080 super(name); 081 } 082 083 /** Construct a new TestPtolemyThread object. This constructor has the 084 * same effect as TestPtolemyThread(group, target, generatedName), 085 * where generatedName is a newly generated name. Automatically 086 * generated names are of the form "Thread-"+n, where n is an 087 * integer. 088 * @param group The thread group 089 * @param target The object whose run method is called. 090 */ 091 public TestPtolemyThread(ThreadGroup group, Runnable target) { 092 super(group, target); 093 } 094 095 /** Construct a new TestPtolemyThread object so that it has target as 096 * its run object, has the specified name as its name, and belongs 097 * to the thread group referred to by group. 098 * @param group The thread group. 099 * @param target The object whose run method is called. 100 * @param name The name of the new thread. 101 * @exception SecurityException If the superclass constructor throws it. 102 * 103 */ 104 public TestPtolemyThread(ThreadGroup group, Runnable target, String name) { 105 super(group, target, name); 106 } 107 108 /** Construct a new TestPtolemyThread object. This constructor has the same 109 * effect as TestPtolemyThread(group, null, name). 110 * @param group The thread group. 111 * @param name The name of the new thread. 112 */ 113 public TestPtolemyThread(ThreadGroup group, String name) { 114 super(group, name); 115 } 116 117 /////////////////////////////////////////////////////////////////// 118 //// public methods //// 119 120 /** Send a debug event to all debug listeners that have registered. 121 * TestPtolemyThread exists solely because in the parent class 122 * _debug() is protected 123 * @param event The event. 124 */ 125 public void debug(DebugEvent event) { 126 _debug(event); 127 } 128 129 /** Send a debug message to all debug listeners that have registered. 130 * By convention, messages should not include a newline at the end. 131 * The newline will be added by the listener, if appropriate. 132 * Note that using this method could be fairly expensive if the 133 * message is constructed from parts, and that this expense will 134 * be incurred regardless of whether there are actually any debug 135 * listeners. Thus, you should avoid, if possible, constructing 136 * the message from parts. 137 * @param message The message. 138 * @since Ptolemy II 2.3 139 */ 140 public void debug(String message) { 141 _debug(message); 142 } 143}