public CloudTrailEvent getNextEvent() throws IOException {
        CloudTrailEventData eventData = new CloudTrailEventData();
        String key;

         /* Get next CloudTrailEvent event from log file. When failed to parse a event,
         * IOException will be thrown. In this case, the charEnd index the place we
         * encountered parsing error. */

        // return the starting location of the current token; that is, position of the first character
        // from input that starts the current token
        int charStart = (int) jsonParser.getTokenLocation().getCharOffset();

        while(jsonParser.nextToken() != JsonToken.END_OBJECT) {
            key = jsonParser.getCurrentName();

            switch (key) {
            case "eventVersion":
                String eventVersion = jsonParser.nextTextValue();
                if (Double.parseDouble(eventVersion) > SUPPORTED_EVENT_VERSION) {
                    logger.debug(String.format("EventVersion %s is not supported by CloudTrail.", eventVersion));
                }
                eventData.add(key, eventVersion);
                break;
            case "userIdentity":
                this.parseUserIdentity(eventData);
                break;
            case "eventTime":
                eventData.add(CloudTrailEventField.eventTime.name(), convertToDate(jsonParser.nextTextValue()));
                break;
            case "eventID":
                eventData.add(key, convertToUUID(jsonParser.nextTextValue()));
                break;
            case "readOnly":
                this.parseReadOnly(eventData);
                break;
            case "resources":
                this.parseResources(eventData);
                break;
            case "managementEvent":
                this.parseManagementEvent(eventData);
                break;
            default:
                eventData.add(key, parseDefaultValue(key));
                break;
            }
        }
        this.setAccountId(eventData);

        // event's last character position in the log file.
        int charEnd = (int) jsonParser.getTokenLocation().getCharOffset();

        CloudTrailEventMetadata metaData = getMetadata(charStart, charEnd);

        return new CloudTrailEvent(eventData, metaData);
    }
public CloudTrailEvent getNextEvent ( ) throws IOException { CloudTrailEventData eventData = new CloudTrailEventData ( ) ; String key ; int charStart = ( int ) jsonParser . getTokenLocation ( ) . getCharOffset ( ) ; while ( jsonParser . nextToken ( ) != JsonToken . END_OBJECT ) { key = jsonParser . getCurrentName ( ) ; switch ( key ) { case "eventVersion" : String eventVersion = jsonParser . nextTextValue ( ) ; if ( Double . parseDouble ( eventVersion ) > SUPPORTED_EVENT_VERSION ) { logger . debug ( String . format ( "EventVersion %s is not supported by CloudTrail." , eventVersion ) ) ; } eventData . add ( key , eventVersion ) ; break ; case "userIdentity" : this . parseUserIdentity ( eventData ) ; break ; case "eventTime" : eventData . add ( CloudTrailEventField . eventTime . name ( ) , convertToDate ( jsonParser . nextTextValue ( ) ) ) ; break ; case "eventID" : eventData . add ( key , convertToUUID ( jsonParser . nextTextValue ( ) ) ) ; break ; case "readOnly" : this . parseReadOnly ( eventData ) ; break ; case "resources" : this . parseResources ( eventData ) ; break ; case "managementEvent" : this . parseManagementEvent ( eventData ) ; break ; default : eventData . add ( key , parseDefaultValue ( key ) ) ; break ; } } this . setAccountId ( eventData ) ; int charEnd = ( int ) jsonParser . getTokenLocation ( ) . getCharOffset ( ) ; CloudTrailEventMetadata metaData = getMetadata ( charStart , charEnd ) ; return new CloudTrailEvent ( eventData , metaData ) ; }
Get the next event from the CloudTrail log and parse it.

@return a {@link CloudTrailEvent} that represents the
parsed event.
@throws IOException if the event could not be parsed.