I think it would be possible to enforce the correct sequence of API calls in the AbstractxxStream classes.
This could be done as follows: public finish(){ throw Exception if state is invalid set state to finish finish0(); } // Override this if the sub-class needs to do anything. protected finish0(){ } Similarly for other methods. The Abstract class would be responsible for maintaining the current state and checking that the method is valid for the state. Another way to do this would be to implement a checkValidState() method that could be called by sub-classes. This would not enforce the rules - subclasses would have to call it - but would allow the common code to be extracted. WDYT? --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org