Path: blob/master/src/java.base/share/classes/jdk/internal/event/Event.java
41159 views
/*1* Copyright (c) 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. 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 jdk.internal.event;2627/**28* Base class for events, to be subclassed in order to define events and their29* fields.30*/31public abstract class Event {32/**33* Sole constructor, for invocation by subclass constructors, typically34* implicit.35*/36protected Event() {37}3839/**40* Starts the timing of this event.41*/42public void begin() {43}4445/**46* Ends the timing of this event.47*48* The {@code end} method must be invoked after the {@code begin} method.49*/50public void end() {51}5253/**54* Writes the field values, time stamp, and event duration.55* <p>56* If the event starts with an invocation of the {@code begin} method, but does57* not end with an explicit invocation of the {@code end} method, then the event58* ends when the {@code commit} method is invoked.59*/60public void commit() {61}6263/**64* Returns {@code true} if the event is enabled, {@code false} otherwise65*66* @return {@code true} if event is enabled, {@code false} otherwise67*/68public boolean isEnabled() {69return false;70}7172/**73* Returns {@code true} if the event is enabled and if the duration is within74* the threshold for the event, {@code false} otherwise.75*76* @return {@code true} if the event can be written, {@code false} otherwise77*/78public boolean shouldCommit() {79return false;80}8182/**83* Sets a field value.84*85* @param index the index of the field to set86* @param value value to set, can be {@code null}87* @throws UnsupportedOperationException if functionality is not supported88* @throws IndexOutOfBoundsException if {@code index} is less than {@code 0} or89* greater than or equal to the number of fields specified for the event90*/91public void set(int index, Object value) {92}93}949596