flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject svn commit: r1442818 - in /flex/asjs/branches/develop/frameworks/as/src/org/apache/flex: data/ net/ net/dataConverters/
Date Wed, 06 Feb 2013 00:49:45 GMT
Author: aharui
Date: Wed Feb  6 00:49:44 2013
New Revision: 1442818

URL: http://svn.apache.org/viewvc?rev=1442818&view=rev
Log:
HTTPService and LazyCollection

Added:
    flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/data/
    flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/data/ICollection.as   (with
props)
    flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/data/IStringCollection.as
  (with props)
    flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/
    flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/HTTPService.as
    flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/IInputParser.as   (with
props)
    flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/IItemConverter.as   (with
props)
    flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/JSONInputParser.as  
(with props)
    flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/JSONItemConverter.as
  (with props)
    flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/dataConverters/
    flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/dataConverters/LazyCollection.as
  (with props)

Added: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/data/ICollection.as
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/data/ICollection.as?rev=1442818&view=auto
==============================================================================
--- flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/data/ICollection.as (added)
+++ flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/data/ICollection.as Wed Feb
 6 00:49:44 2013
@@ -0,0 +1,25 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.data
+{
+	public interface ICollection
+	{
+		function getItemAt(index:int):Object
+	}
+}
\ No newline at end of file

Propchange: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/data/ICollection.as
------------------------------------------------------------------------------
    svn:eol-style = native

Added: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/data/IStringCollection.as
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/data/IStringCollection.as?rev=1442818&view=auto
==============================================================================
--- flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/data/IStringCollection.as
(added)
+++ flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/data/IStringCollection.as
Wed Feb  6 00:49:44 2013
@@ -0,0 +1,25 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.data
+{
+	public interface IStringCollection
+	{
+		function getItemAt(index:int):String
+	}
+}
\ No newline at end of file

Propchange: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/data/IStringCollection.as
------------------------------------------------------------------------------
    svn:eol-style = native

Added: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/HTTPService.as
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/HTTPService.as?rev=1442818&view=auto
==============================================================================
--- flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/HTTPService.as (added)
+++ flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/HTTPService.as Wed Feb
 6 00:49:44 2013
@@ -0,0 +1,122 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.Event;
+	import flash.events.EventDispatcher;
+	import flash.net.URLLoader;
+	import flash.net.URLRequest;
+	
+	import org.apache.flex.core.IBead;
+	import org.apache.flex.core.IStrand;
+    
+	public class HTTPService extends EventDispatcher implements IStrand
+	{
+		public function HTTPService()
+		{
+			super();
+		}
+		
+		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 _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"));
+			}
+		}
+		
+		// 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();
+            urlLoader.load(new URLRequest(url));
+            urlLoader.addEventListener(Event.COMPLETE, completeHandler);
+        }
+        
+        protected function completeHandler(event:Event):void
+        {
+            dispatchEvent(event);
+        }
+        
+        public function get data():*
+        {
+            return urlLoader.data;
+        }
+    }
+}
\ No newline at end of file

Added: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/IInputParser.as
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/IInputParser.as?rev=1442818&view=auto
==============================================================================
--- flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/IInputParser.as (added)
+++ flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/IInputParser.as Wed Feb
 6 00:49:44 2013
@@ -0,0 +1,25 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+{
+	public interface IInputParser
+	{
+		function parseItems(s:String):Array;
+	}
+}
\ No newline at end of file

Propchange: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/IInputParser.as
------------------------------------------------------------------------------
    svn:eol-style = native

Added: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/IItemConverter.as
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/IItemConverter.as?rev=1442818&view=auto
==============================================================================
--- flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/IItemConverter.as (added)
+++ flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/IItemConverter.as Wed
Feb  6 00:49:44 2013
@@ -0,0 +1,25 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+{
+	public interface IItemConverter
+	{
+		function convertItem(data:String):Object
+	}
+}
\ No newline at end of file

Propchange: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/IItemConverter.as
------------------------------------------------------------------------------
    svn:eol-style = native

