dango_generator 0.0.38
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +16 -0
- data/README.txt +41 -0
- data/dango_generator.rb +99 -0
- data/templates/as3/as3corelib-license.txt +33 -0
- data/templates/as3/as3corelib-readme.txt +5 -0
- data/templates/as3/com/adobe/crypto/MD5.as +256 -0
- data/templates/as3/com/adobe/crypto/SHA1.as +268 -0
- data/templates/as3/com/adobe/crypto/SHA224.as +255 -0
- data/templates/as3/com/adobe/crypto/SHA256.as +260 -0
- data/templates/as3/com/adobe/crypto/WSSEUsernameToken.as +117 -0
- data/templates/as3/com/adobe/errors/IllegalStateError.as +66 -0
- data/templates/as3/com/adobe/images/BitString.as +42 -0
- data/templates/as3/com/adobe/images/JPGEncoder.as +651 -0
- data/templates/as3/com/adobe/images/PNGEncoder.as +144 -0
- data/templates/as3/com/adobe/net/DynamicURLLoader.as +58 -0
- data/templates/as3/com/adobe/net/IURIResolver.as +79 -0
- data/templates/as3/com/adobe/net/URI.as +2469 -0
- data/templates/as3/com/adobe/net/URIEncodingBitmap.as +142 -0
- data/templates/as3/com/adobe/net/proxies/RFC2817Socket.as +204 -0
- data/templates/as3/com/adobe/serialization/json/JSON.as +88 -0
- data/templates/as3/com/adobe/serialization/json/JSONDecoder.as +218 -0
- data/templates/as3/com/adobe/serialization/json/JSONEncoder.as +302 -0
- data/templates/as3/com/adobe/serialization/json/JSONParseError.as +90 -0
- data/templates/as3/com/adobe/serialization/json/JSONToken.as +107 -0
- data/templates/as3/com/adobe/serialization/json/JSONTokenType.as +70 -0
- data/templates/as3/com/adobe/serialization/json/JSONTokenizer.as +550 -0
- data/templates/as3/com/adobe/utils/ArrayUtil.as +190 -0
- data/templates/as3/com/adobe/utils/DateUtil.as +666 -0
- data/templates/as3/com/adobe/utils/DictionaryUtil.as +90 -0
- data/templates/as3/com/adobe/utils/IntUtil.as +69 -0
- data/templates/as3/com/adobe/utils/NumberFormatter.as +77 -0
- data/templates/as3/com/adobe/utils/StringUtil.as +257 -0
- data/templates/as3/com/adobe/utils/XMLUtil.as +171 -0
- data/templates/as3/com/adobe/webapis/ServiceBase.as +51 -0
- data/templates/as3/com/adobe/webapis/URLLoaderBase.as +111 -0
- data/templates/as3/com/adobe/webapis/events/ServiceEvent.as +78 -0
- data/templates/as3/org/rubyforge/dango/DangoClientFramework.as +426 -0
- data/templates/as3/org/rubyforge/dango/DangoError.as +11 -0
- data/templates/as3/org/rubyforge/dango/DangoErrorCode.as +7 -0
- data/templates/as3/org/rubyforge/dango/DangoErrorEvent.as +23 -0
- data/templates/as3/org/rubyforge/dango/DangoReceiveEvent.as +21 -0
- data/templates/as3/org/rubyforge/dango/DangoURLLoader.as +127 -0
- data/templates/as3/org/rubyforge/dango/DangoURLLoaderEvent.as +29 -0
- data/templates/as3/org/rubyforge/dango/DangoUtil.as +84 -0
- data/templates/dango/config/development.yml +28 -0
- data/templates/dango/config/production.yml +3 -0
- data/templates/dango/config/system_message.yml +5 -0
- data/templates/dango/config/test.yml +3 -0
- data/templates/dango/server/99_dango_server.rb +22 -0
- data/templates/lib/dango_monitor_client.rb +1 -0
- data/templates/lib/dango_tester_client.rb +1 -0
- data/templates/script/dango_server +36 -0
- data/templates/tasks/dango.rake +2 -0
- metadata +108 -0
@@ -0,0 +1,90 @@
|
|
1
|
+
/*
|
2
|
+
Adobe Systems Incorporated(r) Source Code License Agreement
|
3
|
+
Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved.
|
4
|
+
|
5
|
+
Please read this Source Code License Agreement carefully before using
|
6
|
+
the source code.
|
7
|
+
|
8
|
+
Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive,
|
9
|
+
no-charge, royalty-free, irrevocable copyright license, to reproduce,
|
10
|
+
prepare derivative works of, publicly display, publicly perform, and
|
11
|
+
distribute this source code and such derivative works in source or
|
12
|
+
object code form without any attribution requirements.
|
13
|
+
|
14
|
+
The name "Adobe Systems Incorporated" must not be used to endorse or promote products
|
15
|
+
derived from the source code without prior written permission.
|
16
|
+
|
17
|
+
You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and
|
18
|
+
against any loss, damage, claims or lawsuits, including attorney's
|
19
|
+
fees that arise or result from your use or distribution of the source
|
20
|
+
code.
|
21
|
+
|
22
|
+
THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT
|
23
|
+
ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
|
24
|
+
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
25
|
+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF
|
26
|
+
NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA
|
27
|
+
OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
28
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
29
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
30
|
+
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
31
|
+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
32
|
+
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF
|
33
|
+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
|
+
*/
|
35
|
+
|
36
|
+
package com.adobe.utils
|
37
|
+
{
|
38
|
+
import flash.utils.Dictionary;
|
39
|
+
|
40
|
+
public class DictionaryUtil
|
41
|
+
{
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Returns an Array of all keys within the specified dictionary.
|
45
|
+
*
|
46
|
+
* @param d The Dictionary instance whose keys will be returned.
|
47
|
+
*
|
48
|
+
* @return Array of keys contained within the Dictionary
|
49
|
+
*
|
50
|
+
* @langversion ActionScript 3.0
|
51
|
+
* @playerversion Flash 9.0
|
52
|
+
* @tiptext
|
53
|
+
*/
|
54
|
+
public static function getKeys(d:Dictionary):Array
|
55
|
+
{
|
56
|
+
var a:Array = new Array();
|
57
|
+
|
58
|
+
for (var key:Object in d)
|
59
|
+
{
|
60
|
+
a.push(key);
|
61
|
+
}
|
62
|
+
|
63
|
+
return a;
|
64
|
+
}
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Returns an Array of all values within the specified dictionary.
|
68
|
+
*
|
69
|
+
* @param d The Dictionary instance whose values will be returned.
|
70
|
+
*
|
71
|
+
* @return Array of values contained within the Dictionary
|
72
|
+
*
|
73
|
+
* @langversion ActionScript 3.0
|
74
|
+
* @playerversion Flash 9.0
|
75
|
+
* @tiptext
|
76
|
+
*/
|
77
|
+
public static function getValues(d:Dictionary):Array
|
78
|
+
{
|
79
|
+
var a:Array = new Array();
|
80
|
+
|
81
|
+
for each (var value:Object in d)
|
82
|
+
{
|
83
|
+
a.push(value);
|
84
|
+
}
|
85
|
+
|
86
|
+
return a;
|
87
|
+
}
|
88
|
+
|
89
|
+
}
|
90
|
+
}
|
@@ -0,0 +1,69 @@
|
|
1
|
+
|
2
|
+
package com.adobe.utils {
|
3
|
+
|
4
|
+
import flash.utils.Endian;
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Contains reusable methods for operations pertaining
|
8
|
+
* to int values.
|
9
|
+
*/
|
10
|
+
public class IntUtil {
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Rotates x left n bits
|
14
|
+
*
|
15
|
+
* @langversion ActionScript 3.0
|
16
|
+
* @playerversion Flash 9.0
|
17
|
+
* @tiptext
|
18
|
+
*/
|
19
|
+
public static function rol ( x:int, n:int ):int {
|
20
|
+
return ( x << n ) | ( x >>> ( 32 - n ) );
|
21
|
+
}
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Rotates x right n bits
|
25
|
+
*
|
26
|
+
* @langversion ActionScript 3.0
|
27
|
+
* @playerversion Flash 9.0
|
28
|
+
* @tiptext
|
29
|
+
*/
|
30
|
+
public static function ror ( x:int, n:int ):uint {
|
31
|
+
var nn:int = 32 - n;
|
32
|
+
return ( x << nn ) | ( x >>> ( 32 - nn ) );
|
33
|
+
}
|
34
|
+
|
35
|
+
/** String for quick lookup of a hex character based on index */
|
36
|
+
private static var hexChars:String = "0123456789abcdef";
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Outputs the hex value of a int, allowing the developer to specify
|
40
|
+
* the endinaness in the process. Hex output is lowercase.
|
41
|
+
*
|
42
|
+
* @param n The int value to output as hex
|
43
|
+
* @param bigEndian Flag to output the int as big or little endian
|
44
|
+
* @return A string of length 8 corresponding to the
|
45
|
+
* hex representation of n ( minus the leading "0x" )
|
46
|
+
* @langversion ActionScript 3.0
|
47
|
+
* @playerversion Flash 9.0
|
48
|
+
* @tiptext
|
49
|
+
*/
|
50
|
+
public static function toHex( n:int, bigEndian:Boolean = false ):String {
|
51
|
+
var s:String = "";
|
52
|
+
|
53
|
+
if ( bigEndian ) {
|
54
|
+
for ( var i:int = 0; i < 4; i++ ) {
|
55
|
+
s += hexChars.charAt( ( n >> ( ( 3 - i ) * 8 + 4 ) ) & 0xF )
|
56
|
+
+ hexChars.charAt( ( n >> ( ( 3 - i ) * 8 ) ) & 0xF );
|
57
|
+
}
|
58
|
+
} else {
|
59
|
+
for ( var x:int = 0; x < 4; x++ ) {
|
60
|
+
s += hexChars.charAt( ( n >> ( x * 8 + 4 ) ) & 0xF )
|
61
|
+
+ hexChars.charAt( ( n >> ( x * 8 ) ) & 0xF );
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
return s;
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
}
|
@@ -0,0 +1,77 @@
|
|
1
|
+
/*
|
2
|
+
Adobe Systems Incorporated(r) Source Code License Agreement
|
3
|
+
Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved.
|
4
|
+
|
5
|
+
Please read this Source Code License Agreement carefully before using
|
6
|
+
the source code.
|
7
|
+
|
8
|
+
Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive,
|
9
|
+
no-charge, royalty-free, irrevocable copyright license, to reproduce,
|
10
|
+
prepare derivative works of, publicly display, publicly perform, and
|
11
|
+
distribute this source code and such derivative works in source or
|
12
|
+
object code form without any attribution requirements.
|
13
|
+
|
14
|
+
The name "Adobe Systems Incorporated" must not be used to endorse or promote products
|
15
|
+
derived from the source code without prior written permission.
|
16
|
+
|
17
|
+
You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and
|
18
|
+
against any loss, damage, claims or lawsuits, including attorney's
|
19
|
+
fees that arise or result from your use or distribution of the source
|
20
|
+
code.
|
21
|
+
|
22
|
+
THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT
|
23
|
+
ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
|
24
|
+
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
25
|
+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF
|
26
|
+
NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA
|
27
|
+
OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
28
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
29
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
30
|
+
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
31
|
+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
32
|
+
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF
|
33
|
+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
|
+
*/
|
35
|
+
|
36
|
+
package com.adobe.utils
|
37
|
+
{
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Class that contains static utility methods for formatting Numbers
|
41
|
+
*
|
42
|
+
* @langversion ActionScript 3.0
|
43
|
+
* @playerversion Flash 9.0
|
44
|
+
* @tiptext
|
45
|
+
*
|
46
|
+
* @see #mx.formatters.NumberFormatter
|
47
|
+
*/
|
48
|
+
public class NumberFormatter
|
49
|
+
{
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Formats a number to include a leading zero if it is a single digit
|
53
|
+
* between -1 and 10.
|
54
|
+
*
|
55
|
+
* @param n The number that will be formatted
|
56
|
+
*
|
57
|
+
* @return A string with single digits between -1 and 10 padded with a
|
58
|
+
* leading zero.
|
59
|
+
*
|
60
|
+
* @langversion ActionScript 3.0
|
61
|
+
* @playerversion Flash 9.0
|
62
|
+
* @tiptext
|
63
|
+
*/
|
64
|
+
public static function addLeadingZero(n:Number):String
|
65
|
+
{
|
66
|
+
var out:String = String(n);
|
67
|
+
|
68
|
+
if(n < 10 && n > -1)
|
69
|
+
{
|
70
|
+
out = "0" + out;
|
71
|
+
}
|
72
|
+
|
73
|
+
return out;
|
74
|
+
}
|
75
|
+
|
76
|
+
}
|
77
|
+
}
|
@@ -0,0 +1,257 @@
|
|
1
|
+
/*
|
2
|
+
Adobe Systems Incorporated(r) Source Code License Agreement
|
3
|
+
Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved.
|
4
|
+
|
5
|
+
Please read this Source Code License Agreement carefully before using
|
6
|
+
the source code.
|
7
|
+
|
8
|
+
Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive,
|
9
|
+
no-charge, royalty-free, irrevocable copyright license, to reproduce,
|
10
|
+
prepare derivative works of, publicly display, publicly perform, and
|
11
|
+
distribute this source code and such derivative works in source or
|
12
|
+
object code form without any attribution requirements.
|
13
|
+
|
14
|
+
The name "Adobe Systems Incorporated" must not be used to endorse or promote products
|
15
|
+
derived from the source code without prior written permission.
|
16
|
+
|
17
|
+
You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and
|
18
|
+
against any loss, damage, claims or lawsuits, including attorney's
|
19
|
+
fees that arise or result from your use or distribution of the source
|
20
|
+
code.
|
21
|
+
|
22
|
+
THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT
|
23
|
+
ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
|
24
|
+
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
25
|
+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF
|
26
|
+
NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA
|
27
|
+
OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
28
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
29
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
30
|
+
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
31
|
+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
32
|
+
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF
|
33
|
+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
|
+
*/
|
35
|
+
|
36
|
+
package com.adobe.utils
|
37
|
+
{
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Class that contains static utility methods for manipulating Strings.
|
41
|
+
*
|
42
|
+
* @langversion ActionScript 3.0
|
43
|
+
* @playerversion Flash 9.0
|
44
|
+
* @tiptext
|
45
|
+
*/
|
46
|
+
public class StringUtil
|
47
|
+
{
|
48
|
+
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Does a case insensitive compare or two strings and returns true if
|
52
|
+
* they are equal.
|
53
|
+
*
|
54
|
+
* @param s1 The first string to compare.
|
55
|
+
*
|
56
|
+
* @param s2 The second string to compare.
|
57
|
+
*
|
58
|
+
* @returns A boolean value indicating whether the strings' values are
|
59
|
+
* equal in a case sensitive compare.
|
60
|
+
*
|
61
|
+
* @langversion ActionScript 3.0
|
62
|
+
* @playerversion Flash 9.0
|
63
|
+
* @tiptext
|
64
|
+
*/
|
65
|
+
public static function stringsAreEqual(s1:String, s2:String,
|
66
|
+
caseSensitive:Boolean):Boolean
|
67
|
+
{
|
68
|
+
if(caseSensitive)
|
69
|
+
{
|
70
|
+
return (s1 == s2);
|
71
|
+
}
|
72
|
+
else
|
73
|
+
{
|
74
|
+
return (s1.toUpperCase() == s2.toUpperCase());
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Removes whitespace from the front and the end of the specified
|
80
|
+
* string.
|
81
|
+
*
|
82
|
+
* @param input The String whose beginning and ending whitespace will
|
83
|
+
* will be removed.
|
84
|
+
*
|
85
|
+
* @returns A String with whitespace removed from the begining and end
|
86
|
+
*
|
87
|
+
* @langversion ActionScript 3.0
|
88
|
+
* @playerversion Flash 9.0
|
89
|
+
* @tiptext
|
90
|
+
*/
|
91
|
+
public static function trim(input:String):String
|
92
|
+
{
|
93
|
+
return StringUtil.ltrim(StringUtil.rtrim(input));
|
94
|
+
}
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Removes whitespace from the front of the specified string.
|
98
|
+
*
|
99
|
+
* @param input The String whose beginning whitespace will will be removed.
|
100
|
+
*
|
101
|
+
* @returns A String with whitespace removed from the begining
|
102
|
+
*
|
103
|
+
* @langversion ActionScript 3.0
|
104
|
+
* @playerversion Flash 9.0
|
105
|
+
* @tiptext
|
106
|
+
*/
|
107
|
+
public static function ltrim(input:String):String
|
108
|
+
{
|
109
|
+
var size:Number = input.length;
|
110
|
+
for(var i:Number = 0; i < size; i++)
|
111
|
+
{
|
112
|
+
if(input.charCodeAt(i) > 32)
|
113
|
+
{
|
114
|
+
return input.substring(i);
|
115
|
+
}
|
116
|
+
}
|
117
|
+
return "";
|
118
|
+
}
|
119
|
+
|
120
|
+
/**
|
121
|
+
* Removes whitespace from the end of the specified string.
|
122
|
+
*
|
123
|
+
* @param input The String whose ending whitespace will will be removed.
|
124
|
+
*
|
125
|
+
* @returns A String with whitespace removed from the end
|
126
|
+
*
|
127
|
+
* @langversion ActionScript 3.0
|
128
|
+
* @playerversion Flash 9.0
|
129
|
+
* @tiptext
|
130
|
+
*/
|
131
|
+
public static function rtrim(input:String):String
|
132
|
+
{
|
133
|
+
var size:Number = input.length;
|
134
|
+
for(var i:Number = size; i > 0; i--)
|
135
|
+
{
|
136
|
+
if(input.charCodeAt(i - 1) > 32)
|
137
|
+
{
|
138
|
+
return input.substring(0, i);
|
139
|
+
}
|
140
|
+
}
|
141
|
+
|
142
|
+
return "";
|
143
|
+
}
|
144
|
+
|
145
|
+
/**
|
146
|
+
* Determines whether the specified string begins with the spcified prefix.
|
147
|
+
*
|
148
|
+
* @param input The string that the prefix will be checked against.
|
149
|
+
*
|
150
|
+
* @param prefix The prefix that will be tested against the string.
|
151
|
+
*
|
152
|
+
* @returns True if the string starts with the prefix, false if it does not.
|
153
|
+
*
|
154
|
+
* @langversion ActionScript 3.0
|
155
|
+
* @playerversion Flash 9.0
|
156
|
+
* @tiptext
|
157
|
+
*/
|
158
|
+
public static function beginsWith(input:String, prefix:String):Boolean
|
159
|
+
{
|
160
|
+
return (prefix == input.substring(0, prefix.length));
|
161
|
+
}
|
162
|
+
|
163
|
+
/**
|
164
|
+
* Determines whether the specified string ends with the spcified suffix.
|
165
|
+
*
|
166
|
+
* @param input The string that the suffic will be checked against.
|
167
|
+
*
|
168
|
+
* @param prefix The suffic that will be tested against the string.
|
169
|
+
*
|
170
|
+
* @returns True if the string ends with the suffix, false if it does not.
|
171
|
+
*
|
172
|
+
* @langversion ActionScript 3.0
|
173
|
+
* @playerversion Flash 9.0
|
174
|
+
* @tiptext
|
175
|
+
*/
|
176
|
+
public static function endsWith(input:String, suffix:String):Boolean
|
177
|
+
{
|
178
|
+
return (suffix == input.substring(input.length - suffix.length));
|
179
|
+
}
|
180
|
+
|
181
|
+
/**
|
182
|
+
* Removes all instances of the remove string in the input string.
|
183
|
+
*
|
184
|
+
* @param input The string that will be checked for instances of remove
|
185
|
+
* string
|
186
|
+
*
|
187
|
+
* @param remove The string that will be removed from the input string.
|
188
|
+
*
|
189
|
+
* @returns A String with the remove string removed.
|
190
|
+
*
|
191
|
+
* @langversion ActionScript 3.0
|
192
|
+
* @playerversion Flash 9.0
|
193
|
+
* @tiptext
|
194
|
+
*/
|
195
|
+
public static function remove(input:String, remove:String):String
|
196
|
+
{
|
197
|
+
return StringUtil.replace(input, remove, "");
|
198
|
+
}
|
199
|
+
|
200
|
+
/**
|
201
|
+
* Replaces all instances of the replace string in the input string
|
202
|
+
* with the replaceWith string.
|
203
|
+
*
|
204
|
+
* @param input The string that instances of replace string will be
|
205
|
+
* replaces with removeWith string.
|
206
|
+
*
|
207
|
+
* @param replace The string that will be replaced by instances of
|
208
|
+
* the replaceWith string.
|
209
|
+
*
|
210
|
+
* @param replaceWith The string that will replace instances of replace
|
211
|
+
* string.
|
212
|
+
*
|
213
|
+
* @returns A new String with the replace string replaced with the
|
214
|
+
* replaceWith string.
|
215
|
+
*
|
216
|
+
* @langversion ActionScript 3.0
|
217
|
+
* @playerversion Flash 9.0
|
218
|
+
* @tiptext
|
219
|
+
*/
|
220
|
+
public static function replace(input:String, replace:String, replaceWith:String):String
|
221
|
+
{
|
222
|
+
//change to StringBuilder
|
223
|
+
var sb:String = new String();
|
224
|
+
var found:Boolean = false;
|
225
|
+
|
226
|
+
var sLen:Number = input.length;
|
227
|
+
var rLen:Number = replace.length;
|
228
|
+
|
229
|
+
for (var i:Number = 0; i < sLen; i++)
|
230
|
+
{
|
231
|
+
if(input.charAt(i) == replace.charAt(0))
|
232
|
+
{
|
233
|
+
found = true;
|
234
|
+
for(var j:Number = 0; j < rLen; j++)
|
235
|
+
{
|
236
|
+
if(!(input.charAt(i + j) == replace.charAt(j)))
|
237
|
+
{
|
238
|
+
found = false;
|
239
|
+
break;
|
240
|
+
}
|
241
|
+
}
|
242
|
+
|
243
|
+
if(found)
|
244
|
+
{
|
245
|
+
sb += replaceWith;
|
246
|
+
i = i + (rLen - 1);
|
247
|
+
continue;
|
248
|
+
}
|
249
|
+
}
|
250
|
+
sb += input.charAt(i);
|
251
|
+
}
|
252
|
+
//TODO : if the string is not found, should we return the original
|
253
|
+
//string?
|
254
|
+
return sb;
|
255
|
+
}
|
256
|
+
}
|
257
|
+
}
|
@@ -0,0 +1,171 @@
|
|
1
|
+
/*
|
2
|
+
Adobe Systems Incorporated(r) Source Code License Agreement
|
3
|
+
Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved.
|
4
|
+
|
5
|
+
Please read this Source Code License Agreement carefully before using
|
6
|
+
the source code.
|
7
|
+
|
8
|
+
Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive,
|
9
|
+
no-charge, royalty-free, irrevocable copyright license, to reproduce,
|
10
|
+
prepare derivative works of, publicly display, publicly perform, and
|
11
|
+
distribute this source code and such derivative works in source or
|
12
|
+
object code form without any attribution requirements.
|
13
|
+
|
14
|
+
The name "Adobe Systems Incorporated" must not be used to endorse or promote products
|
15
|
+
derived from the source code without prior written permission.
|
16
|
+
|
17
|
+
You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and
|
18
|
+
against any loss, damage, claims or lawsuits, including attorney's
|
19
|
+
fees that arise or result from your use or distribution of the source
|
20
|
+
code.
|
21
|
+
|
22
|
+
THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT
|
23
|
+
ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
|
24
|
+
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
25
|
+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF
|
26
|
+
NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA
|
27
|
+
OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
28
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
29
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
30
|
+
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
31
|
+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
32
|
+
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF
|
33
|
+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
|
+
*/
|
35
|
+
|
36
|
+
package com.adobe.utils
|
37
|
+
{
|
38
|
+
|
39
|
+
public class XMLUtil
|
40
|
+
{
|
41
|
+
/**
|
42
|
+
* Constant representing a text node type returned from XML.nodeKind.
|
43
|
+
*
|
44
|
+
* @see XML.nodeKind()
|
45
|
+
*
|
46
|
+
* @langversion ActionScript 3.0
|
47
|
+
* @playerversion Flash 9.0
|
48
|
+
*/
|
49
|
+
public static const TEXT:String = "text";
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Constant representing a comment node type returned from XML.nodeKind.
|
53
|
+
*
|
54
|
+
* @see XML.nodeKind()
|
55
|
+
*
|
56
|
+
* @langversion ActionScript 3.0
|
57
|
+
* @playerversion Flash 9.0
|
58
|
+
*/
|
59
|
+
public static const COMMENT:String = "comment";
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Constant representing a processing instruction type returned from XML.nodeKind.
|
63
|
+
*
|
64
|
+
* @see XML.nodeKind()
|
65
|
+
*
|
66
|
+
* @langversion ActionScript 3.0
|
67
|
+
* @playerversion Flash 9.0
|
68
|
+
*/
|
69
|
+
public static const PROCESSING_INSTRUCTION:String = "processing-instruction";
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Constant representing an attribute type returned from XML.nodeKind.
|
73
|
+
*
|
74
|
+
* @see XML.nodeKind()
|
75
|
+
*
|
76
|
+
* @langversion ActionScript 3.0
|
77
|
+
* @playerversion Flash 9.0
|
78
|
+
*/
|
79
|
+
public static const ATTRIBUTE:String = "attribute";
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Constant representing a element type returned from XML.nodeKind.
|
83
|
+
*
|
84
|
+
* @see XML.nodeKind()
|
85
|
+
*
|
86
|
+
* @langversion ActionScript 3.0
|
87
|
+
* @playerversion Flash 9.0
|
88
|
+
*/
|
89
|
+
public static const ELEMENT:String = "element";
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Checks whether the specified string is valid and well formed XML.
|
93
|
+
*
|
94
|
+
* @param data The string that is being checked to see if it is valid XML.
|
95
|
+
*
|
96
|
+
* @return A Boolean value indicating whether the specified string is
|
97
|
+
* valid XML.
|
98
|
+
*
|
99
|
+
* @langversion ActionScript 3.0
|
100
|
+
* @playerversion Flash 9.0
|
101
|
+
*/
|
102
|
+
public static function isValidXML(data:String):Boolean
|
103
|
+
{
|
104
|
+
var xml:XML;
|
105
|
+
|
106
|
+
try
|
107
|
+
{
|
108
|
+
xml = new XML(data);
|
109
|
+
}
|
110
|
+
catch(e:Error)
|
111
|
+
{
|
112
|
+
return false;
|
113
|
+
}
|
114
|
+
|
115
|
+
if(xml.nodeKind() != XMLUtil.ELEMENT)
|
116
|
+
{
|
117
|
+
return false;
|
118
|
+
}
|
119
|
+
|
120
|
+
return true;
|
121
|
+
}
|
122
|
+
|
123
|
+
/**
|
124
|
+
* Returns the next sibling of the specified node relative to the node's parent.
|
125
|
+
*
|
126
|
+
* @param x The node whose next sibling will be returned.
|
127
|
+
*
|
128
|
+
* @return The next sibling of the node. null if the node does not have
|
129
|
+
* a sibling after it, or if the node has no parent.
|
130
|
+
*
|
131
|
+
* @langversion ActionScript 3.0
|
132
|
+
* @playerversion Flash 9.0
|
133
|
+
*/
|
134
|
+
public static function getNextSibling(x:XML):XML
|
135
|
+
{
|
136
|
+
return XMLUtil.getSiblingByIndex(x, 1);
|
137
|
+
}
|
138
|
+
|
139
|
+
/**
|
140
|
+
* Returns the sibling before the specified node relative to the node's parent.
|
141
|
+
*
|
142
|
+
* @param x The node whose sibling before it will be returned.
|
143
|
+
*
|
144
|
+
* @return The sibling before the node. null if the node does not have
|
145
|
+
* a sibling before it, or if the node has no parent.
|
146
|
+
*
|
147
|
+
* @langversion ActionScript 3.0
|
148
|
+
* @playerversion Flash 9.0
|
149
|
+
*/
|
150
|
+
public static function getPreviousSibling(x:XML):XML
|
151
|
+
{
|
152
|
+
return XMLUtil.getSiblingByIndex(x, -1);
|
153
|
+
}
|
154
|
+
|
155
|
+
protected static function getSiblingByIndex(x:XML, count:int):XML
|
156
|
+
{
|
157
|
+
var out:XML;
|
158
|
+
|
159
|
+
try
|
160
|
+
{
|
161
|
+
out = x.parent().children()[x.childIndex() + count];
|
162
|
+
}
|
163
|
+
catch(e:Error)
|
164
|
+
{
|
165
|
+
return null;
|
166
|
+
}
|
167
|
+
|
168
|
+
return out;
|
169
|
+
}
|
170
|
+
}
|
171
|
+
}
|