/** * Returns the content of the file range as a string. * * @return A <code>String</code> which represents the contents of the file range. */ @Override public String toString() { return String.format("bytes=%d-%d", this.getStartOffset(), this.getEndOffset()); } }
/** * Creates an instance of the <code>{@link FileRange}</code> class. * * @param start * A <code>long</code> which represents the starting offset. * @param end * A <code>long</code> which represents the ending offset. */ public FileRange(final long start, final long end) { this.setStartOffset(start); this.setEndOffset(end); }
expectedFileRanges.add(new FileRange(0, 512 - 1)); expectedFileRanges.add(new FileRange(2 * 512, 2 * 512 + 3 * 512 - 1)); assertEquals(expectedFileRanges.get(i).getStartOffset(), actualFileRanges.get(i).getStartOffset()); assertEquals(expectedFileRanges.get(i).getEndOffset(), actualFileRanges.get(i).getEndOffset());
@Override public void endElement(String uri, String localName, String qName) throws SAXException { String currentNode = this.elementStack.pop(); // if the node popped from the stack and the localName don't match, the xml document is improperly formatted if (!localName.equals(currentNode)) { throw new SAXException(SR.INVALID_RESPONSE_RECEIVED); } String value = this.bld.toString(); if (value.isEmpty()) { value = null; } if (FileConstants.FILE_RANGE_ELEMENT.equals(currentNode)) { final FileRange fileRangeRef = new FileRange(this.startOffset, this.endOffset); this.fileRanges.add(fileRangeRef); } else if (FileConstants.START_ELEMENT.equals(currentNode)) { this.startOffset = Long.parseLong(value); } else if (Constants.END_ELEMENT.equals(currentNode)) { this.endOffset = Long.parseLong(value); } this.bld = new StringBuilder(); }
request.setRequestProperty(Constants.HeaderConstants.STORAGE_RANGE_HEADER, range.toString());
@Override public void endElement(String uri, String localName, String qName) throws SAXException { String currentNode = this.elementStack.pop(); // if the node popped from the stack and the localName don't match, the xml document is improperly formatted if (!localName.equals(currentNode)) { throw new SAXException(SR.INVALID_RESPONSE_RECEIVED); } String value = this.bld.toString(); if (value.isEmpty()) { value = null; } if (FileConstants.FILE_RANGE_ELEMENT.equals(currentNode)) { final FileRange fileRangeRef = new FileRange(this.startOffset, this.endOffset); this.fileRanges.add(fileRangeRef); } else if (FileConstants.START_ELEMENT.equals(currentNode)) { this.startOffset = Long.parseLong(value); } else if (Constants.END_ELEMENT.equals(currentNode)) { this.endOffset = Long.parseLong(value); } this.bld = new StringBuilder(); }
request.setRequestProperty(Constants.HeaderConstants.STORAGE_RANGE_HEADER, range.toString());
/** * Returns the content of the file range as a string. * * @return A <code>String</code> which represents the contents of the file range. */ @Override public String toString() { return String.format("bytes=%d-%d", this.getStartOffset(), this.getEndOffset()); } }
final FileRange range = new FileRange(offset, offset + length - 1); final byte[] data = new byte[(int) length]; String md5 = null;
/** * Creates an instance of the <code>{@link FileRange}</code> class. * * @param start * A <code>long</code> which represents the starting offset. * @param end * A <code>long</code> which represents the ending offset. */ public FileRange(final long start, final long end) { this.setStartOffset(start); this.setEndOffset(end); }
final FileRange range = new FileRange(offset, offset + length - 1); final byte[] data = new byte[(int) length]; String md5 = null;
final FileRange range = new FileRange(offset, offset + length - 1);
final FileRange range = new FileRange(offset, offset + length - 1);