Added: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/JSONInputParser.as
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/JSONInputParser.as?rev=1442818&view=auto
==============================================================================
--- flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/JSONInputParser.as (added)
+++ flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/JSONInputParser.as Wed
Feb  6 00:49:44 2013
@@ -0,0 +1,37 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 org.apache.flex.core.IBead;
+    import org.apache.flex.core.ISelectionModel;
+    import org.apache.flex.core.IStrand;
+    import org.apache.flex.core.UIBase;
+    import org.apache.flex.html.staticControls.beads.SingleLineBorderBead;
+    import org.apache.flex.html.staticControls.beads.models.SingleLineBorderModel;
+    import org.apache.flex.html.staticControls.supportClasses.Border;
+    import org.apache.flex.html.staticControls.supportClasses.NonVirtualDataGroup;
+
+	public class JSONInputParser implements IInputParser
+	{        
+		public function parseItems(s:String):Array
+        {
+            return s.split("},");
+        }
+	}
+}
\ No newline at end of file

Propchange: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/JSONInputParser.as
------------------------------------------------------------------------------
    svn:eol-style = native

Added: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/JSONItemConverter.as
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/JSONItemConverter.as?rev=1442818&view=auto
==============================================================================
--- flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/JSONItemConverter.as
(added)
+++ flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/JSONItemConverter.as
Wed Feb  6 00:49:44 2013
@@ -0,0 +1,30 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 org.apache.flex.net.IItemConverter;
+    
+	public class JSONItemConverter implements IItemConverter
+	{
+		public function convertItem(data:String):Object
+        {
+            return JSON.parse(data);
+        }
+	}
+}
\ No newline at end of file

Propchange: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/JSONItemConverter.as
------------------------------------------------------------------------------
    svn:eol-style = native

Added: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/dataConverters/LazyCollection.as
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/dataConverters/LazyCollection.as?rev=1442818&view=auto
==============================================================================
--- flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/dataConverters/LazyCollection.as
(added)
+++ flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/dataConverters/LazyCollection.as
Wed Feb  6 00:49:44 2013
@@ -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.net.dataConverters
+{
+	import flash.events.Event;
+	import flash.events.EventDispatcher;
+	import flash.events.IEventDispatcher;
+	
+	import org.apache.flex.core.IBead;
+	import org.apache.flex.core.IStrand;
+	import org.apache.flex.data.ICollection;
+    import org.apache.flex.net.IInputParser;
+    import org.apache.flex.net.IItemConverter;
+    
+	public class LazyCollection extends EventDispatcher implements IBead, ICollection
+	{
+		public function LazyCollection()
+		{
+			super();
+		}
+		
+		private var _inputParser:IInputParser;
+		public function get inputParser():IInputParser
+		{
+			return _inputParser;
+		}
+		public function set inputParser(value:IInputParser):void
+		{
+			if (_inputParser != value)
+			{
+                _inputParser = value;
+				dispatchEvent(new Event("inputParserChanged"));
+			}
+		}
+		
+        private var _itemConverter:IItemConverter;
+        public function get itemConverter():IItemConverter
+        {
+            return _itemConverter;
+        }
+        public function set itemConverter(value:IItemConverter):void
+        {
+            if (_itemConverter != value)
+            {
+                _itemConverter = value;
+                dispatchEvent(new Event("itemConverterChanged"));
+            }
+        }
+
+        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;
+            IEventDispatcher(_strand).addEventListener(Event.COMPLETE, completeHandler);
+        }
+        
+        private var rawData:Array;
+        private var data:Array;
+        
+        private function completeHandler(event:Event):void
+        {
+            rawData = inputParser.parseItems(_strand["data"]);  
+            data = new Array(rawData.length);
+        }
+        
+        public function getItemAt(index:int):Object
+        {
+            if (data[index] == undefined)
+            {
+                data[index] = itemConverter.convertItem(rawData[index]);
+            }
+            return data[index];
+        }   
+	}
+}
\ No newline at end of file

Propchange: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/net/dataConverters/LazyCollection.as
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message