Created
August 2, 2011 15:28
-
-
Save odoe/1120419 to your computer and use it in GitHub Desktop.
AS3 DSL for ESRI Flex QueryTask
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.odoe.flexmaptools.utils | |
{ | |
import com.esri.ags.tasks.QueryTask; | |
import com.esri.ags.tasks.supportClasses.Query; | |
import mx.rpc.AsyncResponder; | |
import mx.rpc.AsyncToken; | |
/** | |
* This is an experiment in DSL for AS3. | |
* Use: | |
* var token:AsyncToken = new QueryToken() | |
* .usingUrl("urlStringGoesHere") | |
* .withObjectIds([0001, 002]) // Array of ObjectIds | |
* .withOutFields(["*"]) | |
* .handleResultWith(result_handler) | |
* .handleErrorWith(error_handler) | |
* .execute(); | |
* | |
* @author rrubalcava | |
*/ | |
public class QueryToken | |
{ | |
private var m_query:Query; | |
private var m_qTask:QueryTask; | |
private var m_resultResponse:Function; | |
private var m_errorResponse:Function; | |
public function QueryToken() | |
{ | |
m_query = new Query(); | |
m_qTask = new QueryTask(); | |
} | |
public function usingUrl(value:String):QueryToken | |
{ | |
m_qTask.url = value; | |
return this; | |
} | |
public function withObjectIds(value:Array):QueryToken | |
{ | |
m_query.objectIds = value; | |
return this; | |
} | |
public function withOutFields(value:Array):QueryToken | |
{ | |
m_query.outFields = value; | |
return this; | |
} | |
public function handleResultWith(value:Function):QueryToken | |
{ | |
m_resultResponse = value; | |
return this; | |
} | |
public function handleErrorWith(value:Function):QueryToken | |
{ | |
m_errorResponse = value; | |
return this; | |
} | |
public function execute():AsyncToken | |
{ | |
return m_qTask.execute(m_query, new AsyncResponder(m_resultResponse, m_errorResponse)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment