001 package edu.rice.cs.cunit.util; 002 003 import java.io.DataInputStream; 004 005 /** A DataInputStream that makes the position in the stream available. */ 006 public final class PositionDataInputStream extends DataInputStream implements ProvidesInputStreamPosition { 007 /** Delegee. */ 008 protected PositionInputStream _in; 009 010 /** Create a new PositionInputStream based on the stream given. 011 * @param in input stream */ 012 public PositionDataInputStream(PositionInputStream in) { 013 super(in); 014 _in = in; 015 } 016 017 /** 018 * <p>Get the stream position.</p> 019 * 020 * <p>Eventually, the position will roll over to a negative number. 021 * Reading 1 Tb per second, this would occur after approximately three 022 * months. Applications should account for this possibility in their 023 * design.</p> 024 * 025 * @return the current stream position. 026 */ 027 public synchronized long getPosition() { 028 return _in.getPosition(); 029 } 030 }