src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedEvent.java
branchJEP-349-branch
changeset 57460 bcbc53560c77
parent 57452 6fabe73e5d9a
child 58112 e7754025004b
equal deleted inserted replaced
57459:df39f8d8f4d6 57460:bcbc53560c77
    37  * A recorded event.
    37  * A recorded event.
    38  *
    38  *
    39  * @since 9
    39  * @since 9
    40  */
    40  */
    41 public final class RecordedEvent extends RecordedObject {
    41 public final class RecordedEvent extends RecordedObject {
    42     private final EventType eventType;
       
    43     long startTimeTicks;
    42     long startTimeTicks;
    44     long endTimeTicks;
    43     long endTimeTicks;
    45 
    44 
    46     // package private
    45     // package private
    47     RecordedEvent(EventType type, List<ValueDescriptor> vds, Object[] values, long startTimeTicks, long endTimeTicks, TimeConverter timeConverter) {
    46     RecordedEvent(ObjectContext objectContext, Object[] values, long startTimeTicks, long endTimeTicks) {
    48         super(vds, values, timeConverter);
    47         super(objectContext, values);
    49         this.eventType = type;
       
    50         this.startTimeTicks = startTimeTicks;
    48         this.startTimeTicks = startTimeTicks;
    51         this.endTimeTicks = endTimeTicks;
    49         this.endTimeTicks = endTimeTicks;
    52     }
    50     }
    53 
    51 
    54     /**
    52     /**
    75      * Returns the event type that describes the event.
    73      * Returns the event type that describes the event.
    76      *
    74      *
    77      * @return the event type, not {@code null}
    75      * @return the event type, not {@code null}
    78      */
    76      */
    79     public EventType getEventType() {
    77     public EventType getEventType() {
    80         return eventType;
    78         return objectContext.eventType;
    81     }
    79     }
    82 
    80 
    83     /**
    81     /**
    84      * Returns the start time of the event.
    82      * Returns the start time of the event.
    85      * <p>
    83      * <p>
   116      *
   114      *
   117      * @return descriptors, not {@code null}
   115      * @return descriptors, not {@code null}
   118      */
   116      */
   119     @Override
   117     @Override
   120     public List<ValueDescriptor> getFields() {
   118     public List<ValueDescriptor> getFields() {
   121         return getEventType().getFields();
   119         return objectContext.fields;
   122     }
   120     }
   123 
   121 
   124     protected final Object objectAt(int index) {
   122     protected final Object objectAt(int index) {
   125         if (index == 0) {
   123         if (index == 0) {
   126             return startTimeTicks;
   124             return startTimeTicks;
   133         }
   131         }
   134         return objects[index - 1];
   132         return objects[index - 1];
   135     }
   133     }
   136 
   134 
   137     private boolean hasDuration() {
   135     private boolean hasDuration() {
   138         return objects.length + 2 == descriptors.size();
   136         return objects.length + 2 == objectContext.fields.size();
   139     }
   137     }
   140 
   138 
   141     private long getStartTimeNanos() {
   139     private long getStartTimeNanos() {
   142         return timeConverter.convertTimestamp(startTimeTicks);
   140         return objectContext.timeConverter.convertTimestamp(startTimeTicks);
   143     }
   141     }
   144 
   142 
   145     private long getEndTimeNanos() {
   143     private long getEndTimeNanos() {
   146         return timeConverter.convertTimestamp(endTimeTicks);
   144         return objectContext.timeConverter.convertTimestamp(endTimeTicks);
   147     }
   145     }
   148 }
   146 }