Commit b7ea17f4 authored by Matt Strum's avatar Matt Strum
Browse files

Added some public/protected declarations to remove warnings in FlexBuilder

parent 8fd4b67e
/**
* @author Matt Shaw <xmlrpc@mattism.com>
* @url http://sf.net/projects/xmlrpcflash
* http://www.osflash.org/doku.php?id=xmlrpcflash
*
* @author Daniel Mclaren (http://danielmclaren.net)
* @note Updated to Actionscript 3.0
*/
package com.mattism.http.xmlrpc
{
import flash.events.Event;
import flash.events.ErrorEvent;
import flash.events.EventDispatcher;
import flash.events.IOErrorEvent;
import flash.events.SecurityErrorEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import com.mattism.http.xmlrpc.Connection;
import com.mattism.http.xmlrpc.MethodCall;
import com.mattism.http.xmlrpc.MethodCallImpl;
import com.mattism.http.xmlrpc.MethodFault;
import com.mattism.http.xmlrpc.MethodFaultImpl;
import com.mattism.http.xmlrpc.Parser;
import com.mattism.http.xmlrpc.ParserImpl;
public class ConnectionImpl extends EventDispatcher implements Connection
{
// Metadata
private var _VERSION : String = "1.0.0";
private var _PRODUCT : String = "ConnectionImpl";
private var ERROR_NO_URL : String = "No URL was specified for XMLRPCall.";
private var _url : String;
public var _method : MethodCall;
private var _rpc_response : Object;
private var _parser : Parser;
public var _response : URLLoader;
private var _parsed_response : Object;
private var _fault : MethodFault;
public function ConnectionImpl(url : String)
{
//prepare method response handler
//this.ignoreWhite = true;
//init method
this._method = new MethodCallImpl();
//init parser
this._parser = new ParserImpl();
//init response
this._response = new URLLoader();
this._response.addEventListener(Event.COMPLETE, this._onLoad);
// this._response.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatus);
this._response.addEventListener(IOErrorEvent.IO_ERROR, ioError);
// this._response.addEventListener(Event.OPEN, open);
// this._response.addEventListener(ProgressEvent.PROGRESS, progress);
this._response.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
securityError);
if (url)
{
this.setUrl( url );
}
}
public function cleanup() : void
{
this._response.removeEventListener(Event.COMPLETE, this._onLoad);
// this._response.removeEventListener(HTTPStatusEvent.HTTP_STATUS,
// httpStatus);
this._response.removeEventListener(IOErrorEvent.IO_ERROR, ioError);
// this._response.removeEventListener(Event.OPEN, open);
// this._response.removeEventListener(ProgressEvent.PROGRESS, progress);
this._response.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,
securityError);
}
public function call(method : String) : void
{
this._call( method );
}
private function _call( method:String ):void
{
if ( !this.getUrl() )
{
trace(ERROR_NO_URL);
throw Error(ERROR_NO_URL);
}
else
{
this.debug( "Call -> " + method+"() -> " + this.getUrl());
this._method.setName( method );
var request:URLRequest = new URLRequest();
request.contentType = 'text/xml';
request.data = this._method.getXml();
request.method = URLRequestMethod.POST;
request.url = this.getUrl();
this._response.load(request);
}
}
private function _onLoad( evt:Event ):void
{
var responseXML:XML = new XML(this._response.data);
_fault = null;
if (responseXML.fault.length() > 0)
{
// fault
var parsedFault:Object = parseResponse(responseXML.fault.value.*[0]);
_fault = new MethodFaultImpl( parsedFault );
trace("XMLRPC Fault (" + _fault.getFaultCode() + "):\n"
+ _fault.getFaultString());
dispatchEvent(new ErrorEvent(ErrorEvent.ERROR));
}
else if (responseXML.params)
{
_parsed_response = parseResponse(responseXML.params.param.value[0]);
dispatchEvent(new Event(Event.COMPLETE));
}
else
{
dispatchEvent(new ErrorEvent(ErrorEvent.ERROR));
}
}
function ioError(event : IOErrorEvent) : void
{
_fault = null;
dispatchEvent(new ErrorEvent(ErrorEvent.ERROR, false, false,
event.toString()));
}
function securityError(event : SecurityErrorEvent) : void
{
_fault = null;
dispatchEvent(new ErrorEvent(ErrorEvent.ERROR, false, false,
event.toString()));
}
private function parseResponse(xml:XML):Object
{
return this._parser.parse( xml );
}
//public function __resolve( method:String ):void { this._call( method ); }
public function getUrl() : String
{
return this._url;
}
public function setUrl(a : String) : void
{
this._url = a;
}
public function addParam(o : Object, type : String) : void
{
this._method.addParam( o,type );
}
public function removeParams() : void
{
this._method.removeParams();
}
public function getResponse() : Object
{
return this._parsed_response;
}
public function getFault() : MethodFault
{
return this._fault;
}
override public function toString() : String
{
return '<xmlrpc.ConnectionImpl Object>';
}
private function debug(a : String) : void
{
/*trace( this._PRODUCT + " -> " + a );*/
}
}
}
/**
* @author Matt Shaw <xmlrpc@mattism.com>
* @url http://sf.net/projects/xmlrpcflash
* http://www.osflash.org/doku.php?id=xmlrpcflash
*
* @author Daniel Mclaren (http://danielmclaren.net)
* @note Updated to Actionscript 3.0
*/
package com.mattism.http.xmlrpc
{
import flash.events.Event;
import flash.events.ErrorEvent;
import flash.events.EventDispatcher;
import flash.events.IOErrorEvent;
import flash.events.SecurityErrorEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import com.mattism.http.xmlrpc.Connection;
import com.mattism.http.xmlrpc.MethodCall;
import com.mattism.http.xmlrpc.MethodCallImpl;
import com.mattism.http.xmlrpc.MethodFault;
import com.mattism.http.xmlrpc.MethodFaultImpl;
import com.mattism.http.xmlrpc.Parser;
import com.mattism.http.xmlrpc.ParserImpl;
public class ConnectionImpl extends EventDispatcher implements Connection
{
// Metadata
private var _VERSION : String = "1.0.0";
private var _PRODUCT : String = "ConnectionImpl";
private var ERROR_NO_URL : String = "No URL was specified for XMLRPCall.";
private var _url : String;
public var _method : MethodCall;
private var _rpc_response : Object;
private var _parser : Parser;
public var _response : URLLoader;
private var _parsed_response : Object;
private var _fault : MethodFault;
public function ConnectionImpl(url : String)
{
//prepare method response handler
//this.ignoreWhite = true;
//init method
this._method = new MethodCallImpl();
//init parser
this._parser = new ParserImpl();
//init response
this._response = new URLLoader();
this._response.addEventListener(Event.COMPLETE, this._onLoad);
// this._response.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatus);
this._response.addEventListener(IOErrorEvent.IO_ERROR, ioError);
// this._response.addEventListener(Event.OPEN, open);
// this._response.addEventListener(ProgressEvent.PROGRESS, progress);
this._response.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
securityError);
if (url)
{
this.setUrl( url );
}
}
public function cleanup() : void
{
this._response.removeEventListener(Event.COMPLETE, this._onLoad);
// this._response.removeEventListener(HTTPStatusEvent.HTTP_STATUS,
// httpStatus);
this._response.removeEventListener(IOErrorEvent.IO_ERROR, ioError);
// this._response.removeEventListener(Event.OPEN, open);
// this._response.removeEventListener(ProgressEvent.PROGRESS, progress);
this._response.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,
securityError);
}
public function call(method : String) : void
{
this._call( method );
}
private function _call( method:String ):void
{
if ( !this.getUrl() )
{
trace(ERROR_NO_URL);
throw Error(ERROR_NO_URL);
}
else
{
this.debug( "Call -> " + method+"() -> " + this.getUrl());
this._method.setName( method );
var request:URLRequest = new URLRequest();
request.contentType = 'text/xml';
request.data = this._method.getXml();
request.method = URLRequestMethod.POST;
request.url = this.getUrl();
this._response.load(request);
}
}
private function _onLoad( evt:Event ):void
{
var responseXML:XML = new XML(this._response.data);
_fault = null;
if (responseXML.fault.length() > 0)
{
// fault
var parsedFault:Object = parseResponse(responseXML.fault.value.*[0]);
_fault = new MethodFaultImpl( parsedFault );
trace("XMLRPC Fault (" + _fault.getFaultCode() + "):\n"
+ _fault.getFaultString());
dispatchEvent(new ErrorEvent(ErrorEvent.ERROR));
}
else if (responseXML.params)
{
_parsed_response = parseResponse(responseXML.params.param.value[0]);
dispatchEvent(new Event(Event.COMPLETE));
}
else
{
dispatchEvent(new ErrorEvent(ErrorEvent.ERROR));
}
}
protected function ioError(event : IOErrorEvent) : void
{
_fault = null;
dispatchEvent(new ErrorEvent(ErrorEvent.ERROR, false, false,
event.toString()));
}
protected function securityError(event : SecurityErrorEvent) : void
{
_fault = null;
dispatchEvent(new ErrorEvent(ErrorEvent.ERROR, false, false,
event.toString()));
}
private function parseResponse(xml:XML):Object
{
return this._parser.parse( xml );
}
//public function __resolve( method:String ):void { this._call( method ); }
public function getUrl() : String
{
return this._url;
}
public function setUrl(a : String) : void
{
this._url = a;
}
public function addParam(o : Object, type : String) : void
{
this._method.addParam( o,type );
}
public function removeParams() : void
{
this._method.removeParams();
}
public function getResponse() : Object
{
return this._parsed_response;
}
public function getFault() : MethodFault
{
return this._fault;
}
override public function toString() : String
{
return '<xmlrpc.ConnectionImpl Object>';
}
private function debug(a : String) : void
{
/*trace( this._PRODUCT + " -> " + a );*/
}
}
}
/**
* @author Matt Shaw <xmlrpc@mattism.com>
* @url http://sf.net/projects/xmlrpcflash
* http://www.osflash.org/doku.php?id=xmlrpcflash
*
* @author Daniel Mclaren (http://danielmclaren.net)
* @note Updated to Actionscript 3.0
*/
package com.mattism.http.xmlrpc
{
interface MethodCall
{
function setName( name:String ):void;
function addParam( arg:Object, type:String ):void;
function removeParams():void;
function getXml():XML;
}
/**
* @author Matt Shaw <xmlrpc@mattism.com>
* @url http://sf.net/projects/xmlrpcflash
* http://www.osflash.org/doku.php?id=xmlrpcflash
*
* @author Daniel Mclaren (http://danielmclaren.net)
* @note Updated to Actionscript 3.0
*/
package com.mattism.http.xmlrpc
{
public interface MethodCall
{
function setName( name:String ):void;
function addParam( arg:Object, type:String ):void;
function removeParams():void;
function getXml():XML;
}
}
\ No newline at end of file
/**
* @author Matt Shaw <xmlrpc@mattism.com>
* @url http://sf.net/projects/xmlrpcflash
* http://www.osflash.org/doku.php?id=xmlrpcflash
*
* @author Daniel Mclaren (http://danielmclaren.net)
* @note Updated to Actionscript 3.0
*/
package com.mattism.http.xmlrpc
{
import com.mattism.http.xmlrpc.util.XMLRPCUtils;
import com.mattism.http.xmlrpc.util.XMLRPCDataTypes;
import com.mattism.http.xmlrpc.MethodCall;
public class MethodCallImpl
implements MethodCall
{
private var _VERSION:String = "1.0";
private var _PRODUCT:String = "MethodCallImpl";
private var _TRACE_LEVEL:Number = 3;
private var _parameters:Array;
private var _name:String;
private var _xml:XML;
public function MethodCallImpl(){
this.removeParams();
this.debug("MethodCallImpl instance created. (v" + _VERSION + ")");
}
public function setName( name:String ):void {
this._name=name;
}
public function addParam(param_value:Object,param_type:String):void {
this.debug("MethodCallImpl.addParam("+arguments+")");
this._parameters.push({type:param_type,value:param_value});
}
public function removeParams():void {
this._parameters=new Array();
}
public function getXml():XML {
this.debug("getXml()");
var ParentNode:XML;
var ChildNode:XML;
// Create the <methodCall>...</methodCall> root node
ParentNode = <methodCall />;
this._xml = ParentNode;
// Create the <methodName>...</methodName> node
ChildNode = <methodName>{this._name}</methodName>;
ParentNode.appendChild(ChildNode);
// Create the <params>...</params> node
ChildNode = <params />;
ParentNode.appendChild(ChildNode);
ParentNode = ChildNode;
// build nodes that hold all the params
this.debug("Render(): Creating the params node.");
var i:Number;
for (i=0; i<this._parameters.length; i++) {
this.debug("PARAM: " + [this._parameters[i].type,this._parameters[i].value]);
ChildNode = <param />;
ChildNode.appendChild( this.createParamsNode(this._parameters[i]) );
ParentNode.appendChild(ChildNode);
}
this.debug("Render(): Resulting XML document:");
this.debug("Render(): " + this._xml.toXMLString());
return this._xml;
}
private function createParamsNode( parameter:Object ):XML
{
this.debug("CreateParameterNode()");
var Node:XML = <value />;
var TypeNode:XML;
if (parameter is String)
{
parameter = {value:parameter};
}
else if (parameter && parameter.value == null)
{
parameter = {value:parameter};
}
if ( typeof parameter == "object")
{
// Default to
if (!parameter.type){
var v:Object = parameter.value;
if ( v is Array )
parameter.type=XMLRPCDataTypes.ARRAY;
else if ( v is String )
parameter.type=XMLRPCDataTypes.STRING;
else if ( v is Object )
parameter.type=XMLRPCDataTypes.STRUCT;
else
parameter.type = XMLRPCDataTypes.STRING;
}
// Handle Explicit Simple Objects
if ( XMLRPCUtils.isSimpleType(parameter.type) ) {
//cdata is really a string type with a cdata wrapper, so don't really make a 'cdata' tag
parameter = this.fixCDATAParameter(parameter);
this.debug("CreateParameterNode(): Creating object '"+parameter.value+"' as type "+parameter.type);
TypeNode = <{parameter.type}>{parameter.value}</{parameter.type}>;
Node.appendChild(TypeNode);
return Node;
}
// Handle Array Objects
if (parameter.type == XMLRPCDataTypes.ARRAY) {
var DataNode:XML;