001package votorola.a.count.gwt; // Copyright 2012, Michael Allan. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE. 002 003import com.google.gwt.user.client.rpc.AsyncCallback; 004import votorola.a.web.wap.*; 005 006 007/** A {@linkplain CountCache.WAPResponse WAPResponse} callback with error detection. 008 */ 009abstract class WAPCleanCallback implements AsyncCallback<CountCache.WAPResponse> 010{ 011 012 013 /** Creates a WAPCleanCallback. 014 * 015 * @see #pollName() 016 */ 017 WAPCleanCallback( String _pollName ) { pollName = _pollName; } 018 019 020 021 // - A s y n c - C a l l b a c k -------------------------------------------------- 022 023 024 public final void onSuccess( final CountCache.WAPResponse response ) 025 { 026 final CountCache.WAPResponseP responseP; 027 try 028 { 029 responseP = response.forPoll( pollName ); 030 responseP.ensureClean(); 031 } 032 catch( final WAPException x ) 033 { 034 onFailure( x ); 035 return; 036 } 037 038 onSuccess( responseP ); 039 } 040 041 042 043 /** Handles successful completion of the call. 044 */ 045 abstract void onSuccess( CountCache.WAPResponseP responseP ); 046 047 048 049 /** Identifies the poll that was requested. 050 */ 051 String pollName() { return pollName; } 052 053 054 private final String pollName; 055 056 057 058} 059 060 061