diff options
| author | sostler <sbostler@gmail.com> | 2010-02-27 23:22:29 -0500 |
|---|---|---|
| committer | sostler <sbostler@gmail.com> | 2010-02-27 23:22:29 -0500 |
| commit | 8e0b068b1d6929af82ef348a47b235dd89196c11 (patch) | |
| tree | 64b5b4caa125c9db737ba1033dd871c2f0b3b108 /webcam/com/adobe/utils | |
| parent | 19603b846364d0f22d725d35321435badc5e41e8 (diff) | |
Fixed CLRF
Diffstat (limited to 'webcam/com/adobe/utils')
| -rw-r--r-- | webcam/com/adobe/utils/ArrayUtil.as | 380 | ||||
| -rw-r--r-- | webcam/com/adobe/utils/IntUtil.as | 136 | ||||
| -rw-r--r-- | webcam/com/adobe/utils/NumberFormatter.as | 152 | ||||
| -rw-r--r-- | webcam/com/adobe/utils/XMLUtil.as | 340 |
4 files changed, 504 insertions, 504 deletions
diff --git a/webcam/com/adobe/utils/ArrayUtil.as b/webcam/com/adobe/utils/ArrayUtil.as index 79f499b..c535602 100644 --- a/webcam/com/adobe/utils/ArrayUtil.as +++ b/webcam/com/adobe/utils/ArrayUtil.as @@ -1,190 +1,190 @@ -/*
- Adobe Systems Incorporated(r) Source Code License Agreement
- Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved.
-
- Please read this Source Code License Agreement carefully before using
- the source code.
-
- Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive,
- no-charge, royalty-free, irrevocable copyright license, to reproduce,
- prepare derivative works of, publicly display, publicly perform, and
- distribute this source code and such derivative works in source or
- object code form without any attribution requirements.
-
- The name "Adobe Systems Incorporated" must not be used to endorse or promote products
- derived from the source code without prior written permission.
-
- You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and
- against any loss, damage, claims or lawsuits, including attorney's
- fees that arise or result from your use or distribution of the source
- code.
-
- THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT
- ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
- BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF
- NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA
- OR ITS SUPPLIERS 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 SOURCE CODE, 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;
- }
- }
-}
+/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS 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 SOURCE CODE, 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/webcam/com/adobe/utils/IntUtil.as b/webcam/com/adobe/utils/IntUtil.as index 6b677ef..591edc0 100644 --- a/webcam/com/adobe/utils/IntUtil.as +++ b/webcam/com/adobe/utils/IntUtil.as @@ -1,69 +1,69 @@ -
-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;
- }
- }
-
+ +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/webcam/com/adobe/utils/NumberFormatter.as b/webcam/com/adobe/utils/NumberFormatter.as index 60b9667..53b2501 100644 --- a/webcam/com/adobe/utils/NumberFormatter.as +++ b/webcam/com/adobe/utils/NumberFormatter.as @@ -1,77 +1,77 @@ -/*
- Adobe Systems Incorporated(r) Source Code License Agreement
- Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved.
-
- Please read this Source Code License Agreement carefully before using
- the source code.
-
- Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive,
- no-charge, royalty-free, irrevocable copyright license, to reproduce,
- prepare derivative works of, publicly display, publicly perform, and
- distribute this source code and such derivative works in source or
- object code form without any attribution requirements.
-
- The name "Adobe Systems Incorporated" must not be used to endorse or promote products
- derived from the source code without prior written permission.
-
- You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and
- against any loss, damage, claims or lawsuits, including attorney's
- fees that arise or result from your use or distribution of the source
- code.
-
- THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT
- ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
- BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF
- NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA
- OR ITS SUPPLIERS 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 SOURCE CODE, 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;
- }
-
- }
+/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS 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 SOURCE CODE, 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/webcam/com/adobe/utils/XMLUtil.as b/webcam/com/adobe/utils/XMLUtil.as index 1a902ef..8524a0b 100644 --- a/webcam/com/adobe/utils/XMLUtil.as +++ b/webcam/com/adobe/utils/XMLUtil.as @@ -1,171 +1,171 @@ -/*
- Adobe Systems Incorporated(r) Source Code License Agreement
- Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved.
-
- Please read this Source Code License Agreement carefully before using
- the source code.
-
- Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive,
- no-charge, royalty-free, irrevocable copyright license, to reproduce,
- prepare derivative works of, publicly display, publicly perform, and
- distribute this source code and such derivative works in source or
- object code form without any attribution requirements.
-
- The name "Adobe Systems Incorporated" must not be used to endorse or promote products
- derived from the source code without prior written permission.
-
- You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and
- against any loss, damage, claims or lawsuits, including attorney's
- fees that arise or result from your use or distribution of the source
- code.
-
- THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT
- ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
- BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF
- NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA
- OR ITS SUPPLIERS 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 SOURCE CODE, 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;
- }
- }
+/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS 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 SOURCE CODE, 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 |
