src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedObject.java
branchJEP-349-branch
changeset 58197 0ef79bd7fb5c
parent 58145 bc54ed8d908a
equal deleted inserted replaced
58193:baf88aa4f5db 58197:0ef79bd7fb5c
    62             public List<Type> readTypes(RecordingFile file) throws IOException {
    62             public List<Type> readTypes(RecordingFile file) throws IOException {
    63                 return file.readTypes();
    63                 return file.readTypes();
    64             }
    64             }
    65 
    65 
    66             public boolean isLastEventInChunk(RecordingFile file) {
    66             public boolean isLastEventInChunk(RecordingFile file) {
    67                 return file.isLastEventInChunk;
    67                 return file.isLastEventInChunk();
    68             }
    68             }
    69 
    69 
    70             @Override
    70             @Override
    71             public Object getOffsetDataTime(RecordedObject event, String name) {
    71             public Object getOffsetDataTime(RecordedObject event, String name) {
    72                 return event.getOffsetDateTime(name);
    72                 return event.getOffsetDateTime(name);
   831             case Timespan.MILLISECONDS:
   831             case Timespan.MILLISECONDS:
   832                 return Duration.ofMillis(timespan);
   832                 return Duration.ofMillis(timespan);
   833             case Timespan.NANOSECONDS:
   833             case Timespan.NANOSECONDS:
   834                 return Duration.ofNanos(timespan);
   834                 return Duration.ofNanos(timespan);
   835             case Timespan.TICKS:
   835             case Timespan.TICKS:
   836                 return Duration.ofNanos(objectContext.timeConverter.convertTimespan(timespan));
   836                 return Duration.ofNanos(objectContext.convertTimespan(timespan));
   837             }
   837             }
   838             throw new IllegalArgumentException("Attempt to get " + v.getTypeName() + " field \"" + name + "\" with illegal timespan unit " + ts.value());
   838             throw new IllegalArgumentException("Attempt to get " + v.getTypeName() + " field \"" + name + "\" with illegal timespan unit " + ts.value());
   839         }
   839         }
   840         throw new IllegalArgumentException("Attempt to get " + v.getTypeName() + " field \"" + name + "\" with missing @Timespan");
   840         throw new IllegalArgumentException("Attempt to get " + v.getTypeName() + " field \"" + name + "\" with missing @Timespan");
   841     }
   841     }
   904             }
   904             }
   905             switch (ts.value()) {
   905             switch (ts.value()) {
   906             case Timestamp.MILLISECONDS_SINCE_EPOCH:
   906             case Timestamp.MILLISECONDS_SINCE_EPOCH:
   907                 return Instant.ofEpochMilli(timestamp);
   907                 return Instant.ofEpochMilli(timestamp);
   908             case Timestamp.TICKS:
   908             case Timestamp.TICKS:
   909                 return Instant.ofEpochSecond(0, objectContext.timeConverter.convertTimestamp(timestamp));
   909                 return Instant.ofEpochSecond(0, objectContext.convertTimestamp(timestamp));
   910             }
   910             }
   911             throw new IllegalArgumentException("Attempt to get " + v.getTypeName() + " field \"" + name + "\" with illegal timestamp unit " + ts.value());
   911             throw new IllegalArgumentException("Attempt to get " + v.getTypeName() + " field \"" + name + "\" with illegal timestamp unit " + ts.value());
   912         }
   912         }
   913         throw new IllegalArgumentException("Attempt to get " + v.getTypeName() + " field \"" + name + "\" with missing @Timestamp");
   913         throw new IllegalArgumentException("Attempt to get " + v.getTypeName() + " field \"" + name + "\" with missing @Timestamp");
   914     }
   914     }
   979         p.flush(true);
   979         p.flush(true);
   980         return s.toString();
   980         return s.toString();
   981     }
   981     }
   982 
   982 
   983     // package private for now. Used by EventWriter
   983     // package private for now. Used by EventWriter
   984     OffsetDateTime getOffsetDateTime(String name) {
   984     private OffsetDateTime getOffsetDateTime(String name) {
   985         Instant instant = getInstant(name);
   985         Instant instant = getInstant(name);
   986         if (instant.equals(Instant.MIN)) {
   986         if (instant.equals(Instant.MIN)) {
   987             return OffsetDateTime.MIN;
   987             return OffsetDateTime.MIN;
   988         }
   988         }
   989         return OffsetDateTime.ofInstant(getInstant(name), objectContext.timeConverter.getZoneOffset());
   989         return OffsetDateTime.ofInstant(getInstant(name), objectContext.getZoneOffset());
   990     }
   990     }
   991 
   991 
   992     private static IllegalArgumentException newIllegalArgumentException(String name, String typeName) {
   992     private static IllegalArgumentException newIllegalArgumentException(String name, String typeName) {
   993         return new IllegalArgumentException("Attempt to get field \"" + name + "\" with illegal data type conversion " + typeName);
   993         return new IllegalArgumentException("Attempt to get field \"" + name + "\" with illegal data type conversion " + typeName);
   994     }
   994     }