com.amazonaws.util
Class LengthCheckInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by com.amazonaws.internal.SdkFilterInputStream
              extended by com.amazonaws.util.LengthCheckInputStream
All Implemented Interfaces:
com.amazonaws.internal.MetricAware, java.io.Closeable

public class LengthCheckInputStream
extends com.amazonaws.internal.SdkFilterInputStream

Used to perform length check to ensure the number of bytes read from the underlying input stream is the same as the expected total.


Field Summary
static boolean EXCLUDE_SKIPPED_BYTES
           
static boolean INCLUDE_SKIPPED_BYTES
           
 
Constructor Summary
LengthCheckInputStream(java.io.InputStream in, long expectedLength, boolean includeSkipped)
          Constructs an input stream that performs length check to ensure the number of bytes read from the underlying input stream is the same as the expected total.
 
Method Summary
 void mark(int readlimit)
           
 int read()
          
 int read(byte[] b, int off, int len)
          
 void reset()
           
 long skip(long n)
          
 
Methods inherited from class com.amazonaws.internal.SdkFilterInputStream
available, close, isMetricActivated, markSupported
 
Methods inherited from class java.io.FilterInputStream
read
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INCLUDE_SKIPPED_BYTES

public static final boolean INCLUDE_SKIPPED_BYTES
See Also:
Constant Field Values

EXCLUDE_SKIPPED_BYTES

public static final boolean EXCLUDE_SKIPPED_BYTES
See Also:
Constant Field Values
Constructor Detail

LengthCheckInputStream

public LengthCheckInputStream(java.io.InputStream in,
                              long expectedLength,
                              boolean includeSkipped)
Constructs an input stream that performs length check to ensure the number of bytes read from the underlying input stream is the same as the expected total.

Parameters:
in - the underlying input stream
expectedLength - the total length of the data in bytes expected to be read from the underlying input stream; must be non-negative.
includeSkipped - true if bytes skipped are to be considered as part of the data length; false otherwise. Typically, this parameter should be set to false for uploading data to AWS, but set to true for receiving data from AWS.
Method Detail

read

public int read()
         throws java.io.IOException

Overrides:
read in class com.amazonaws.internal.SdkFilterInputStream
Throws:
AmazonClientException - if the data length read has exceeded the expected total, or if the total data length is not the same as the expected total.
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException

Overrides:
read in class com.amazonaws.internal.SdkFilterInputStream
Throws:
AmazonClientException - if the data length read has exceeded the expected total, or if the total data length is not the same as the expected total.
java.io.IOException

mark

public void mark(int readlimit)
Overrides:
mark in class com.amazonaws.internal.SdkFilterInputStream

reset

public void reset()
           throws java.io.IOException
Overrides:
reset in class com.amazonaws.internal.SdkFilterInputStream
Throws:
java.io.IOException

skip

public long skip(long n)
          throws java.io.IOException

Overrides:
skip in class com.amazonaws.internal.SdkFilterInputStream
Throws:
AmazonClientException - if includeSkipped is true and the data length skipped has exceeded the expected total.
java.io.IOException


Copyright © 2010 Amazon Web Services, Inc. All Rights Reserved.