commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <>
Subject [COMPRESS] COMPRESS-64 - enforcing correct sequence of API calls
Date Thu, 23 Apr 2009 11:40:55 GMT
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

// 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.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message