|
1 /* |
|
2 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. Oracle designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Oracle in the LICENSE file that accompanied this code. |
|
10 * |
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
|
15 * accompanied this code). |
|
16 * |
|
17 * You should have received a copy of the GNU General Public License version |
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 * |
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 * or visit www.oracle.com if you need additional information or have any |
|
23 * questions. |
|
24 */ |
|
25 |
|
26 package jdk.internal.event; |
|
27 |
|
28 /** |
|
29 * Base class for events, to be subclassed in order to define events and their |
|
30 * fields. |
|
31 */ |
|
32 public abstract class Event { |
|
33 /** |
|
34 * Sole constructor, for invocation by subclass constructors, typically |
|
35 * implicit. |
|
36 */ |
|
37 protected Event() { |
|
38 } |
|
39 |
|
40 /** |
|
41 * Starts the timing of this event. |
|
42 */ |
|
43 public void begin() { |
|
44 } |
|
45 |
|
46 /** |
|
47 * Ends the timing of this event. |
|
48 * |
|
49 * The {@code end} method must be invoked after the {@code begin} method. |
|
50 */ |
|
51 public void end() { |
|
52 } |
|
53 |
|
54 /** |
|
55 * Writes the field values, time stamp, and event duration. |
|
56 * <p> |
|
57 * If the event starts with an invocation of the {@code begin} method, but does |
|
58 * not end with an explicit invocation of the {@code end} method, then the event |
|
59 * ends when the {@code commit} method is invoked. |
|
60 */ |
|
61 public void commit() { |
|
62 } |
|
63 |
|
64 /** |
|
65 * Returns {@code true} if the event is enabled, {@code false} otherwise |
|
66 * |
|
67 * @return {@code true} if event is enabled, {@code false} otherwise |
|
68 */ |
|
69 public boolean isEnabled() { |
|
70 return false; |
|
71 } |
|
72 |
|
73 /** |
|
74 * Returns {@code true} if the event is enabled and if the duration is within |
|
75 * the threshold for the event, {@code false} otherwise. |
|
76 * |
|
77 * @return {@code true} if the event can be written, {@code false} otherwise |
|
78 */ |
|
79 public boolean shouldCommit() { |
|
80 return false; |
|
81 } |
|
82 |
|
83 /** |
|
84 * Sets a field value. |
|
85 * |
|
86 * @param index the index of the field to set |
|
87 * @param value value to set, can be {@code null} |
|
88 * @throws UnsupportedOperationException if functionality is not supported |
|
89 * @throws IndexOutOfBoundsException if {@code index} is less than {@code 0} or |
|
90 * greater than or equal to the number of fields specified for the event |
|
91 */ |
|
92 public void set(int index, Object value) { |
|
93 } |
|
94 } |