aboutsummaryrefslogtreecommitdiff
path: root/vendors/uploadify/com/adobe/utils
diff options
context:
space:
mode:
Diffstat (limited to 'vendors/uploadify/com/adobe/utils')
-rw-r--r--vendors/uploadify/com/adobe/utils/ArrayUtil.as187
-rw-r--r--vendors/uploadify/com/adobe/utils/DateUtil.as699
-rw-r--r--vendors/uploadify/com/adobe/utils/DictionaryUtil.as87
-rw-r--r--vendors/uploadify/com/adobe/utils/IntUtil.as99
-rw-r--r--vendors/uploadify/com/adobe/utils/NumberFormatter.as74
-rw-r--r--vendors/uploadify/com/adobe/utils/StringUtil.as270
-rw-r--r--vendors/uploadify/com/adobe/utils/XMLUtil.as168
7 files changed, 1584 insertions, 0 deletions
diff --git a/vendors/uploadify/com/adobe/utils/ArrayUtil.as b/vendors/uploadify/com/adobe/utils/ArrayUtil.as
new file mode 100644
index 000000000..e65612004
--- /dev/null
+++ b/vendors/uploadify/com/adobe/utils/ArrayUtil.as
@@ -0,0 +1,187 @@
+/*
+ Copyright (c) 2008, Adobe Systems Incorporated
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package com.adobe.utils
+{
+
+ /**
+ * Class that contains static utility methods for manipulating and working
+ * with Arrays.
+ *
+ * Note that all APIs assume that they are working with well formed arrays.
+ * i.e. they will only manipulate indexed values.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public class ArrayUtil
+ {
+
+ /**
+ * Determines whether the specified array contains the specified value.
+ *
+ * @param arr The array that will be checked for the specified value.
+ *
+ * @param value The object which will be searched for within the array
+ *
+ * @return True if the array contains the value, False if it does not.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public static function arrayContainsValue(arr:Array, value:Object):Boolean
+ {
+ return (arr.indexOf(value) != -1);
+ }
+
+ /**
+ * Remove all instances of the specified value from the array,
+ *
+ * @param arr The array from which the value will be removed
+ *
+ * @param value The object that will be removed from the array.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public static function removeValueFromArray(arr:Array, value:Object):void
+ {
+ var len:uint = arr.length;
+
+ for(var i:Number = len; i > -1; i--)
+ {
+ if(arr[i] === value)
+ {
+ arr.splice(i, 1);
+ }
+ }
+ }
+
+ /**
+ * Create a new array that only contains unique instances of objects
+ * in the specified array.
+ *
+ * Basically, this can be used to remove duplication object instances
+ * from an array
+ *
+ * @param arr The array which contains the values that will be used to
+ * create the new array that contains no duplicate values.
+ *
+ * @return A new array which only contains unique items from the specified
+ * array.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public static function createUniqueCopy(a:Array):Array
+ {
+ var newArray:Array = new Array();
+
+ var len:Number = a.length;
+ var item:Object;
+
+ for (var i:uint = 0; i < len; ++i)
+ {
+ item = a[i];
+
+ if(ArrayUtil.arrayContainsValue(newArray, item))
+ {
+ continue;
+ }
+
+ newArray.push(item);
+ }
+
+ return newArray;
+ }
+
+ /**
+ * Creates a copy of the specified array.
+ *
+ * Note that the array returned is a new array but the items within the
+ * array are not copies of the items in the original array (but rather
+ * references to the same items)
+ *
+ * @param arr The array that will be copies
+ *
+ * @return A new array which contains the same items as the array passed
+ * in.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public static function copyArray(arr:Array):Array
+ {
+ return arr.slice();
+ }
+
+ /**
+ * Compares two arrays and returns a boolean indicating whether the arrays
+ * contain the same values at the same indexes.
+ *
+ * @param arr1 The first array that will be compared to the second.
+ *
+ * @param arr2 The second array that will be compared to the first.
+ *
+ * @return True if the arrays contains the same values at the same indexes.
+ False if they do not.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public static function arraysAreEqual(arr1:Array, arr2:Array):Boolean
+ {
+ if(arr1.length != arr2.length)
+ {
+ return false;
+ }
+
+ var len:Number = arr1.length;
+
+ for(var i:Number = 0; i < len; i++)
+ {
+ if(arr1[i] !== arr2[i])
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/vendors/uploadify/com/adobe/utils/DateUtil.as b/vendors/uploadify/com/adobe/utils/DateUtil.as
new file mode 100644
index 000000000..a49fe433e
--- /dev/null
+++ b/vendors/uploadify/com/adobe/utils/DateUtil.as
@@ -0,0 +1,699 @@
+/*
+ Copyright (c) 2008, Adobe Systems Incorporated
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package com.adobe.utils
+{
+ import mx.formatters.DateBase;
+
+ /**
+ * Class that contains static utility methods for manipulating and working
+ * with Dates.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public class DateUtil
+ {
+
+ /**
+ * Returns the English Short Month name (3 letters) for the Month that
+ * the Date represents.
+ *
+ * @param d The Date instance whose month will be used to retrieve the
+ * short month name.
+ *
+ * @return An English 3 Letter Month abbreviation.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ *
+ * @see SHORT_MONTH
+ */
+ public static function getShortMonthName(d:Date):String
+ {
+ return DateBase.monthNamesShort[d.getMonth()];
+ }
+
+ /**
+ * Returns the index of the month that the short month name string
+ * represents.
+ *
+ * @param m The 3 letter abbreviation representing a short month name.
+ *
+ * @param Optional parameter indicating whether the search should be case
+ * sensitive
+ *
+ * @return A int that represents that month represented by the specifed
+ * short name.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ *
+ * @see SHORT_MONTH
+ */
+ public static function getShortMonthIndex(m:String):int
+ {
+ return DateBase.monthNamesShort.indexOf(m);
+ }
+
+ /**
+ * Returns the English full Month name for the Month that
+ * the Date represents.
+ *
+ * @param d The Date instance whose month will be used to retrieve the
+ * full month name.
+ *
+ * @return An English full month name.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ *
+ * @see FULL_MONTH
+ */
+ public static function getFullMonthName(d:Date):String
+ {
+ return DateBase.monthNamesLong[d.getMonth()];
+ }
+
+ /**
+ * Returns the index of the month that the full month name string
+ * represents.
+ *
+ * @param m A full month name.
+ *
+ * @return A int that represents that month represented by the specifed
+ * full month name.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ *
+ * @see FULL_MONTH
+ */
+ public static function getFullMonthIndex(m:String):int
+ {
+ return DateBase.monthNamesLong.indexOf(m);
+ }
+
+ /**
+ * Returns the English Short Day name (3 letters) for the day that
+ * the Date represents.
+ *
+ * @param d The Date instance whose day will be used to retrieve the
+ * short day name.
+ *
+ * @return An English 3 Letter day abbreviation.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ *
+ * @see SHORT_DAY
+ */
+ public static function getShortDayName(d:Date):String
+ {
+ return DateBase.dayNamesShort[d.getDay()];
+ }
+
+ /**
+ * Returns the index of the day that the short day name string
+ * represents.
+ *
+ * @param m A short day name.
+ *
+ * @return A int that represents that short day represented by the specifed
+ * full month name.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ *
+ * @see SHORT_DAY
+ */
+ public static function getShortDayIndex(d:String):int
+ {
+ return DateBase.dayNamesShort.indexOf(d);
+ }
+
+ /**
+ * Returns the English full day name for the day that
+ * the Date represents.
+ *
+ * @param d The Date instance whose day will be used to retrieve the
+ * full day name.
+ *
+ * @return An English full day name.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ *
+ * @see FULL_DAY
+ */
+ public static function getFullDayName(d:Date):String
+ {
+ return DateBase.dayNamesLong[d.getDay()];
+ }
+
+ /**
+ * Returns the index of the day that the full day name string
+ * represents.
+ *
+ * @param m A full day name.
+ *
+ * @return A int that represents that full day represented by the specifed
+ * full month name.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ *
+ * @see FULL_DAY
+ */
+ public static function getFullDayIndex(d:String):int
+ {
+ return DateBase.dayNamesLong.indexOf(d);
+ }
+
+ /**
+ * Returns a two digit representation of the year represented by the
+ * specified date.
+ *
+ * @param d The Date instance whose year will be used to generate a two
+ * digit string representation of the year.
+ *
+ * @return A string that contains a 2 digit representation of the year.
+ * Single digits will be padded with 0.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public static function getShortYear(d:Date):String
+ {
+ var dStr:String = String(d.getFullYear());
+
+ if(dStr.length < 3)
+ {
+ return dStr;
+ }
+
+ return (dStr.substr(dStr.length - 2));
+ }
+
+ /**
+ * Compares two dates and returns an integer depending on their relationship.
+ *
+ * Returns -1 if d1 is greater than d2.
+ * Returns 1 if d2 is greater than d1.
+ * Returns 0 if both dates are equal.
+ *
+ * @param d1 The date that will be compared to the second date.
+ * @param d2 The date that will be compared to the first date.
+ *
+ * @return An int indicating how the two dates compare.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public static function compareDates(d1:Date, d2:Date):int
+ {
+ var d1ms:Number = d1.getTime();
+ var d2ms:Number = d2.getTime();
+
+ if(d1ms > d2ms)
+ {
+ return -1;
+ }
+ else if(d1ms < d2ms)
+ {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ /**
+ * Returns a short hour (0 - 12) represented by the specified date.
+ *
+ * If the hour is less than 12 (0 - 11 AM) then the hour will be returned.
+ *
+ * If the hour is greater than 12 (12 - 23 PM) then the hour minus 12
+ * will be returned.
+ *
+ * @param d1 The Date from which to generate the short hour
+ *
+ * @return An int between 0 and 13 ( 1 - 12 ) representing the short hour.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public static function getShortHour(d:Date):int
+ {
+ var h:int = d.hours;
+
+ if(h == 0 || h == 12)
+ {
+ return 12;
+ }
+ else if(h > 12)
+ {
+ return h - 12;
+ }
+ else
+ {
+ return h;
+ }
+ }
+
+ /**
+ * Returns a string indicating whether the date represents a time in the
+ * ante meridiem (AM) or post meridiem (PM).
+ *
+ * If the hour is less than 12 then "AM" will be returned.
+ *
+ * If the hour is greater than 12 then "PM" will be returned.
+ *
+ * @param d1 The Date from which to generate the 12 hour clock indicator.
+ *
+ * @return A String ("AM" or "PM") indicating which half of the day the
+ * hour represents.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public static function getAMPM(d:Date):String
+ {
+ return (d.hours > 11)? "PM" : "AM";
+ }
+
+ /**
+ * Parses dates that conform to RFC822 into Date objects. This method also
+ * supports four-digit years (not supported in RFC822), but two-digit years
+ * (referring to the 20th century) are fine, too.
+ *
+ * This function is useful for parsing RSS .91, .92, and 2.0 dates.
+ *
+ * @param str
+ *
+ * @returns
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ *
+ * @see http://asg.web.cmu.edu/rfc/rfc822.html
+ */
+ public static function parseRFC822(str:String):Date
+ {
+ var finalDate:Date;
+ try
+ {
+ var dateParts:Array = str.split(" ");
+ var day:String = null;
+
+ if (dateParts[0].search(/\d/) == -1)
+ {
+ day = dateParts.shift().replace(/\W/, "");
+ }
+
+ var date:Number = Number(dateParts.shift());
+ var month:Number = Number(DateUtil.getShortMonthIndex(dateParts.shift()));
+ var year:Number = Number(dateParts.shift());
+ var timeParts:Array = dateParts.shift().split(":");
+ var hour:Number = int(timeParts.shift());
+ var minute:Number = int(timeParts.shift());
+ var second:Number = (timeParts.length > 0) ? int(timeParts.shift()): 0;
+
+ var milliseconds:Number = Date.UTC(year, month, date, hour, minute, second, 0);
+
+ var timezone:String = dateParts.shift();
+ var offset:Number = 0;
+
+ if (timezone.search(/\d/) == -1)
+ {
+ switch(timezone)
+ {
+ case "UT":
+ offset = 0;
+ break;
+ case "UTC":
+ offset = 0;
+ break;
+ case "GMT":
+ offset = 0;
+ break;
+ case "EST":
+ offset = (-5 * 3600000);
+ break;
+ case "EDT":
+ offset = (-4 * 3600000);
+ break;
+ case "CST":
+ offset = (-6 * 3600000);
+ break;
+ case "CDT":
+ offset = (-5 * 3600000);
+ break;
+ case "MST":
+ offset = (-7 * 3600000);
+ break;
+ case "MDT":
+ offset = (-6 * 3600000);
+ break;
+ case "PST":
+ offset = (-8 * 3600000);
+ break;
+ case "PDT":
+ offset = (-7 * 3600000);
+ break;
+ case "Z":
+ offset = 0;
+ break;
+ case "A":
+ offset = (-1 * 3600000);
+ break;
+ case "M":
+ offset = (-12 * 3600000);
+ break;
+ case "N":
+ offset = (1 * 3600000);
+ break;
+ case "Y":
+ offset = (12 * 3600000);
+ break;
+ default:
+ offset = 0;
+ }
+ }
+ else
+ {
+ var multiplier:Number = 1;
+ var oHours:Number = 0;
+ var oMinutes:Number = 0;
+ if (timezone.length != 4)
+ {
+ if (timezone.charAt(0) == "-")
+ {
+ multiplier = -1;
+ }
+ timezone = timezone.substr(1, 4);
+ }
+ oHours = Number(timezone.substr(0, 2));
+ oMinutes = Number(timezone.substr(2, 2));
+ offset = (((oHours * 3600000) + (oMinutes * 60000)) * multiplier);
+ }
+
+ finalDate = new Date(milliseconds - offset);
+
+ if (finalDate.toString() == "Invalid Date")
+ {
+ throw new Error("This date does not conform to RFC822.");
+ }
+ }
+ catch (e:Error)
+ {
+ var eStr:String = "Unable to parse the string [" +str+ "] into a date. ";
+ eStr += "The internal error was: " + e.toString();
+ throw new Error(eStr);
+ }
+ return finalDate;
+ }
+
+ /**
+ * Returns a date string formatted according to RFC822.
+ *
+ * @param d
+ *
+ * @returns
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ *
+ * @see http://asg.web.cmu.edu/rfc/rfc822.html
+ */
+ public static function toRFC822(d:Date):String
+ {
+ var date:Number = d.getUTCDate();
+ var hours:Number = d.getUTCHours();
+ var minutes:Number = d.getUTCMinutes();
+ var seconds:Number = d.getUTCSeconds();
+ var sb:String = new String();
+ sb += DateBase.dayNamesShort[d.getUTCDay()];
+ sb += ", ";
+
+ if (date < 10)
+ {
+ sb += "0";
+ }
+ sb += date;
+ sb += " ";
+ //sb += DateUtil.SHORT_MONTH[d.getUTCMonth()];
+ sb += DateBase.monthNamesShort[d.getUTCMonth()];
+ sb += " ";
+ sb += d.getUTCFullYear();
+ sb += " ";
+ if (hours < 10)
+ {
+ sb += "0";
+ }
+ sb += hours;
+ sb += ":";
+ if (minutes < 10)
+ {
+ sb += "0";
+ }
+ sb += minutes;
+ sb += ":";
+ if (seconds < 10)
+ {
+ sb += "0";
+ }
+ sb += seconds;
+ sb += " GMT";
+ return sb;
+ }
+
+ /**
+ * Parses dates that conform to the W3C Date-time Format into Date objects.
+ *
+ * This function is useful for parsing RSS 1.0 and Atom 1.0 dates.
+ *
+ * @param str
+ *
+ * @returns
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ *
+ * @see http://www.w3.org/TR/NOTE-datetime
+ */
+ public static function parseW3CDTF(str:String):Date
+ {
+ var finalDate:Date;
+ try
+ {
+ var dateStr:String = str.substring(0, str.indexOf("T"));
+ var timeStr:String = str.substring(str.indexOf("T")+1, str.length);
+ var dateArr:Array = dateStr.split("-");
+ var year:Number = Number(dateArr.shift());
+ var month:Number = Number(dateArr.shift());
+ var date:Number = Number(dateArr.shift());
+
+ var multiplier:Number;
+ var offsetHours:Number;
+ var offsetMinutes:Number;
+ var offsetStr:String;
+
+ if (timeStr.indexOf("Z") != -1)
+ {
+ multiplier = 1;
+ offsetHours = 0;
+ offsetMinutes = 0;
+ timeStr = timeStr.replace("Z", "");
+ }
+ else if (timeStr.indexOf("+") != -1)
+ {
+ multiplier = 1;
+ offsetStr = timeStr.substring(timeStr.indexOf("+")+1, timeStr.length);
+ offsetHours = Number(offsetStr.substring(0, offsetStr.indexOf(":")));
+ offsetMinutes = Number(offsetStr.substring(offsetStr.indexOf(":")+1, offsetStr.length));
+ timeStr = timeStr.substring(0, timeStr.indexOf("+"));
+ }
+ else // offset is -
+ {
+ multiplier = -1;
+ offsetStr = timeStr.substring(timeStr.indexOf("-")+1, timeStr.length);
+ offsetHours = Number(offsetStr.substring(0, offsetStr.indexOf(":")));
+ offsetMinutes = Number(offsetStr.substring(offsetStr.indexOf(":")+1, offsetStr.length));
+ timeStr = timeStr.substring(0, timeStr.indexOf("-"));
+ }
+ var timeArr:Array = timeStr.split(":");
+ var hour:Number = Number(timeArr.shift());
+ var minutes:Number = Number(timeArr.shift());
+ var secondsArr:Array = (timeArr.length > 0) ? String(timeArr.shift()).split(".") : null;
+ var seconds:Number = (secondsArr != null && secondsArr.length > 0) ? Number(secondsArr.shift()) : 0;
+ var milliseconds:Number = (secondsArr != null && secondsArr.length > 0) ? Number(secondsArr.shift()) : 0;
+ var utc:Number = Date.UTC(year, month-1, date, hour, minutes, seconds, milliseconds);
+ var offset:Number = (((offsetHours * 3600000) + (offsetMinutes * 60000)) * multiplier);
+ finalDate = new Date(utc - offset);
+
+ if (finalDate.toString() == "Invalid Date")
+ {
+ throw new Error("This date does not conform to W3CDTF.");
+ }
+ }
+ catch (e:Error)
+ {
+ var eStr:String = "Unable to parse the string [" +str+ "] into a date. ";
+ eStr += "The internal error was: " + e.toString();
+ throw new Error(eStr);
+ }
+ return finalDate;
+ }
+
+ /**
+ * Returns a date string formatted according to W3CDTF.
+ *
+ * @param d
+ * @param includeMilliseconds Determines whether to include the
+ * milliseconds value (if any) in the formatted string.
+ *
+ * @returns
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ *
+ * @see http://www.w3.org/TR/NOTE-datetime
+ */
+ public static function toW3CDTF(d:Date,includeMilliseconds:Boolean=false):String
+ {
+ var date:Number = d.getUTCDate();
+ var month:Number = d.getUTCMonth();
+ var hours:Number = d.getUTCHours();
+ var minutes:Number = d.getUTCMinutes();
+ var seconds:Number = d.getUTCSeconds();
+ var milliseconds:Number = d.getUTCMilliseconds();
+ var sb:String = new String();
+
+ sb += d.getUTCFullYear();
+ sb += "-";
+
+ //thanks to "dom" who sent in a fix for the line below
+ if (month + 1 < 10)
+ {
+ sb += "0";
+ }
+ sb += month + 1;
+ sb += "-";
+ if (date < 10)
+ {
+ sb += "0";
+ }
+ sb += date;
+ sb += "T";
+ if (hours < 10)
+ {
+ sb += "0";
+ }
+ sb += hours;
+ sb += ":";
+ if (minutes < 10)
+ {
+ sb += "0";
+ }
+ sb += minutes;
+ sb += ":";
+ if (seconds < 10)
+ {
+ sb += "0";
+ }
+ sb += seconds;
+ if (includeMilliseconds && milliseconds > 0)
+ {
+ sb += ".";
+ sb += milliseconds;
+ }
+ sb += "-00:00";
+ return sb;
+ }
+
+ /**
+ * Converts a date into just after midnight.
+ */
+ public static function makeMorning(d:Date):Date
+ {
+ var d:Date = new Date(d.time);
+ d.hours = 0;
+ d.minutes = 0;
+ d.seconds = 0;
+ d.milliseconds = 0;
+ return d;
+ }
+
+ /**
+ * Converts a date into just befor midnight.
+ */
+ public static function makeNight(d:Date):Date
+ {
+ var d:Date = new Date(d.time);
+ d.hours = 23;
+ d.minutes = 59;
+ d.seconds = 59;
+ d.milliseconds = 999;
+ return d;
+ }
+
+ /**
+ * Sort of converts a date into UTC.
+ */
+ public static function getUTCDate(d:Date):Date
+ {
+ var nd:Date = new Date();
+ var offset:Number = d.getTimezoneOffset() * 60 * 1000;
+ nd.setTime(d.getTime() + offset);
+ return nd;
+ }
+ }
+}
diff --git a/vendors/uploadify/com/adobe/utils/DictionaryUtil.as b/vendors/uploadify/com/adobe/utils/DictionaryUtil.as
new file mode 100644
index 000000000..9552ef494
--- /dev/null
+++ b/vendors/uploadify/com/adobe/utils/DictionaryUtil.as
@@ -0,0 +1,87 @@
+/*
+ Copyright (c) 2008, Adobe Systems Incorporated
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package com.adobe.utils
+{
+ import flash.utils.Dictionary;
+
+ public class DictionaryUtil
+ {
+
+ /**
+ * Returns an Array of all keys within the specified dictionary.
+ *
+ * @param d The Dictionary instance whose keys will be returned.
+ *
+ * @return Array of keys contained within the Dictionary
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public static function getKeys(d:Dictionary):Array
+ {
+ var a:Array = new Array();
+
+ for (var key:Object in d)
+ {
+ a.push(key);
+ }
+
+ return a;
+ }
+
+ /**
+ * Returns an Array of all values within the specified dictionary.
+ *
+ * @param d The Dictionary instance whose values will be returned.
+ *
+ * @return Array of values contained within the Dictionary
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public static function getValues(d:Dictionary):Array
+ {
+ var a:Array = new Array();
+
+ for each (var value:Object in d)
+ {
+ a.push(value);
+ }
+
+ return a;
+ }
+
+ }
+} \ No newline at end of file
diff --git a/vendors/uploadify/com/adobe/utils/IntUtil.as b/vendors/uploadify/com/adobe/utils/IntUtil.as
new file mode 100644
index 000000000..8c812fe08
--- /dev/null
+++ b/vendors/uploadify/com/adobe/utils/IntUtil.as
@@ -0,0 +1,99 @@
+/*
+ Copyright (c) 2008, Adobe Systems Incorporated
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+package com.adobe.utils {
+
+ import flash.utils.Endian;
+
+ /**
+ * Contains reusable methods for operations pertaining
+ * to int values.
+ */
+ public class IntUtil {
+
+ /**
+ * Rotates x left n bits
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public static function rol ( x:int, n:int ):int {
+ return ( x << n ) | ( x >>> ( 32 - n ) );
+ }
+
+ /**
+ * Rotates x right n bits
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public static function ror ( x:int, n:int ):uint {
+ var nn:int = 32 - n;
+ return ( x << nn ) | ( x >>> ( 32 - nn ) );
+ }
+
+ /** String for quick lookup of a hex character based on index */
+ private static var hexChars:String = "0123456789abcdef";
+
+ /**
+ * Outputs the hex value of a int, allowing the developer to specify
+ * the endinaness in the process. Hex output is lowercase.
+ *
+ * @param n The int value to output as hex
+ * @param bigEndian Flag to output the int as big or little endian
+ * @return A string of length 8 corresponding to the
+ * hex representation of n ( minus the leading "0x" )
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public static function toHex( n:int, bigEndian:Boolean = false ):String {
+ var s:String = "";
+
+ if ( bigEndian ) {
+ for ( var i:int = 0; i < 4; i++ ) {
+ s += hexChars.charAt( ( n >> ( ( 3 - i ) * 8 + 4 ) ) & 0xF )
+ + hexChars.charAt( ( n >> ( ( 3 - i ) * 8 ) ) & 0xF );
+ }
+ } else {
+ for ( var x:int = 0; x < 4; x++ ) {
+ s += hexChars.charAt( ( n >> ( x * 8 + 4 ) ) & 0xF )
+ + hexChars.charAt( ( n >> ( x * 8 ) ) & 0xF );
+ }
+ }
+
+ return s;
+ }
+ }
+
+} \ No newline at end of file
diff --git a/vendors/uploadify/com/adobe/utils/NumberFormatter.as b/vendors/uploadify/com/adobe/utils/NumberFormatter.as
new file mode 100644
index 000000000..6fe12e145
--- /dev/null
+++ b/vendors/uploadify/com/adobe/utils/NumberFormatter.as
@@ -0,0 +1,74 @@
+/*
+ Copyright (c) 2008, Adobe Systems Incorporated
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package com.adobe.utils
+{
+
+ /**
+ * Class that contains static utility methods for formatting Numbers
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ *
+ * @see #mx.formatters.NumberFormatter
+ */
+ public class NumberFormatter
+ {
+
+ /**
+ * Formats a number to include a leading zero if it is a single digit
+ * between -1 and 10.
+ *
+ * @param n The number that will be formatted
+ *
+ * @return A string with single digits between -1 and 10 padded with a
+ * leading zero.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public static function addLeadingZero(n:Number):String
+ {
+ var out:String = String(n);
+
+ if(n < 10 && n > -1)
+ {
+ out = "0" + out;
+ }
+
+ return out;
+ }
+
+ }
+} \ No newline at end of file
diff --git a/vendors/uploadify/com/adobe/utils/StringUtil.as b/vendors/uploadify/com/adobe/utils/StringUtil.as
new file mode 100644
index 000000000..6aa1979fd
--- /dev/null
+++ b/vendors/uploadify/com/adobe/utils/StringUtil.as
@@ -0,0 +1,270 @@
+/*
+ Copyright (c) 2008, Adobe Systems Incorporated
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package com.adobe.utils
+{
+
+ /**
+ * Class that contains static utility methods for manipulating Strings.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public class StringUtil
+ {
+
+
+ /**
+ * Does a case insensitive compare or two strings and returns true if
+ * they are equal.
+ *
+ * @param s1 The first string to compare.
+ *
+ * @param s2 The second string to compare.
+ *
+ * @returns A boolean value indicating whether the strings' values are
+ * equal in a case sensitive compare.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public static function stringsAreEqual(s1:String, s2:String,
+ caseSensitive:Boolean):Boolean
+ {
+ if(caseSensitive)
+ {
+ return (s1 == s2);
+ }
+ else
+ {
+ return (s1.toUpperCase() == s2.toUpperCase());
+ }
+ }
+
+ /**
+ * Removes whitespace from the front and the end of the specified
+ * string.
+ *
+ * @param input The String whose beginning and ending whitespace will
+ * will be removed.
+ *
+ * @returns A String with whitespace removed from the begining and end
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public static function trim(input:String):String
+ {
+ return StringUtil.ltrim(StringUtil.rtrim(input));
+ }
+
+ /**
+ * Removes whitespace from the front of the specified string.
+ *
+ * @param input The String whose beginning whitespace will will be removed.
+ *
+ * @returns A String with whitespace removed from the begining
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public static function ltrim(input:String):String
+ {
+ var size:Number = input.length;
+ for(var i:Number = 0; i < size; i++)
+ {
+ if(input.charCodeAt(i) > 32)
+ {
+ return input.substring(i);
+ }
+ }
+ return "";
+ }
+
+ /**
+ * Removes whitespace from the end of the specified string.
+ *
+ * @param input The String whose ending whitespace will will be removed.
+ *
+ * @returns A String with whitespace removed from the end
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public static function rtrim(input:String):String
+ {
+ var size:Number = input.length;
+ for(var i:Number = size; i > 0; i--)
+ {
+ if(input.charCodeAt(i - 1) > 32)
+ {
+ return input.substring(0, i);
+ }
+ }
+
+ return "";
+ }
+
+ /**
+ * Determines whether the specified string begins with the spcified prefix.
+ *
+ * @param input The string that the prefix will be checked against.
+ *
+ * @param prefix The prefix that will be tested against the string.
+ *
+ * @returns True if the string starts with the prefix, false if it does not.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public static function beginsWith(input:String, prefix:String):Boolean
+ {
+ return (prefix == input.substring(0, prefix.length));
+ }
+
+ /**
+ * Determines whether the specified string ends with the spcified suffix.
+ *
+ * @param input The string that the suffic will be checked against.
+ *
+ * @param prefix The suffic that will be tested against the string.
+ *
+ * @returns True if the string ends with the suffix, false if it does not.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public static function endsWith(input:String, suffix:String):Boolean
+ {
+ return (suffix == input.substring(input.length - suffix.length));
+ }
+
+ /**
+ * Removes all instances of the remove string in the input string.
+ *
+ * @param input The string that will be checked for instances of remove
+ * string
+ *
+ * @param remove The string that will be removed from the input string.
+ *
+ * @returns A String with the remove string removed.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public static function remove(input:String, remove:String):String
+ {
+ return StringUtil.replace(input, remove, "");
+ }
+
+ /**
+ * Replaces all instances of the replace string in the input string
+ * with the replaceWith string.
+ *
+ * @param input The string that instances of replace string will be
+ * replaces with removeWith string.
+ *
+ * @param replace The string that will be replaced by instances of
+ * the replaceWith string.
+ *
+ * @param replaceWith The string that will replace instances of replace
+ * string.
+ *
+ * @returns A new String with the replace string replaced with the
+ * replaceWith string.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public static function replace(input:String, replace:String, replaceWith:String):String
+ {
+ //change to StringBuilder
+ var sb:String = new String();
+ var found:Boolean = false;
+
+ var sLen:Number = input.length;
+ var rLen:Number = replace.length;
+
+ for (var i:Number = 0; i < sLen; i++)
+ {
+ if(input.charAt(i) == replace.charAt(0))
+ {
+ found = true;
+ for(var j:Number = 0; j < rLen; j++)
+ {
+ if(!(input.charAt(i + j) == replace.charAt(j)))
+ {
+ found = false;
+ break;
+ }
+ }
+
+ if(found)
+ {
+ sb += replaceWith;
+ i = i + (rLen - 1);
+ continue;
+ }
+ }
+ sb += input.charAt(i);
+ }
+ //TODO : if the string is not found, should we return the original
+ //string?
+ return sb;
+ }
+
+ /**
+ * Specifies whether the specified string is either non-null, or contains
+ * characters (i.e. length is greater that 0)
+ *
+ * @param s The string which is being checked for a value
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ * @tiptext
+ */
+ public static function stringHasValue(s:String):Boolean
+ {
+ //todo: this needs a unit test
+ return (s != null && s.length > 0);
+ }
+ }
+} \ No newline at end of file
diff --git a/vendors/uploadify/com/adobe/utils/XMLUtil.as b/vendors/uploadify/com/adobe/utils/XMLUtil.as
new file mode 100644
index 000000000..24fce00fa
--- /dev/null
+++ b/vendors/uploadify/com/adobe/utils/XMLUtil.as
@@ -0,0 +1,168 @@
+/*
+ Copyright (c) 2008, Adobe Systems Incorporated
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package com.adobe.utils
+{
+
+ public class XMLUtil
+ {
+ /**
+ * Constant representing a text node type returned from XML.nodeKind.
+ *
+ * @see XML.nodeKind()
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ */
+ public static const TEXT:String = "text";
+
+ /**
+ * Constant representing a comment node type returned from XML.nodeKind.
+ *
+ * @see XML.nodeKind()
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ */
+ public static const COMMENT:String = "comment";
+
+ /**
+ * Constant representing a processing instruction type returned from XML.nodeKind.
+ *
+ * @see XML.nodeKind()
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ */
+ public static const PROCESSING_INSTRUCTION:String = "processing-instruction";
+
+ /**
+ * Constant representing an attribute type returned from XML.nodeKind.
+ *
+ * @see XML.nodeKind()
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ */
+ public static const ATTRIBUTE:String = "attribute";
+
+ /**
+ * Constant representing a element type returned from XML.nodeKind.
+ *
+ * @see XML.nodeKind()
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ */
+ public static const ELEMENT:String = "element";
+
+ /**
+ * Checks whether the specified string is valid and well formed XML.
+ *
+ * @param data The string that is being checked to see if it is valid XML.
+ *
+ * @return A Boolean value indicating whether the specified string is
+ * valid XML.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ */
+ public static function isValidXML(data:String):Boolean
+ {
+ var xml:XML;
+
+ try
+ {
+ xml = new XML(data);
+ }
+ catch(e:Error)
+ {
+ return false;
+ }
+
+ if(xml.nodeKind() != XMLUtil.ELEMENT)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Returns the next sibling of the specified node relative to the node's parent.
+ *
+ * @param x The node whose next sibling will be returned.
+ *
+ * @return The next sibling of the node. null if the node does not have
+ * a sibling after it, or if the node has no parent.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ */
+ public static function getNextSibling(x:XML):XML
+ {
+ return XMLUtil.getSiblingByIndex(x, 1);
+ }
+
+ /**
+ * Returns the sibling before the specified node relative to the node's parent.
+ *
+ * @param x The node whose sibling before it will be returned.
+ *
+ * @return The sibling before the node. null if the node does not have
+ * a sibling before it, or if the node has no parent.
+ *
+ * @langversion ActionScript 3.0
+ * @playerversion Flash 9.0
+ */
+ public static function getPreviousSibling(x:XML):XML
+ {
+ return XMLUtil.getSiblingByIndex(x, -1);
+ }
+
+ protected static function getSiblingByIndex(x:XML, count:int):XML
+ {
+ var out:XML;
+
+ try
+ {
+ out = x.parent().children()[x.childIndex() + count];
+ }
+ catch(e:Error)
+ {
+ return null;
+ }
+
+ return out;
+ }
+ }
+} \ No newline at end of file