This is an automated email from the ASF dual-hosted git repository.
carlosrovira pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/develop by this push:
new eb0bfb9 crux: added AMFStorageBean
eb0bfb9 is described below
commit eb0bfb9c465c79657cb3401c88ffb2e9ae510da6
Author: Carlos Rovira <[email protected]>
AuthorDate: Mon Feb 17 12:15:30 2020 +0100
crux: added AMFStorageBean
---
frameworks/projects/Crux/pom.xml | 14 ++
.../Crux/src/main/resources/crux-manifest.xml | 1 +
.../apache/royale/crux/storage/AMFStorageBean.as | 214 +++++++++++++++++++++
.../apache/royale/crux/storage/IAMFStorageBean.as | 142 ++++++++++++++
4 files changed, 371 insertions(+)
diff --git a/frameworks/projects/Crux/pom.xml b/frameworks/projects/Crux/pom.xml
index 4776684..8c2b25d 100644
--- a/frameworks/projects/Crux/pom.xml
+++ b/frameworks/projects/Crux/pom.xml
@@ -106,6 +106,13 @@
</dependency>
<dependency>
<groupId>org.apache.royale.framework</groupId>
+ <artifactId>Storage</artifactId>
+ <version>0.9.7-SNAPSHOT</version>
+ <type>swc</type>
+ <classifier>js</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.royale.framework</groupId>
<artifactId>Language</artifactId>
<version>0.9.7-SNAPSHOT</version>
<type>swc</type>
@@ -161,6 +168,13 @@
</dependency>
<dependency>
<groupId>org.apache.royale.framework</groupId>
+ <artifactId>Storage</artifactId>
+ <version>0.9.7-SNAPSHOT</version>
+ <type>swc</type>
+ <classifier>swf</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.royale.framework</groupId>
<artifactId>Language</artifactId>
<version>0.9.7-SNAPSHOT</version>
<type>swc</type>
diff --git a/frameworks/projects/Crux/src/main/resources/crux-manifest.xml
b/frameworks/projects/Crux/src/main/resources/crux-manifest.xml
index 37bc1c9..b54971b 100644
--- a/frameworks/projects/Crux/src/main/resources/crux-manifest.xml
+++ b/frameworks/projects/Crux/src/main/resources/crux-manifest.xml
@@ -22,6 +22,7 @@
<component id="CruxConfig" class="org.apache.royale.crux.CruxConfig"/>
<component id="BeanProvider" class="org.apache.royale.crux.BeanProvider"/>
<component id="Bean" class="org.apache.royale.crux.Bean"/>
+ <component id="AMFStorageBean"
class="org.apache.royale.crux.storage.AMFStorageBean"/>
<component id="JSStageEvents"
class="org.apache.royale.crux.beads.JSStageEvents"/>
</componentPackage>
diff --git
a/frameworks/projects/Crux/src/main/royale/org/apache/royale/crux/storage/AMFStorageBean.as
b/frameworks/projects/Crux/src/main/royale/org/apache/royale/crux/storage/AMFStorageBean.as
new file mode 100644
index 0000000..d2b05f9
--- /dev/null
+++
b/frameworks/projects/Crux/src/main/royale/org/apache/royale/crux/storage/AMFStorageBean.as
@@ -0,0 +1,214 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.royale.crux.storage
+{
+ import org.apache.royale.events.EventDispatcher;
+ import org.apache.royale.storage.AMFStorage;
+
+ public class AMFStorageBean extends EventDispatcher implements
IAMFStorageBean
+ {
+ private var storage:AMFStorage;
+
+ private var _path:String = "crux";
+ private var _name:String = "cruxAMFStorage";
+
+ /**
+ * @inheritDoc
+ */
+ public function set localPath( path:String ):void
+ {
+ _path = path;
+ invalidate();
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function set name( name:String ):void
+ {
+ _name = name;
+ invalidate();
+ }
+
+ /**
+ * @inheritDoc
+ */
+ // public function get size():Number
+ // {
+ // if( storage != null )
+ // {
+ // return storage.size
+ // }
+ // return NaN;
+ // }
+
+ public function AMFStorageBean()
+ {
+ super();
+ invalidate();
+ }
+
+ protected function invalidate():void
+ {
+ storage = AMFStorage.getLocal( _name, _path );
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function clear():void
+ {
+ storage.clear();
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function hasValue( name:String ):Boolean
+ {
+ return storage.data[name] != undefined;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getValue( name:String, initValue:* = null ):*
+ {
+ var o:Object = storage.data;
+ if( o[name] == null && initValue != null )
+ {
+ o[name] = initValue;
+ storage.save();
+ }
+
+ return o[name];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function setValue( name:String, value:* ):void
+ {
+ var o:Object = storage.data;
+ o[name] = value;
+ storage.save();
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getString( name:String, initValue:String = null
):String
+ {
+ var o:Object = storage.data;
+ if( o[name] == null && initValue != null )
+ {
+ o[name] = initValue;
+ storage.save();
+ }
+
+ return o[name];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function setString( name:String, value:String ):void
+ {
+ var o:Object = storage.data;
+ o[name] = value;
+ storage.save();
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getBoolean( name:String, initValue:Boolean =
false ):Boolean
+ {
+ var o:Object = storage.data;
+ if( o[name] == null )
+ {
+ o[name] = initValue;
+ storage.save();
+ }
+
+ return o[name];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function setBoolean( name:String, value:Boolean ):void
+ {
+ var o:Object = storage.data;
+ o[name] = value;
+ storage.save();
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getNumber( name:String, initValue:Number = NaN
):Number
+ {
+ var o:Object = storage.data;
+ if( o[name] == null )
+ {
+ o[name] = initValue;
+ storage.save();
+ }
+
+ return o[name];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function setNumber( name:String, value:Number ):void
+ {
+ var o:Object = storage.data;
+ o[name] = value;
+ storage.save();
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getInt( name:String, initValue:int = -1 ):int
+ {
+ var o:Object = storage.data;
+ if( o[name] == null )
+ {
+ o[name] = initValue;
+ storage.save();
+ }
+
+ return o[name];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function setInt( name:String, value:int ):void
+ {
+ var o:Object = storage.data;
+ o[name] = value;
+ storage.save();
+ dispatchEvent( new Event( "intChange" ) );
+ }
+ }
+}
\ No newline at end of file
diff --git
a/frameworks/projects/Crux/src/main/royale/org/apache/royale/crux/storage/IAMFStorageBean.as
b/frameworks/projects/Crux/src/main/royale/org/apache/royale/crux/storage/IAMFStorageBean.as
new file mode 100644
index 0000000..13ee368
--- /dev/null
+++
b/frameworks/projects/Crux/src/main/royale/org/apache/royale/crux/storage/IAMFStorageBean.as
@@ -0,0 +1,142 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.royale.crux.storage
+{
+ public interface IAMFStorageBean
+ {
+ /**
+ *
+ * @param path AMFStorage localPath value. default is "/"
+ *
+ */
+ function set localPath( path : String ):void;
+
+ /**
+ *
+ * @param name AMFStorage name value.
+ *
+ */
+ function set name( name : String ):void;
+
+ /**
+ *
+ * @return Size of the AMFStorage
+ *
+ */
+ // function get size():Number;
+
+ /**
+ * clears the AMFStorage data
+ */
+ function clear():void;
+
+ /**
+ *
+ * @param name Name of the value
+ * @return True if the value already exists. False if the value
does not exist.
+ *
+ */
+ function hasValue( name : String ):Boolean;
+
+ /**
+ *
+ * @param name Value name
+ * @param initValue Optional initial value. Default is null.
+ * @return Untyped value
+ *
+ */
+ function getValue( name : String, initValue : * = null ):*;
+
+ /**
+ *
+ * @param name Value name
+ * @param value String value
+ *
+ */
+ function setValue( name : String, value : * ):void;
+
+ /**
+ *
+ * @param name Value name
+ * @param initValue Optional initial value. Default is null.
+ * @return String value
+ *
+ */
+ function getString( name : String, initValue : String = null
):String;
+
+ /**
+ *
+ * @param name Value name
+ * @param value String value
+ *
+ */
+ function setString( name : String, value : String ):void;
+
+ /**
+ *
+ * @param name Value name
+ * @param initValue Optional initial value. Default is false.
+ * @return Boolean value
+ *
+ */
+ function getBoolean( name : String, initValue : Boolean = false
):Boolean;
+
+ /**
+ *
+ * @param name Value name
+ * @param value Boolean value
+ *
+ */
+ function setBoolean( name : String, value : Boolean ):void;
+
+ /**
+ *
+ * @param name Value name
+ * @param initValue Optional initial value. Default is NaN.
+ * @return Number value
+ *
+ */
+ function getNumber( name : String, initValue : Number = NaN
):Number;
+
+ /**
+ *
+ * @param name Value name
+ * @param value Number value
+ *
+ */
+ function setNumber( name : String, value : Number ):void;
+
+ /**
+ *
+ * @param name Value name
+ * @param initValue Optional initial value. Default is -1.
+ * @return Integer value
+ *
+ */
+ function getInt( name : String, initValue : int = -1 ):int;
+
+ /**
+ *
+ * @param name Value name
+ * @param value Integer value
+ *
+ */
+ function setInt( name : String, value : int ):void;
+ }
+}
\ No newline at end of file