Updated Branches:
refs/heads/develop 9ea55e39c -> 0991467eb
Add BinaryUploader. Doesn't work on <IE9 as it uses typed arrays
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/0991467e
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/0991467e
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/0991467e
Branch: refs/heads/develop
Commit: 0991467ebced08bf0aaa7cb376aa7df7f873588b
Parents: 9ea55e3
Author: Alex Harui <ah...@apache.org>
Authored: Mon May 6 22:06:31 2013 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Mon May 6 22:06:31 2013 -0700
----------------------------------------------------------------------
frameworks/as/basic-manifest.xml | 1 +
.../as/src/org/apache/flex/net/BinaryUploader.as | 305 ++++++++++
.../as/src/org/apache/flex/utils/BinaryData.as | 106 ++++
.../src/org/apache/flex/net/BinaryUploader.js | 429 +++++++++++++++
.../FlexJS/src/org/apache/flex/utils/BinaryData.js | 220 ++++++++
5 files changed, 1061 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0991467e/frameworks/as/basic-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/as/basic-manifest.xml b/frameworks/as/basic-manifest.xml
index 3998ceb..8654660 100644
--- a/frameworks/as/basic-manifest.xml
+++ b/frameworks/as/basic-manifest.xml
@@ -43,5 +43,6 @@
<component id="JSONInputParser" class="org.apache.flex.net.JSONInputParser"/>
<component id="JSONItemConverter" class="org.apache.flex.net.JSONItemConverter"/>
<component id="ViewSourceContextMenuOption" class="org.apache.flex.utils.ViewSourceContextMenuOption"/>
+ <component id="BinaryUploader" class="org.apache.flex.net.BinaryUploader"/>
</componentPackage>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0991467e/frameworks/as/src/org/apache/flex/net/BinaryUploader.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/net/BinaryUploader.as b/frameworks/as/src/org/apache/flex/net/BinaryUploader.as
new file mode 100644
index 0000000..e806518
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/net/BinaryUploader.as
@@ -0,0 +1,305 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.net
+{
+ import flash.events.HTTPStatusEvent;
+ import flash.events.IOErrorEvent;
+ import flash.net.URLLoader;
+ import flash.net.URLRequest;
+ import flash.net.URLRequestHeader;
+ import flash.net.URLRequestMethod;
+
+ import org.apache.flex.core.IBead;
+ import org.apache.flex.core.IStrand;
+ import org.apache.flex.events.Event;
+ import org.apache.flex.events.EventDispatcher;
+ import org.apache.flex.utils.BinaryData;
+
+ [Event(name="complete", type="org.apache.flex.events.Event")]
+
+ [Event(name="ioError", type="org.apache.flex.events.Event")]
+
+ [Event(name="httpStatus", type="org.apache.flex.events.Event")]
+
+ [Event(name="httpResponseStatus", type="org.apache.flex.events.Event")]
+
+ [DefaultProperty("beads")]
+
+ public class BinaryUploader extends EventDispatcher implements IStrand, IBead
+ {
+ public static const HTTP_METHOD_GET:String = URLRequestMethod.GET;
+ public static const HTTP_METHOD_POST:String = URLRequestMethod.POST;
+ public static const HTTP_METHOD_PUT:String = URLRequestMethod.PUT;
+ public static const HTTP_METHOD_DELETE:String = URLRequestMethod.DELETE;
+
+ public function BinaryUploader()
+ {
+ super();
+ }
+
+ private var _contentType:String = "application/octet-stream";
+ public function get contentType():String
+ {
+ return _contentType;
+ }
+ public function set contentType(value:String):void
+ {
+ if (_contentType != value)
+ {
+ _contentType = value;
+ dispatchEvent(new Event("contentTypeChanged"));
+ }
+ }
+
+ private var _binaryData:BinaryData;
+ public function get binaryData():BinaryData
+ {
+ return _binaryData;
+ }
+ public function set binaryData(value:BinaryData):void
+ {
+ if (_binaryData != value)
+ {
+ _binaryData = value;
+ dispatchEvent(new Event("binaryDataChanged"));
+ }
+ }
+
+ private var _headers:Array;
+ public function get headers():Array
+ {
+ if (_headers == null)
+ _headers = [];
+ return _headers;
+ }
+ public function set headers(value:Array):void
+ {
+ if (_headers != value)
+ {
+ _headers = value;
+ dispatchEvent(new Event("headersChanged"));
+ }
+ }
+
+ private var _method:String = HTTP_METHOD_POST;
+ public function get method():String
+ {
+ return _method;
+ }
+ public function set method(value:String):void
+ {
+ if (_method != value)
+ {
+ _method = value;
+ dispatchEvent(new Event("methodChanged"));
+ }
+ }
+
+ private var _responseHeaders:Array;
+ public function get responseHeaders():Array
+ {
+ if (_responseHeaders && _responseHeaders.length > 0)
+ {
+ if (_responseHeaders[0] is URLRequestHeader)
+ {
+ var n:int = _responseHeaders.length;
+ for (var i:int = 0; i < n; i++)
+ {
+ var old:URLRequestHeader = _responseHeaders[i];
+ var nu:HTTPHeader = new HTTPHeader(old.name, old.value);
+ _responseHeaders[i] = nu;
+ }
+ }
+ }
+ return _responseHeaders;
+ }
+
+ private var _responseURL:String;
+ public function get responseURL():String
+ {
+ return _responseURL;
+ }
+
+ private var _status:int;
+ public function get status():int
+ {
+ return _status;
+ }
+
+ private var _url:String;
+ public function get url():String
+ {
+ return _url;
+ }
+ public function set url(value:String):void
+ {
+ if (_url != value)
+ {
+ _url = value;
+ dispatchEvent(new Event("urlChanged"));
+ }
+ }
+
+ private var _timeout:Number = 0;
+ public function get timeout():Number
+ {
+ return _timeout;
+ }
+ public function set timeout(value:Number):void
+ {
+ if (_timeout != value)
+ {
+ _timeout = value;
+ dispatchEvent(new Event("timeoutChanged"));
+ }
+ }
+
+ private var _id:String;
+ public function get id():String
+ {
+ return _id;
+ }
+ public function set id(value:String):void
+ {
+ if (_id != value)
+ {
+ _id = value;
+ dispatchEvent(new Event("idChanged"));
+ }
+ }
+
+ private var _strand:IStrand;
+
+ public function set strand(value:IStrand):void
+ {
+ _strand = value;
+ }
+
+ // beads declared in MXML are added to the strand.
+ // from AS, just call addBead()
+ public var beads:Array;
+
+ private var _beads:Vector.<IBead>;
+ public function addBead(bead:IBead):void
+ {
+ if (!_beads)
+ _beads = new Vector.<IBead>;
+ _beads.push(bead);
+ bead.strand = this;
+ }
+
+ public function getBeadByType(classOrInterface:Class):IBead
+ {
+ for each (var bead:IBead in _beads)
+ {
+ if (bead is classOrInterface)
+ return bead;
+ }
+ return null;
+ }
+
+ public function removeBead(value:IBead):IBead
+ {
+ var n:int = _beads.length;
+ for (var i:int = 0; i < n; i++)
+ {
+ var bead:IBead = _beads[i];
+ if (bead == value)
+ {
+ _beads.splice(i, 1);
+ return bead;
+ }
+ }
+ return null;
+ }
+
+ private var urlLoader:URLLoader;
+
+ public function send():void
+ {
+ if (!urlLoader)
+ urlLoader = new URLLoader();
+ var request:URLRequest = new URLRequest(url);
+ request.method = method;
+ if ("idleTimeout" in request)
+ {
+ request["idleTimeout"] = timeout;
+ }
+ var sawContentType:Boolean;
+ if (headers)
+ {
+ for each (var header:HTTPHeader in headers)
+ {
+ var urlHeader:URLRequestHeader = new URLRequestHeader(header.name, header.value);
+ request.requestHeaders.push(urlHeader);
+ if (header.name == HTTPHeader.CONTENT_TYPE)
+ sawContentType = true;
+ }
+ }
+ if (method != HTTP_METHOD_GET && !sawContentType)
+ {
+ urlHeader = new URLRequestHeader(HTTPHeader.CONTENT_TYPE, contentType);
+ request.requestHeaders.push(urlHeader);
+ }
+ if (binaryData)
+ {
+ if (method == HTTP_METHOD_GET)
+ {
+ if (url.indexOf("?") != -1)
+ url += binaryData.data.toString();
+ else
+ url += "?" + binaryData.data.toString();
+ }
+ else
+ request.data = binaryData.data;
+ }
+ urlLoader.addEventListener(flash.events.Event.COMPLETE, completeHandler);
+ urlLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
+ if (HTTPStatusEvent.HTTP_RESPONSE_STATUS) // only on AIR
+ urlLoader.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, statusHandler);
+ urlLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, statusHandler);
+ urlLoader.load(request);
+ }
+
+ protected function statusHandler(event:HTTPStatusEvent):void
+ {
+ _status = event.status;
+ if ("responseHeaders" in event)
+ _responseHeaders = event.responseHeaders;
+ if ("responseURL" in event)
+ _responseURL = event.responseURL;
+ dispatchEvent(new Event(event.type));
+ }
+
+ protected function ioErrorHandler(event:IOErrorEvent):void
+ {
+ dispatchEvent(new Event(event.type));
+ }
+
+ protected function completeHandler(event:flash.events.Event):void
+ {
+ dispatchEvent(new Event(event.type));
+ }
+
+ public function get data():*
+ {
+ return urlLoader.data;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0991467e/frameworks/as/src/org/apache/flex/utils/BinaryData.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/utils/BinaryData.as b/frameworks/as/src/org/apache/flex/utils/BinaryData.as
new file mode 100644
index 0000000..48cfd00
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/utils/BinaryData.as
@@ -0,0 +1,106 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.utils
+{
+ import flash.utils.ByteArray;
+
+public class BinaryData
+{
+ public function BinaryData()
+ {
+
+ }
+
+ private var ba:ByteArray = new ByteArray();
+
+ /**
+ * Get the platform-specific data for sending.
+ * Generally only used by the network services.
+ */
+ public function get data():Object
+ {
+ return ba;
+ }
+
+ public function writeByte(byte:int):void
+ {
+ ba.writeByte(byte);
+ }
+
+ public function writeShort(byte:int):void
+ {
+ ba.writeShort(byte);
+ }
+
+ public function writeUnsignedInt(byte:uint):void
+ {
+ ba.writeUnsignedInt(byte);
+ }
+
+ public function writeInt(byte:uint):void
+ {
+ ba.writeInt(byte);
+ }
+
+ public function readByte():int
+ {
+ return ba.readByte();
+ }
+
+ public function readShort():int
+ {
+ return ba.readShort();
+ }
+
+ public function readUnsignedInt():uint
+ {
+ return ba.readUnsignedInt();
+ }
+
+ public function readInt():int
+ {
+ return ba.readInt();
+ }
+
+ public function get length():int
+ {
+ return ba.length;
+ }
+
+ public function get bytesAvailable():int
+ {
+ return ba.bytesAvailable;
+ }
+
+ public function get position():int
+ {
+ return ba.position;
+ }
+
+ public function set position(value:int):void
+ {
+ ba.position = value;
+ }
+
+ public function growBuffer(extra:int):void
+ {
+ // no need to do anything in AS
+ }
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0991467e/frameworks/js/FlexJS/src/org/apache/flex/net/BinaryUploader.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/net/BinaryUploader.js b/frameworks/js/FlexJS/src/org/apache/flex/net/BinaryUploader.js
new file mode 100644
index 0000000..448ced0
--- /dev/null
+++ b/frameworks/js/FlexJS/src/org/apache/flex/net/BinaryUploader.js
@@ -0,0 +1,429 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the 'License');
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an 'AS IS' BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+goog.provide('org.apache.flex.net.BinaryUploader');
+
+goog.require('org.apache.flex.core.HTMLElementWrapper');
+goog.require('org.apache.flex.net.HTTPHeader');
+
+
+
+/**
+ * @constructor
+ * @extends {org.apache.flex.core.HTMLElementWrapper}
+ */
+org.apache.flex.net.BinaryUploader = function() {
+ goog.base(this);
+
+ /**
+ * @protected
+ * @type {string}
+ */
+ this.url_;
+
+ /**
+ * @private
+ * @type {Number}
+ */
+ this.status_;
+
+ /**
+ * @private
+ * @type {string}
+ */
+ this.method_ = 'POST';
+
+ /**
+ * @private
+ * @type {Array}
+ */
+ this.headers_;
+
+ /**
+ * @private
+ * @type {Array}
+ */
+ this.responseHeaders_;
+
+ /**
+ * @private
+ * @type {string}
+ */
+ this.responseURL_;
+
+ /**
+ * @private
+ * @type {Number}
+ */
+ this.timeout_ = 0;
+
+ /**
+ * @private
+ * @type {string}
+ */
+ this.binaryData_;
+
+ /**
+ * @private
+ * @type {string}
+ */
+ this.contentType_ = 'application/octet-stream';
+
+ //try { // (erikdebruin) 'desperate' attempt to bypass XDR security in IE < 10
+ // this.contentType_ = 'text/plain';
+ // this.element = new XDomainRequest();
+ //} catch (e) {}
+
+ this.element = new XMLHttpRequest();
+};
+goog.inherits(org.apache.flex.net.BinaryUploader,
+ org.apache.flex.core.HTMLElementWrapper);
+
+
+/**
+ * @expose
+ * @type {string}
+ */
+org.apache.flex.net.BinaryUploader.HTTP_METHOD_GET = 'GET';
+
+
+/**
+ * @expose
+ * @type {string}
+ */
+org.apache.flex.net.BinaryUploader.HTTP_METHOD_POST = 'POST';
+
+
+/**
+ * @expose
+ * @type {string}
+ */
+org.apache.flex.net.BinaryUploader.HTTP_METHOD_PUT = 'PUT';
+
+
+/**
+ * @expose
+ * @type {string}
+ */
+org.apache.flex.net.BinaryUploader.HTTP_METHOD_DELETE = 'DELETE';
+
+
+/**
+ * @expose
+ * @this {org.apache.flex.net.BinaryUploader}
+ * @return {string} value The data.
+ */
+org.apache.flex.net.BinaryUploader.prototype.get_data = function() {
+ return this.element.responseText;
+};
+
+
+/**
+ * @expose
+ * @this {org.apache.flex.net.BinaryUploader}
+ * @return {org.apache.flex.utils.BinaryData} value The binary Data.
+ */
+org.apache.flex.net.BinaryUploader.prototype.get_binaryData = function() {
+ return this.binaryData_;
+};
+
+
+/**
+ * @expose
+ * @this {org.apache.flex.net.BinaryUploader}
+ * @param {org.apache.flex.utils.BinaryData} value The binary Data.
+ */
+org.apache.flex.net.BinaryUploader.prototype.set_binaryData = function(value) {
+ this.binaryData_ = value;
+};
+
+
+/**
+ * @expose
+ * @this {org.apache.flex.net.BinaryUploader}
+ * @return {string} value The contentType.
+ */
+org.apache.flex.net.BinaryUploader.prototype.get_contentType = function() {
+ return this.contentType_;
+};
+
+
+/**
+ * @expose
+ * @this {org.apache.flex.net.BinaryUploader}
+ * @param {string} value The contentType.
+ */
+org.apache.flex.net.BinaryUploader.prototype.set_contentType = function(value) {
+ this.contentType_ = value;
+};
+
+
+/**
+ * @expose
+ * @this {org.apache.flex.net.BinaryUploader}
+ * @return {Array} value The array of HTTPHeaders.
+ */
+org.apache.flex.net.BinaryUploader.prototype.get_headers = function() {
+ if (this.headers_ === 'undefined') {
+ this.headers_ = [];
+ }
+
+ return this.headers_;
+};
+
+
+/**
+ * @expose
+ * @this {org.apache.flex.net.BinaryUploader}
+ * @param {Array} value The array of HTTPHeaders.
+ */
+org.apache.flex.net.BinaryUploader.prototype.set_headers = function(value) {
+ this.headers_ = value;
+};
+
+
+/**
+ * @expose
+ * @this {org.apache.flex.net.BinaryUploader}
+ * @return {string} value The method.
+ */
+org.apache.flex.net.BinaryUploader.prototype.get_method = function() {
+ return this.method_;
+};
+
+
+/**
+ * @expose
+ * @this {org.apache.flex.net.BinaryUploader}
+ * @param {string} value The method.
+ */
+org.apache.flex.net.BinaryUploader.prototype.set_method = function(value) {
+ this.method_ = value;
+};
+
+
+/**
+ * @expose
+ * @this {org.apache.flex.net.BinaryUploader}
+ * @return {Array} value The array of HTTPHeaders.
+ */
+org.apache.flex.net.BinaryUploader.prototype.get_responseHeaders = function() {
+ var allHeaders, c, hdr, i, n, part1, part2;
+
+ if (typeof this.responseHeaders_ === 'undefined') {
+ allHeaders = this.element.getAllResponseHeaders();
+ this.responseHeaders_ = allHeaders.split('\n');
+ n = this.responseHeaders_.length;
+ for (i = 0; i < n; i++) {
+ hdr = this.responseHeaders_[i];
+ c = hdr.indexOf(':');
+ part1 = hdr.substring(0, c);
+ part2 = hdr.substring(c + 2);
+ this.responseHeaders_[i] =
+ new org.apache.flex.net.HTTPHeader(part1, part2);
+ }
+ }
+ return this.responseHeaders_;
+};
+
+
+/**
+ * @expose
+ * @this {org.apache.flex.net.BinaryUploader}
+ * @return {string} value The url.
+ */
+org.apache.flex.net.BinaryUploader.prototype.get_responseURL = function() {
+ return this.responseURL_;
+};
+
+
+/**
+ * @expose
+ * @this {org.apache.flex.net.BinaryUploader}
+ * @return {Number} value The status.
+ */
+org.apache.flex.net.BinaryUploader.prototype.get_status = function() {
+ return this.status_;
+};
+
+
+/**
+ * @expose
+ * @this {org.apache.flex.net.BinaryUploader}
+ * @return {Number} value The timeout.
+ */
+org.apache.flex.net.BinaryUploader.prototype.get_timeout = function() {
+ return this.timeout_;
+};
+
+
+/**
+ * @expose
+ * @this {org.apache.flex.net.BinaryUploader}
+ * @param {Number} value The timeout.
+ */
+org.apache.flex.net.BinaryUploader.prototype.set_timeout = function(value) {
+ this.timeout_ = value;
+};
+
+
+/**
+ * @expose
+ * @this {org.apache.flex.net.BinaryUploader}
+ * @return {string} value The url.
+ */
+org.apache.flex.net.BinaryUploader.prototype.get_url = function() {
+ return this.url_;
+};
+
+
+/**
+ * @expose
+ * @this {org.apache.flex.net.BinaryUploader}
+ * @param {string} value The url to fetch.
+ */
+org.apache.flex.net.BinaryUploader.prototype.set_url = function(value) {
+ this.url_ = value;
+};
+
+
+/**
+ * @expose
+ * @this {org.apache.flex.net.BinaryUploader}
+ */
+org.apache.flex.net.BinaryUploader.prototype.send = function() {
+ var contentData, header, i, n, sawContentType, url;
+
+ this.element.onreadystatechange = goog.bind(this.progressHandler, this);
+
+ url = this.url_;
+
+ binaryData = null;
+ if (this.binaryData_ !== undefined) {
+ if (this.method_ === org.apache.flex.net.BinaryUploader.HTTP_METHOD_GET) {
+ if (url.indexOf('?') !== -1) {
+ url += this.binaryData_.get_data();
+ } else {
+ url += '?' + this.binaryData_.get_data();
+ }
+ } else {
+ binaryData = this.binaryData_.get_data();
+ }
+ }
+
+ this.element.open(this.method_, this.url_, true);
+ this.element.timeout = this.timeout_;
+
+ sawContentType = false;
+ if (this.headers_) {
+ n = this.headers_.length;
+ for (i = 0; i < n; i++) {
+ header = this.headers_[i];
+ if (header.name === org.apache.flex.net.HTTPHeader.CONTENT_TYPE) {
+ sawContentType = true;
+ }
+
+ this.element.setRequestHeader(header.name, header.value);
+ }
+ }
+
+ if (this.method_ !== org.apache.flex.net.BinaryUploader.HTTP_METHOD_GET &&
+ !sawContentType && binaryData) {
+ this.element.setRequestHeader(
+ org.apache.flex.net.HTTPHeader.CONTENT_TYPE, this.binaryType_);
+ }
+
+ if (binaryData) {
+ this.element.setRequestHeader('Content-length', binaryData.length);
+ this.element.setRequestHeader('Connection', 'close');
+ this.element.send(binaryData);
+ } else {
+ this.element.send();
+ }
+};
+
+
+/**
+ * @protected
+ * @this {org.apache.flex.net.BinaryUploader}
+ */
+org.apache.flex.net.BinaryUploader.prototype.progressHandler = function() {
+ if (this.element.readyState === 2) {
+ this.status_ = this.element.status;
+ this.dispatchEvent('httpResponseStatus');
+ this.dispatchEvent('httpStatus');
+ } else if (this.element.readyState === 4) {
+ this.dispatchEvent('complete');
+ }
+};
+
+
+/**
+ * @expose
+ * @type {string}
+ */
+org.apache.flex.net.BinaryUploader.prototype.id;
+
+
+/**
+ * @expose
+ * @this {org.apache.flex.net.BinaryUploader}
+ * @return {string} The id.
+ */
+org.apache.flex.net.BinaryUploader.prototype.get_id = function() {
+ return this.id;
+};
+
+
+/**
+ * @expose
+ * @this {org.apache.flex.net.BinaryUploader}
+ * @param {Object} value The new id.
+ */
+org.apache.flex.net.BinaryUploader.prototype.set_id = function(value) {
+ if (this.id !== value) {
+ this.id = value;
+ this.dispatchEvent('idChanged');
+ }
+};
+
+
+/**
+ * @expose
+ * @this {org.apache.flex.net.BinaryUploader}
+ * @return {Array} The array of descriptors.
+ */
+org.apache.flex.net.BinaryUploader.prototype.get_MXMLDescriptor = function() {
+ return null;
+};
+
+
+/**
+ * @expose
+ * @this {org.apache.flex.net.BinaryUploader}
+ * @return {Array} The array of properties.
+ */
+org.apache.flex.net.BinaryUploader.prototype.get_MXMLProperties = function() {
+ return null;
+};
+
+
+/**
+ * @this {org.apache.flex.net.BinaryUploader}
+ * @param {Object} document The MXML object.
+ * @param {string} id The id for the instance.
+ */
+org.apache.flex.net.BinaryUploader.prototype.setDocument = function(document, id) {
+ this.document = document;
+};
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0991467e/frameworks/js/FlexJS/src/org/apache/flex/utils/BinaryData.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/utils/BinaryData.js b/frameworks/js/FlexJS/src/org/apache/flex/utils/BinaryData.js
new file mode 100644
index 0000000..f503fb8
--- /dev/null
+++ b/frameworks/js/FlexJS/src/org/apache/flex/utils/BinaryData.js
@@ -0,0 +1,220 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+goog.provide('org.apache.flex.utils.BinaryData');
+
+/**
+ * @constructor
+ */
+org.apache.flex.utils.BinaryData = function() {
+
+ /**
+ * @private
+ * @type {ArrayBuffer}
+ */
+ this.data_ = new ArrayBuffer();
+
+ /**
+ * @private
+ * @type {number}
+ */
+ this.position_ = 0;
+
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.utils.BinaryData}
+ * @return {Object} The platform-specific data.
+ */
+org.apache.flex.utils.BinaryData.prototype.get_data = function() {
+ return this.data_;
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.utils.BinaryData}
+ * @param {number} b The byte to write.
+ */
+org.apache.flex.utils.BinaryData.prototype.writeByte = function(b) {
+ var view;
+
+ this.growBuffer(1);
+
+ view = new Int8Array(this.data_, this.position_, 1);
+ view[0] = b;
+ this.position_++;
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.utils.BinaryData}
+ * @param {number} s The 16-bit integer to write.
+ */
+org.apache.flex.utils.BinaryData.prototype.writeShort = function(s) {
+ var view;
+
+ this.growBuffer(2);
+
+ view = new Int16Array(this.data_, this.position_, 1);
+ view[0] = s;
+ this.position_ += 2;
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.utils.BinaryData}
+ * @param {number} num The 32-bit integer to write.
+ */
+org.apache.flex.utils.BinaryData.prototype.writeInt = function(num) {
+ var view;
+
+ this.growBuffer(4);
+
+ view = new Int32Array(this.data_, this.position_, 1);
+ view[0] = num;
+ this.position_ += 4;
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.utils.BinaryData}
+ * @param {number} num The 32-bit unsigned integer to write.
+ */
+org.apache.flex.utils.BinaryData.prototype.writeUnsignedInt =
+ function(num) {
+ var view;
+
+ this.growBuffer(4);
+
+ view = new Uint32Array(this.data_, this.position_, 1);
+ view[0] = num;
+ this.position_ += 4;
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.utils.BinaryData}
+ * @return {number} The byte that was read.
+ */
+org.apache.flex.utils.BinaryData.prototype.readByte = function() {
+ var view;
+
+ view = new Int8Array(this.data_, this.position_, 1);
+ this.position_++;
+ return view[0];
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.utils.BinaryData}
+ * @return {number} The 16-bit integer that was read.
+ */
+org.apache.flex.utils.BinaryData.prototype.readShort = function() {
+ var view;
+
+ view = new Int16Array(this.data_, this.position_, 1);
+ this.position_ += 2;
+ return view[0];
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.utils.BinaryData}
+ * @return {number} The 32-bit integer that was read.
+ */
+org.apache.flex.utils.BinaryData.prototype.readInteger = function() {
+ var view;
+
+ view = new Int32Array(this.data_, this.position_, 1);
+ this.position_ += 4;
+ return view[0];
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.utils.BinaryData}
+ * @return {number} The 32-bit unsigned integer that was read.
+ */
+org.apache.flex.utils.BinaryData.prototype.readUnsignedInteger =
+ function() {
+ var view;
+
+ view = new Uint32Array(this.data_, this.position_, 1);
+ this.position_ += 4;
+ return view[0];
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.utils.BinaryData}
+ * @return {number} The offset to write to or read from.
+ */
+org.apache.flex.utils.BinaryData.prototype.get_position = function() {
+ return this.position_;
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.utils.BinaryData}
+ * @param {number} value The offset to write to or read from.
+ */
+org.apache.flex.utils.BinaryData.prototype.set_position = function(value) {
+ this.position_ = value;
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.utils.BinaryData}
+ * @return {number} The offset to write to or read from.
+ */
+org.apache.flex.utils.BinaryData.prototype.get_length = function() {
+ return this.data_.byteLength;
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.utils.BinaryData}
+ * @return {number} The number of bytes that can still be read.
+ */
+org.apache.flex.utils.BinaryData.prototype.get_bytesAvailable = function() {
+ return this.data_.byteLength - this.position_;
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.utils.BinaryData}
+ * @param {number} extra The number of bytes to add to the buffer.
+ */
+org.apache.flex.utils.BinaryData.prototype.growBuffer = function(extra) {
+ var newBuffer, newView, view, i, n;
+
+ if (this.position_ >= this.data_.byteLength)
+ {
+ n = this.data_.byteLength;
+ newBuffer = new ArrayBuffer(n + extra);
+ newView = new Int8Array(newBuffer, 0, n);
+ view = new Int8Array(this.data_, 0, n);
+ for (i = 0; i < n; i++)
+ {
+ newView[i] = view[i];
+ }
+ this.data_ = newBuffer;
+ }
+};
+
+
+
+
+