commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
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
  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-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message