protected final void switchState(final TransactionState newState) throws SQLException {
synchronized (getSynchronizationObject()) {
    final TransactionState currentState=state;
    if (currentState == newState)     return;
    if (currentState.isValidTransition(newState)) {
      state=newState;
      transactionListenerDispatcher.transactionStateChanged(this,newState,currentState);
    }
 else {
      throw new SQLException(String.format("Unable to change transaction state: state %s is not valid after %s",newState,currentState));
    }
  }
}

protected final void switchState ( final TransactionState newState ) throws SQLException { synchronized ( getSynchronizationObject ( ) ) { final TransactionState currentState = state ; if ( currentState == newState ) return ; if ( currentState . isValidTransition ( newState ) ) { state = newState ; transactionListenerDispatcher . transactionStateChanged ( this , newState , currentState ) ; } else { throw new SQLException ( String . format ( "Unable to change transaction state: state %s is not valid after %s" , newState , currentState ) ) ; } } }
switches current state to the supplied newstate .
