1 /* Copyright (c) 2009 Peter Troshin
\r
3 * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0
\r
5 * This library is free software; you can redistribute it and/or modify it under the terms of the
\r
6 * Apache License version 2 as published by the Apache Software Foundation
\r
8 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
\r
9 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache
\r
10 * License for more details.
\r
12 * A copy of the license is in apache_license.txt. It is also available here:
\r
13 * @see: http://www.apache.org/licenses/LICENSE-2.0.txt
\r
15 * Any republication or derived work distributed in source code form
\r
16 * must include this copyright and license notice.
\r
19 package compbio.metadata;
\r
21 import javax.xml.bind.annotation.XmlAccessType;
\r
22 import javax.xml.bind.annotation.XmlAccessorType;
\r
25 * Represents a chunk of a string data together with the position in a file for
\r
26 * the next read operation.
\r
30 * @version 1.0 December 2009
\r
32 @XmlAccessorType(XmlAccessType.FIELD)
\r
33 public class ChunkHolder {
\r
38 private ChunkHolder() {
\r
39 // JaxB default constructor
\r
40 // should not be used otherwise
\r
43 public ChunkHolder(String chunk, long position) {
\r
45 throw new IndexOutOfBoundsException(
\r
46 "Position in a file could not be negative! Given value: "
\r
49 if (chunk == null) {
\r
50 throw new NullPointerException("Chunk must not be NULL!");
\r
53 this.position = position;
\r
56 public String getChunk() {
\r
60 public long getNextPosition() {
\r
65 public boolean equals(Object obj) {
\r
69 ChunkHolder ch = null;
\r
70 if (!(obj instanceof ChunkHolder)) {
\r
71 ch = (ChunkHolder) obj;
\r
73 if (this.position != ch.position) {
\r
76 if (!this.chunk.equals(ch.chunk)) {
\r
83 public String toString() {
\r
84 String value = "Position: " + position + "\n";
\r
85 value += "Chunk size: " + chunk.length() + "\n";
\r
86 value += "Chunk: " + chunk + "\n";
\r
91 public int hashCode() {
\r
92 return new Long(position + chunk.hashCode()).intValue();
\r