import javax.xml.bind.annotation.XmlAccessorType;\r
\r
/**\r
- * Represents a chunk of string data together with the position in a file from\r
- * where corresponding to of the data.\r
+ * Represents a chunk of a string data together with the position in a file for\r
+ * the next read operation.\r
* \r
* @author pvtroshin\r
* \r
- * Date December 2009\r
+ * @version 1.0 December 2009\r
*/\r
@XmlAccessorType(XmlAccessType.FIELD)\r
public class ChunkHolder {\r
\r
- String chunk;\r
- long position;\r
+ String chunk;\r
+ long position;\r
\r
- private ChunkHolder() {\r
- // JaxB default constructor\r
- // should not be used otherwise\r
- }\r
-\r
- public ChunkHolder(String chunk, long position) {\r
- if (position < 0) {\r
- throw new IndexOutOfBoundsException(\r
- "Position in a file could not be negative! Given value: "\r
- + position);\r
- }\r
- if (chunk == null) {\r
- throw new NullPointerException("Chunk must not be NULL!");\r
+ private ChunkHolder() {\r
+ // JaxB default constructor\r
+ // should not be used otherwise\r
}\r
- this.chunk = chunk;\r
- this.position = position;\r
- }\r
-\r
- public String getChunk() {\r
- return chunk;\r
- }\r
\r
- public long getNextPosition() {\r
- return position;\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- if (obj == null) {\r
- return false;\r
+ public ChunkHolder(String chunk, long position) {\r
+ if (position < 0) {\r
+ throw new IndexOutOfBoundsException(\r
+ "Position in a file could not be negative! Given value: "\r
+ + position);\r
+ }\r
+ if (chunk == null) {\r
+ throw new NullPointerException("Chunk must not be NULL!");\r
+ }\r
+ this.chunk = chunk;\r
+ this.position = position;\r
}\r
- ChunkHolder ch = null;\r
- if (!(obj instanceof ChunkHolder)) {\r
- ch = (ChunkHolder) obj;\r
+\r
+ public String getChunk() {\r
+ return chunk;\r
}\r
- if (this.position != ch.position) {\r
- return false;\r
+\r
+ public long getNextPosition() {\r
+ return position;\r
}\r
- if (!this.chunk.equals(ch.chunk)) {\r
- return false;\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (obj == null) {\r
+ return false;\r
+ }\r
+ ChunkHolder ch = null;\r
+ if (!(obj instanceof ChunkHolder)) {\r
+ ch = (ChunkHolder) obj;\r
+ }\r
+ if (this.position != ch.position) {\r
+ return false;\r
+ }\r
+ if (!this.chunk.equals(ch.chunk)) {\r
+ return false;\r
+ }\r
+ return true;\r
}\r
- return true;\r
- }\r
\r
- @Override\r
- public String toString() {\r
- String value = "Position: " + position + "\n";\r
- value += "Chunk size: " + chunk.length() + "\n";\r
- value += "Chunk: " + chunk + "\n";\r
- return value;\r
- }\r
+ @Override\r
+ public String toString() {\r
+ String value = "Position: " + position + "\n";\r
+ value += "Chunk size: " + chunk.length() + "\n";\r
+ value += "Chunk: " + chunk + "\n";\r
+ return value;\r
+ }\r
\r
- @Override\r
- public int hashCode() {\r
- return new Long(position + chunk.hashCode()).intValue();\r
- }\r
+ @Override\r
+ public int hashCode() {\r
+ return new Long(position + chunk.hashCode()).intValue();\r
+ }\r
}\r