Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/StateController.java
40948 views
/*1* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223package nsk.monitoring.share;2425import nsk.share.*;2627/**28* An abstract base class for operating VM state. The follow methods must29* be implemented by its subclasses:30* <ul>31* <li><code>run()</code> -- brings VM into defined state.32* <li><code>reset()</code> -- tries to reclaim VM into initial state.33* </ul>34*/35public abstract class StateController implements Runnable {3637/**38* Public default constructor.39*/40public StateController() {41super();42}4344/**45* A string that is printed before each string when {@link Log#complain46* <code>Log.complain()</code>}, and {@link Log#display47* <code>Log.display()</code>} are invoked.48*/49protected String logPrefix;5051/**52* A variable to save reference to {@link Log <code>Log.Logger</code>}53* class.54*/55protected Log.Logger logger;5657/**58* Brings VM into defined state.59*/60public abstract void run();6162/**63* Tries to reclaim VM into initial state64*/65public abstract void reset();6667/**68* Outputs <code>message</code> using {@link Log <code>Log.Logger</code>}69* object.70*/71protected void display(String message) {72if (logger != null)73logger.display(message);74}7576/**77* Outputs <code>message</code> using {@link Log <code>Log.Logger</code>}78* object.79*/80protected void complain(String message) {81if (logger != null)82logger.complain(message);83}8485/**86* Defines {@link Log <code>Log.Logger</code>} object.87*/88public void setLog(Log log) {89logger = new Log.Logger(log, logPrefix);90}9192/**93* Converts an integer to string.94*95* @param i an integer to convert.96* @return a string that represents the int value.97*/98public String int2Str(int i) {99String tmp = "";100101if (i < 10) {102tmp = "00";103} else if (i >= 10 && i < 100) {104tmp = "0";105}106return tmp + String.valueOf(i);107}108}109110111