Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/make/src/classes/build/tools/jdwpgen/Context.java
32287 views
/*1* Copyright (c) 1998, 2013, 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. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package build.tools.jdwpgen;2627import java.util.*;2829class Context {3031static final int outer = 0;32static final int readingReply = 1;33static final int writingCommand = 2;3435final String whereJava;36final String whereC;3738int state = outer;39private boolean inEvent = false;4041Context() {42whereJava = "";43whereC = "";44}4546private Context(String whereJava, String whereC) {47this.whereJava = whereJava;48this.whereC = whereC;49}5051Context subcontext(String level) {52Context ctx;53if (whereC.length() == 0) {54ctx = new Context(level, level);55} else {56ctx = new Context(whereJava + "." + level, whereC + "_" + level);57}58ctx.state = state;59ctx.inEvent = inEvent;60return ctx;61}6263private Context cloneContext() {64Context ctx = new Context(whereJava, whereC);65ctx.state = state;66ctx.inEvent = inEvent;67return ctx;68}6970Context replyReadingSubcontext() {71Context ctx = cloneContext();72ctx.state = readingReply;73return ctx;74}7576Context commandWritingSubcontext() {77Context ctx = cloneContext();78ctx.state = writingCommand;79return ctx;80}8182Context inEventSubcontext() {83Context ctx = cloneContext();84ctx.inEvent = true;85return ctx;86}8788boolean inEvent() {89return inEvent;90}9192boolean isWritingCommand() {93return state == writingCommand;94}9596boolean isReadingReply() {97return state == readingReply;98}99}100101102