Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   *
   * Licensed under the Apache License, Version 2.0 (the "License").
   * You may not use this file except in compliance with the License.
   * A copy of the License is located at
   *
   *  http://aws.amazon.com/apache2.0
   *
  * or in the "license" file accompanying this file. This file is distributed
  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
 package com.amazonaws.event;
 
 import java.util.Map;
 
A progress event. Typically this is used to notify a chunk of bytes has been transferred. Also used to notify other types of progress events such as a transfer starting, or failing.

The legacy Amazon S3 progress event com.amazonaws.services.s3.model.ProgressEvent has been deprecated in favor of this new class.

 
 public class ProgressEvent {
    
The number of bytes associated with the progress event.
 
     private final long bytes;
     private final ProgressEventType eventType;

    
Creates a BYTE_TRANSFER_EVENT with the specified bytesTransferred data.
 
     @Deprecated
     public ProgressEvent(long bytes) {
         this(.bytes);
     }

    
Creates a ProgressEvent object with the specified event type.

Parameters:
eventType Type of the progress event. This parameter must not be null.
 
     public ProgressEvent(ProgressEventType eventType) {
         this(eventType, 0);
     }

    
Creates a ProgressEvent object.

Parameters:
eventType Type of the progress event. This parameter must not be null.
bytes Number of bytes involved.
 
     public ProgressEvent(ProgressEventType eventTypelong bytes) {
         if (eventType == null)
             throw new IllegalArgumentException("eventType must not be null.");
         if (bytes < 0)
             throw new IllegalArgumentException("bytes reported must be non-negative");
         this. = eventType;
         this. = bytes;
     }

    
Returns the number of bytes associated with the event. The number of bytes are not necessarily the same as the number of bytes transferred, and it's meaning depends on the specific event type. For example, the bytes of a ProgressEventType.REQUEST_CONTENT_LENGTH_EVENT refers to the expected number of bytes to be sent to AWS, not the actual number of bytes that have been transferred.
 
     public long getBytes() {
         return ;
     }

    
Convenient method to returns the number of bytes transferred in this event, or the number of bytes reset (or discarded) if negative. In particular, bytes of a content-length event is excluded.
 
     public long getBytesTransferred() {
         switch() {
             case :
             case :
                 return ;
             case :
             case :
             case :
                 return 0 - ;
         default:
            return 0;
        }
    }

    
Returns the unique event code identifying the type of event this object represents.

Deprecated:
Use getEventType() instead.
Returns:
The unique event code that identifies what type of specific type of event this object represents.
    @Deprecated
    public int getEventCode() {
        Integer legacyCode =  .get();
        // Returns -1 if the event type does not have a legacy event code
        return legacyCode == null ? -1 : legacyCode;
    }

    
Returns the type of event this object represents. This method never returns null.

Returns:
The type of event this object represents.
    public ProgressEventType getEventType() {
        return ;
    }
    // Deprecated integer event codes

    
    @Deprecated public static final int PREPARING_EVENT_CODE = 1;

    
    @Deprecated public static final int STARTED_EVENT_CODE = 2;

    
    @Deprecated public static final int COMPLETED_EVENT_CODE = 4;

    
    @Deprecated public static final int FAILED_EVENT_CODE = 8;

    
    @Deprecated public static final int CANCELED_EVENT_CODE = 16;

    
    @Deprecated public static final int RESET_EVENT_CODE = 32;

    
    @Deprecated public static final int PART_STARTED_EVENT_CODE = 1024;

    
    @Deprecated public static final int PART_COMPLETED_EVENT_CODE = 2048;

    
    @Deprecated public static final int PART_FAILED_EVENT_CODE = 4096;
    // Mapping from event types to the legacy event codes
    private static final Map<ProgressEventTypeIntegerlegacyEventCodes =
        new EnumMap<ProgressEventTypeInteger>(ProgressEventType.class);
    static {
        .put(.,              0);
    }
    
    @Override
    public String toString() {
        return  + ", bytes: " + ;
    }
New to GrepCode? Check out our FAQ X