/*
* Copyright 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.
*/
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
namespace Amazon.S3.Model
{
///
/// This class represents the byte range for a range GET from S3.
///
public class ByteRange
{
///
/// Constructs a ByteRange and sets the start and end.
///
///
///
public ByteRange(long start, long end)
{
this.Start = start;
this.End = end;
}
///
/// Constructs a ByteRange and sets the header to the value specified.
///
///
public ByteRange(string byteRangeValue)
{
this._formattedByteRange = byteRangeValue;
}
///
/// A private string, represending the byte range.
///
private string _formattedByteRange;
///
/// The starting byte number of the range
///
public long Start
{
get;
set;
}
///
/// The ending byte number of the range
///
public long End
{
get;
set;
}
///
/// The formatted string representing the byte range to be set for the range header.
///
public string FormattedByteRange
{
get
{
if (!string.IsNullOrEmpty(this._formattedByteRange))
return this._formattedByteRange;
else
return string.Format(CultureInfo.InvariantCulture, "bytes={0}-{1}", this.Start, this.End);
}
set
{
_formattedByteRange = value;
}
}
}
}