Skip to content
This repository
Browse code

Merge branch 'json_optimization'

  • Loading branch information...
commit cc66f99a0d9bfce46b437f51acd16014ba890367 2 parents c99a4ea + 064139a
Darron Schall authored November 07, 2010
3  .gitignore
@@ -15,6 +15,9 @@ profile
15 15
 .settings
16 16
 bin/*
17 17
 bin-debug/*
  18
+report/*
  19
+bin-test/*
  20
+docs/*
18 21
 .flexLibProperties
19 22
 
20 23
 #Java Noise
42  build/build.properties
... ...
@@ -1,48 +1,20 @@
1  
-# -----------------------------------------------------------------
2  
-# User-Defined Paths
3  
-#
4  
-# Modify these path values to reflect paths on your system
5  
-# -----------------------------------------------------------------
6  
-
7  
-# The path to the flexunit.swc -- Required when trying to build/run unit
8  
-# tests for this library.  The below path assumes there's an "as3flexunitlib"
9  
-# folder along side of this library's root folder, with the .swc file in the
10  
-# bin subdirectory.
11  
-flexunit.swc = ${basedir}/../as3flexunitlib/bin/as3flexunitlib.swc
12  
-
13  
-# The location of the Flex 2 SDK on your sytem.
14  
-flex2sdk.bin.dir = C:/Program Files/Adobe/Flex Builder 2 Plug-in/Flex SDK 2/bin
15  
-flex2sdk.lib.dir = C:/Program Files/Adobe/Flex Builder 2 Plug-in/Flex SDK 2/frameworks/libs
16  
-
17  
-# Note that the locale dir uses the {locale} token at the end to specify the directory
18  
-# of language-specific files.  This is replaced by the compiler with the locale defined
19  
-# by the locale property below.
20  
-flex2sdk.locale = en_US
21  
-flex2sdk.locale.dir = C:/Program Files/Adobe/Flex Builder 2 Plug-in/Flex SDK 2/frameworks/locale/{locale}
22  
-
23  
-#note we have to use aasdoc since the library not includes some AIR files.
24  
-asdoc.exe = aasdoc
25  
-compc.exe = ${flex2sdk.bin.dir}/compc.exe
26  
-mxmlc.exe = ${flex2sdk.bin.dir}/mxmlc.exe
27  
-
28  
-# The debug player is necessary here because it writes trace statements to a flashlog.txt
29  
-# file.  This allows us to examine the .txt file and determine the status of unit tests
30  
-# in an automated fashion.
31  
-flashDebugPlayer.exe = C:/Program Files/Adobe/Flex Builder 2 Plug-in/Player/debug/SAFlashPlayer.exe
32 1
 
33 2
 # -----------------------------------------------------------------
34 3
 # File Names - DO NOT MODIFY
35 4
 # -----------------------------------------------------------------
36  
-testRunner.dir = .
37  
-testRunner.name = CoreLibTestRunner
  5
+test.application.name = CoreLibTestRunner
38 6
 
39  
-library.name = corelib
  7
+library.name = as3corelib
40 8
 
41 9
 # -----------------------------------------------------------------
42 10
 # Project Paths - DO NOT MODIFY
43 11
 # -----------------------------------------------------------------
44 12
 build.dir = ${basedir}/build
  13
+build.libs.dir = ${basedir}/build/libs
45 14
 src.dir = ${basedir}/src
46  
-tests.dir = ${basedir}/tests
  15
+test.src.dir = ${basedir}/tests/src
47 16
 bin.dir = ${basedir}/bin
  17
+test.bin.dir = ${basedir}/bin-test
  18
+report.dir = ${basedir}/report
  19
+report.html.dir = ${basedir}/report/html
48 20
 docs.dir = ${basedir}/docs
222  build/build.xml
... ...
@@ -1,104 +1,172 @@
1 1
 <?xml version="1.0"?>
2  
-<project name="as3corelib" basedir="../" default="lib">
  2
+<project name="as3corelib" basedir="../" default="compile">
3 3
 
4  
-	<!-- Define variables/paths used in this build script -->
5  
-	<property file="./build/build.properties" />
  4
+	<!-- ============================== -->
  5
+	<!--  Configuration -->
  6
+	<!-- ============================== -->
6 7
 
7  
-	<!--
8  
-		Have you edit the properties file to make sure the paths are right oo your system?
9  
-	-->
10  
-	<target name="properties">
11  
-		<fail unless="asdoc.exe">The "asdoc.exe" property must be set in ${build.dir}/build.properties.</fail>
12  
-		<fail unless="compc.exe">The "compc.exe" property must be set in ${build.dir}/build.properties.</fail>
13  
-		<fail unless="mxmlc.exe">The "mxmlc.exe" property must be set in ${build.dir}/build.properties.</fail>
  8
+	<property environment="env" />
  9
+	
  10
+	<fail unless="env.FLEX_HOME" message="FLEX_HOME needs to be defined as an environment variable or in the Ant build." />
  11
+
  12
+	<!-- Configuration -->
  13
+	<property file="${basedir}/build/build.properties" />
  14
+
  15
+	<!-- Setup Flex Ant Resources -->
  16
+	<!--property name="FLEX_HOME" location="${flex.sdk}" /-->
  17
+	<property name="FLEX_HOME" location="${env.FLEX_HOME}" />
  18
+	<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
  19
+	
  20
+	<!-- ============================== -->
  21
+	<!--  Clean and Init Targets -->
  22
+	<!-- ============================== -->
  23
+
  24
+	<target name="clean" description="Removes artifacts from previous builds">
  25
+		<delete includeemptydirs="true" failonerror="false">
  26
+			<fileset dir="${bin.dir}" defaultexcludes="false">
  27
+				<include name="**/*" />
  28
+			</fileset>
  29
+			<fileset dir="${test.bin.dir}" defaultexcludes="false">
  30
+				<include name="**/*" />
  31
+			</fileset>
  32
+			<fileset dir="${docs.dir}" defaultexcludes="false">
  33
+				<include name="**/*" />
  34
+			</fileset>
  35
+			<fileset dir="${report.dir}" defaultexcludes="false">
  36
+				<include name="**/*" />
  37
+			</fileset>
  38
+		</delete>
14 39
 	</target>
  40
+
  41
+	<target name="init" description="Initializes project and destination folders">
  42
+			<echo message="Project: ${ant.project.name}" />
  43
+			<echo message="Flex SDK: ${FLEX_HOME}" />
  44
+
  45
+			<!-- Create direectories -->
  46
+			<mkdir dir="${bin.dir}" />
  47
+			<mkdir dir="${test.bin.dir}" />
  48
+			<mkdir dir="${docs.dir}" />
  49
+			<mkdir dir="${report.dir}" />
  50
+		</target>
15 51
 	
16  
-	<!--
17  
-		Compile the unit tests for the library, placing the test runner .swf file
18  
-		in the bin directory.
19  
-	-->
20  
-	<target name="compileTests" depends="properties">
21  
-		<exec executable="${mxmlc.exe}" dir="${basedir}">
22  
-			<!-- Point to the main test runner's application mxml file -->
23  
-			<arg line="'${tests.dir}/${testRunner.dir}/${testRunner.name}.mxml'" />
24  
-			
25  
-			<!-- Use AIR configuration file -->
26  
-			<arg line="-load-config '${flex2sdk.lib.dir}/../air-config.xml'" />
27  
-			
28  
-			<!-- Place the built .swf file in the "bin" directory -->
29  
-			<arg line="-o '${bin.dir}/${testRunner.name}.swf'" />
30  
-			
31  
-			<!-- Define source directories for "src" and "tests" -->
32  
-			<arg line="-sp ${src.dir}" />
33  
-			<arg line="-sp ${tests.dir}/src" />
  52
+	<!-- ======================================= -->
  53
+	<!--  Unit Test Targets -->
  54
+	<!-- ======================================= -->
  55
+	
  56
+	<target name="compileTestRunner" depends="init" description="Compiles the test runner application.">
  57
+
  58
+		<!-- Compile TestRunner MXML as a SWF -->
  59
+		<mxmlc file="${test.src.dir}/${test.application.name}.mxml" 
  60
+			output="${test.bin.dir}/${test.application.name}.swf">
34 61
 			
35  
-			<!-- Include the necessary framework libraries in the class path -->
36  
-			<arg line="-l '${flex2sdk.lib.dir}'" />
  62
+			<load-config filename="${FLEX_HOME}/frameworks/air-config.xml" />
37 63
 			
38  
-			<!-- Include in the flexunit.swc in the class path -->
39  
-			<arg line="-l ${flexunit.swc}" />
  64
+			<source-path path-element="${src.dir}" />
  65
+			<source-path path-element="${test.src.dir}" />
  66
+
  67
+			<!--
  68
+				Define JSON Constants
  69
+			-->
  70
+			<define name="JSON_TOKEN::UNKNOWN" value="-1" />
  71
+			<define name="JSON_TOKEN::COMMA" value="0" />
  72
+			<define name="JSON_TOKEN::LEFT_BRACE" value="1" />
  73
+			<define name="JSON_TOKEN::RIGHT_BRACE" value="2" />
  74
+			<define name="JSON_TOKEN::LEFT_BRACKET" value="3" />
  75
+			<define name="JSON_TOKEN::RIGHT_BRACKET" value="4" />	
  76
+			<define name="JSON_TOKEN::COLON" value="6" />
  77
+			<define name="JSON_TOKEN::TRUE" value="7" />
  78
+			<define name="JSON_TOKEN::FALSE" value="8" />
  79
+			<define name="JSON_TOKEN::NULL" value="9" />
  80
+			<define name="JSON_TOKEN::STRING" value="10" />
  81
+			<define name="JSON_TOKEN::NUMBER" value="11" />
  82
+			<define name="JSON_TOKEN::NAN" value="12" />
40 83
 			
41  
-			<!-- Include locale-specific items in the path -->
42  
-			<arg line="-locale ${flex2sdk.locale}" />
43  
-			<arg line="-l '${flex2sdk.locale.dir}'" />
44  
-		</exec>
  84
+			<!-- The TestRunner needs the flexunit libraries in the build/libs folder -->
  85
+			<library-path dir="${build.libs.dir}" append="true">
  86
+				<include name="*.swc" />
  87
+			</library-path>
  88
+
  89
+			<!-- Sets java.awt.headless=true so font compilation works in headless environments -->
  90
+			<compiler.headless-server>true</compiler.headless-server>
  91
+		</mxmlc>
  92
+
  93
+		<echo message="The ${test.application.name}.swf test runner has been created in ${test.bin.dir}" />
45 94
 	</target>
46 95
 	
47  
-	<!--
48  
-		Runs the unit tests for the library in the stand-alone Flash Player
49  
-	-->
50  
-	<target name="test" depends="compileTests">
51  
-		<!--
52  
-			If/When we add support for determinig the status of unit tests
53  
-			as part of the ANT build process, we need to change the spawn to
54  
-			"no" so that ANT waits until the test runner closes before
55  
-			proceeding.
56  
-		-->
57  
-		<exec executable="${flashDebugPlayer.exe}" spawn="yes">
58  
-			<arg line="${bin.dir}/${testRunner.name}.swf" />
59  
-		</exec>
  96
+	<target name="runTestsAndReport" depends="init" description="Launches the test runner, captures results, generates test report artifacts.">
  97
+		<!-- Run FlexUnit Ant Task to execute the unit tests and capture reporting data -->
  98
+		<taskdef resource="flexUnitTasks.tasks" classpath="${build.libs.dir}/flexUnitTasks-4.0.0.jar" />
  99
+		<flexunit swf="${test.bin.dir}/${test.application.name}.swf" toDir="${report.dir}"
  100
+			haltonfailure="false" verbose="false" localTrusted="false" player="air" />
  101
+
  102
+		<!-- Generate html JUnit-style reports based on test results -->
  103
+		<junitreport todir="${report.dir}">
  104
+			<fileset dir="${report.dir}">
  105
+				<include name="TEST-*.xml" />
  106
+			</fileset>
  107
+			<report format="frames" todir="${report.html.dir}" />
  108
+		</junitreport>
  109
+
  110
+		<echo message="The unit test reports have been created in ${report.dir}" />
60 111
 	</target>
  112
+
  113
+	<target name="test" depends="init, compileTestRunner, runTestsAndReport" description="Compiles unit tests and generates test report artiacts." />
  114
+	
  115
+	<!-- ======================================= -->
  116
+	<!-- Compile and Document -->
  117
+	<!-- ======================================= -->
61 118
 	
62  
-	<!--
63  
-		Compile all of the classes under the "src" tree into a .swc file
64  
-	-->
65  
-	<target name="lib" depends="properties">
66  
-		<exec executable="${compc.exe}" dir="${basedir}">
67  
-			<!-- Specify the name of the output file -->
68  
-			<arg line="-o '${bin.dir}/${library.name}.swc'" />
  119
+	<target name="compile" depends="init" description="Compile the library .swc file">
  120
+		<compc output="${bin.dir}/${library.name}.swc"
  121
+			debug="false" optimize="true">
69 122
 			
70  
-			<!-- Specify the main source path as "src" -->
71  
-			<arg line="-sp ${src.dir}" />
  123
+			<load-config filename="${FLEX_HOME}/frameworks/air-config.xml" />
72 124
 			
73  
-			<!-- Include all of the classes in the "src" tree -->
74  
-			<arg line="-is ${src.dir}" />
75  
-		</exec>
  125
+			<!--
  126
+				Define JSON Constants
  127
+			-->
  128
+			<define name="JSON_TOKEN::UNKNOWN" value="-1" />
  129
+			<define name="JSON_TOKEN::COMMA" value="0" />
  130
+			<define name="JSON_TOKEN::LEFT_BRACE" value="1" />
  131
+			<define name="JSON_TOKEN::RIGHT_BRACE" value="2" />
  132
+			<define name="JSON_TOKEN::LEFT_BRACKET" value="3" />
  133
+			<define name="JSON_TOKEN::RIGHT_BRACKET" value="4" />	
  134
+			<define name="JSON_TOKEN::COLON" value="6" />
  135
+			<define name="JSON_TOKEN::TRUE" value="7" />
  136
+			<define name="JSON_TOKEN::FALSE" value="8" />
  137
+			<define name="JSON_TOKEN::NULL" value="9" />
  138
+			<define name="JSON_TOKEN::STRING" value="10" />
  139
+			<define name="JSON_TOKEN::NUMBER" value="11" />
  140
+			<define name="JSON_TOKEN::NAN" value="12" />
  141
+			
  142
+			<source-path path-element="${src.dir}" />
  143
+			<include-sources dir="${src.dir}" includes="*" />
  144
+		</compc>
76 145
 	</target>
77 146
 	
78  
-	<!--
79  
-		Generate ASDoc output for the library
80  
-	-->
81  
-	<target name="docs" depends="properties">
82  
-		<!-- Clean out the contents of the doc directory, without delete "docs" -->
83  
-		<!--
84  
-		<delete includeemptydirs="true">
85  
-			<fileset dir="${docs.dir}" includes="**/*" />
86  
-		</delete>
87  
-		-->
88  
-		
89  
-		<exec executable="${asdoc.exe}" spawn="no">
  147
+	<target name="docs" depends="init" description="Generate ASDoc documentation">
  148
+		<java jar="${FLEX_HOME}/lib/asdoc.jar" 
  149
+			dir="${FLEX_HOME}/frameworks" fork="true" failonerror="true">
  150
+			
  151
+			<arg line="-load-config '${FLEX_HOME}/frameworks/air-config.xml'" />
  152
+			
90 153
 			<!-- Place the documentation in the "docs" directory -->
91  
-			<arg line="-o ${docs.dir}" />
  154
+			<arg line="-output ${docs.dir}" />
92 155
 			
93 156
 			<!-- Specify the main source path as "src" -->
94  
-			<arg line="-sp ${src.dir}" />
  157
+			<arg line="-source-path ${src.dir}" />
95 158
 			
96 159
 			<!-- Document all of the classes in the "src" tree -->
97  
-			<arg line="-ds ${src.dir} " />
  160
+			<arg line="-doc-sources ${src.dir} " />
98 161
 			
99 162
 			<!-- Include the library name in the window title -->
100 163
 			<arg line="-window-title 'Adobe ActionScript 3.0 Core Library - ${library.name}' "/>
101  
-		</exec>
  164
+			
  165
+			<!-- Define JSON Constants -->
  166
+			<arg line="-define+=JSON_TOKEN::UNKNOWN,-1 -define+=JSON_TOKEN::COMMA,0 -define+=JSON_TOKEN::LEFT_BRACE,1 -define+=JSON_TOKEN::RIGHT_BRACE,2 -define+=JSON_TOKEN::LEFT_BRACKET,3 -define+=JSON_TOKEN::RIGHT_BRACKET,4 -define+=JSON_TOKEN::COLON,6 -define+=JSON_TOKEN::TRUE,7 -define+=JSON_TOKEN::FALSE,8 -define+=JSON_TOKEN::NULL,9 -define+=JSON_TOKEN::STRING,10 -define+=JSON_TOKEN::NUMBER,11 -define+=JSON_TOKEN::NAN,12" />
  167
+		</java>
  168
+		
  169
+		<echo message="Documentation has been created in ${docs.dir}" />
102 170
 	</target>
103 171
 
104 172
 </project>
BIN  build/libs/flexUnitTasks-4.0.0.jar
Binary file not shown
BIN  build/libs/flexunit-4.0.0.swc
Binary file not shown
BIN  build/libs/flexunit-aircilistener-4.0.0.swc
Binary file not shown
BIN  build/libs/flexunit-cilistener-4.0.0.swc
Binary file not shown
BIN  build/libs/flexunit-flexcoverlistener-4.0.0.swc
Binary file not shown
BIN  build/libs/flexunit-uilistener-4.0.0.swc
Binary file not shown
2  src/com/adobe/air/crypto/EncryptionKeyGenerator.as
@@ -146,7 +146,7 @@ package com.adobe.air.crypto
146 146
 		 * <p>For any given 
147 147
 		 * password, calling the <code>getEncryptionKey()</code> method from the same AIR application 
148 148
 		 * running in the same user account on the same machine, the encryption key result is 
149  
-		 * the same.
  149
+		 * the same.</p>
150 150
 		 * 
151 151
 		 * <p>This method is designed to create an encryption key suitable for providing the highest 
152 152
 		 * level of data privacy and security. In order to achieve that level of security, your 
2  src/com/adobe/net/IURIResolver.as
@@ -54,7 +54,7 @@ package com.adobe.net
54 54
 	 * of URI.</p>
55 55
 	 * 
56 56
 	 * <p>URI will call this before performing URI comparisons in the
57  
-	 * URI.getRelation() and URI.getCommonParent() functions.
  57
+	 * URI.getRelation() and URI.getCommonParent() functions.</p>
58 58
 	 * 
59 59
 	 * @see URI.getRelation
60 60
 	 * @see URI.getCommonParent
10  src/com/adobe/net/URI.as
@@ -51,7 +51,7 @@ package com.adobe.net
51 51
 	 * <p>URI's fall into one of three categories:
52 52
 	 * <ul>
53 53
 	 *  <li>&lt;scheme&gt;:&lt;scheme-specific-part&gt;#&lt;fragment&gt;		(non-hierarchical)</li>
54  
-	 *  <li>&lt;scheme&gt;:<authority&gt;&lt;path&gt;?&lt;query&gt;#&lt;fragment&gt;	(hierarchical)</li>
  54
+	 *  <li>&lt;scheme&gt;:&lt;authority&gt;&lt;path&gt;?&lt;query&gt;#&lt;fragment&gt;	(hierarchical)</li>
55 55
 	 *  <li>&lt;path&gt;?&lt;query&gt;#&lt;fragment&gt;						(relative hierarchical)</li>
56 56
 	 * </ul></p>
57 57
 	 * 
@@ -307,7 +307,7 @@ package com.adobe.net
307 307
 		 *
308 308
 		 * Given a URI in string format, parse that sucker into its basic
309 309
 		 * components and assign them to this object.  A URI is of the form:
310  
-		 *    <scheme>:<authority><path>?<query>#<fragment>
  310
+		 *    &lt;scheme&gt;:&lt;authority&gt;&lt;path&gt;?&lt;query&gt;#&lt;fragment&gt;
311 311
 		 *
312 312
 		 * For simplicity, we parse the URI in the following order:
313 313
 		 * 		
@@ -348,7 +348,7 @@ package com.adobe.net
348 348
 		 * will result in parsing errors.  This function can handle
349 349
 		 * 	 - absolute hierarchical (e.g. "http://something.com/index.html),
350 350
 		 *   - relative hierarchical (e.g. "../images/flower.gif"), or
351  
-		 *   - non-hierarchical URIs (e.g. "mailto:jsmith@fungoo.com").
  351
+		 *   - non-hierarchical URIs (e.g. "mailto:jsmith&#64;fungoo.com").
352 352
 		 * 
353 353
 		 * Anything else will probably result in a parsing error, or a bogus
354 354
 		 * URI object.
@@ -893,8 +893,8 @@ package com.adobe.net
893 893
 		
894 894
 		/**
895 895
 		 * The non-hierarchical part of the URI.  For example, if
896  
-		 * this URI object represents "mailto:somebody@company.com",
897  
-		 * this will contain "somebody@company.com".  This is valid only
  896
+		 * this URI object represents "mailto:somebody&#64;company.com",
  897
+		 * this will contain "somebody&#64;company.com".  This is valid only
898 898
 		 * for non-hierarchical URI's.  
899 899
 		 */
900 900
 		public function get nonHierarchical() : String
12  src/com/adobe/serialization/json/JSON.as
@@ -32,7 +32,7 @@
32 32
 
33 33
 package com.adobe.serialization.json
34 34
 {
35  
-
  35
+	
36 36
 	/**
37 37
 	 * This class provides encoding and decoding of the JSON format.
38 38
 	 *
@@ -45,7 +45,7 @@ package com.adobe.serialization.json
45 45
 	 *		var myObject:Object = JSON.decode( jsonString );
46 46
 	 *	</code>
47 47
 	 */
48  
-	public class JSON
  48
+	public final class JSON
49 49
 	{
50 50
 		/**
51 51
 		 * Encodes a object into a JSON string.
@@ -57,13 +57,13 @@ package com.adobe.serialization.json
57 57
 		 * @tiptext
58 58
 		 */
59 59
 		public static function encode( o:Object ):String
60  
-		{	
  60
+		{
61 61
 			return new JSONEncoder( o ).getString();
62 62
 		}
63 63
 		
64 64
 		/**
65 65
 		 * Decodes a JSON string into a native object.
66  
-		 * 
  66
+		 *
67 67
 		 * @param s The JSON string representing the object
68 68
 		 * @param strict Flag indicating if the decoder should strictly adhere
69 69
 		 * 		to the JSON standard or not.  The default of <code>true</code>
@@ -77,8 +77,8 @@ package com.adobe.serialization.json
77 77
 		 * @tiptext
78 78
 		 */
79 79
 		public static function decode( s:String, strict:Boolean = true ):*
80  
-		{	
81  
-			return new JSONDecoder( s, strict ).getValue();	
  80
+		{
  81
+			return new JSONDecoder( s, strict ).getValue();
82 82
 		}
83 83
 	
84 84
 	}
143  src/com/adobe/serialization/json/JSONDecoder.as
@@ -34,9 +34,9 @@ package com.adobe.serialization.json
34 34
 {
35 35
 	
36 36
 	public class JSONDecoder
37  
-	{	
38  
-	
39  
-		/** 
  37
+	{
  38
+		
  39
+		/**
40 40
 		 * Flag indicating if the parser should be strict about the format
41 41
 		 * of the JSON string it is attempting to decode.
42 42
 		 */
@@ -52,7 +52,7 @@ package com.adobe.serialization.json
52 52
 		private var token:JSONToken;
53 53
 		
54 54
 		/**
55  
-		 * Constructs a new JSONDecoder to parse a JSON string 
  55
+		 * Constructs a new JSONDecoder to parse a JSON string
56 56
 		 * into a native object.
57 57
 		 *
58 58
 		 * @param s The JSON string to be converted
@@ -64,7 +64,7 @@ package com.adobe.serialization.json
64 64
 		 * @tiptext
65 65
 		 */
66 66
 		public function JSONDecoder( s:String, strict:Boolean )
67  
-		{	
  67
+		{
68 68
 			this.strict = strict;
69 69
 			tokenizer = new JSONTokenizer( s, strict );
70 70
 			
@@ -97,15 +97,39 @@ package com.adobe.serialization.json
97 97
 		 * Returns the next token from the tokenzier reading
98 98
 		 * the JSON string
99 99
 		 */
100  
-		private function nextToken():JSONToken
  100
+		private final function nextToken():JSONToken
101 101
 		{
102 102
 			return token = tokenizer.getNextToken();
103 103
 		}
104 104
 		
105 105
 		/**
  106
+		 * Returns the next token from the tokenizer reading
  107
+		 * the JSON string and verifies that the token is valid.
  108
+		 */
  109
+		private final function nextValidToken():JSONToken
  110
+		{
  111
+			token = tokenizer.getNextToken();
  112
+			checkValidToken();
  113
+			
  114
+			return token;
  115
+		}
  116
+		
  117
+		/**
  118
+		 * Verifies that the token is valid.
  119
+		 */
  120
+		private final function checkValidToken():void
  121
+		{
  122
+			// Catch errors when the input stream ends abruptly
  123
+			if ( token == null )
  124
+			{
  125
+				tokenizer.parseError( "Unexpected end of input" );
  126
+			}
  127
+		}
  128
+		
  129
+		/**
106 130
 		 * Attempt to parse an array.
107 131
 		 */
108  
-		private function parseArray():Array
  132
+		private final function parseArray():Array
109 133
 		{
110 134
 			// create an array internally that we're going to attempt
111 135
 			// to parse from the tokenizer
@@ -113,25 +137,25 @@ package com.adobe.serialization.json
113 137
 			
114 138
 			// grab the next token from the tokenizer to move
115 139
 			// past the opening [
116  
-			nextToken();
  140
+			nextValidToken();
117 141
 			
118 142
 			// check to see if we have an empty array
119  
-			if ( token.type == JSONTokenType.RIGHT_BRACKET )
  143
+			if ( token.type == JSON_TOKEN::RIGHT_BRACKET )
120 144
 			{
121 145
 				// we're done reading the array, so return it
122 146
 				return a;
123 147
 			}
124 148
 			// in non-strict mode an empty array is also a comma
125 149
 			// followed by a right bracket
126  
-			else if ( !strict && token.type == JSONTokenType.COMMA )
  150
+			else if ( !strict && token.type == JSON_TOKEN::COMMA )
127 151
 			{
128 152
 				// move past the comma
129  
-				nextToken();
  153
+				nextValidToken();
130 154
 				
131 155
 				// check to see if we're reached the end of the array
132  
-				if ( token.type == JSONTokenType.RIGHT_BRACKET )
  156
+				if ( token.type == JSON_TOKEN::RIGHT_BRACKET )
133 157
 				{
134  
-					return a;	
  158
+					return a;
135 159
 				}
136 160
 				else
137 161
 				{
@@ -145,16 +169,16 @@ package com.adobe.serialization.json
145 169
 			{
146 170
 				// read in the value and add it to the array
147 171
 				a.push( parseValue() );
148  
-			
  172
+				
149 173
 				// after the value there should be a ] or a ,
150  
-				nextToken();
  174
+				nextValidToken();
151 175
 				
152  
-				if ( token.type == JSONTokenType.RIGHT_BRACKET )
  176
+				if ( token.type == JSON_TOKEN::RIGHT_BRACKET )
153 177
 				{
154 178
 					// we're done reading the array, so return it
155 179
 					return a;
156 180
 				}
157  
-				else if ( token.type == JSONTokenType.COMMA )
  181
+				else if ( token.type == JSON_TOKEN::COMMA )
158 182
 				{
159 183
 					// move past the comma and read another value
160 184
 					nextToken();
@@ -163,8 +187,10 @@ package com.adobe.serialization.json
163 187
 					// if the decoder is not in strict mode
164 188
 					if ( !strict )
165 189
 					{
  190
+						checkValidToken();
  191
+						
166 192
 						// Reached ",]" as the end of the array, so return it
167  
-						if ( token.type == JSONTokenType.RIGHT_BRACKET )
  193
+						if ( token.type == JSON_TOKEN::RIGHT_BRACKET )
168 194
 						{
169 195
 							return a;
170 196
 						}
@@ -175,40 +201,41 @@ package com.adobe.serialization.json
175 201
 					tokenizer.parseError( "Expecting ] or , but found " + token.value );
176 202
 				}
177 203
 			}
178  
-            return null;
  204
+			
  205
+			return null;
179 206
 		}
180 207
 		
181 208
 		/**
182 209
 		 * Attempt to parse an object.
183 210
 		 */
184  
-		private function parseObject():Object
  211
+		private final function parseObject():Object
185 212
 		{
186 213
 			// create the object internally that we're going to
187 214
 			// attempt to parse from the tokenizer
188 215
 			var o:Object = new Object();
189  
-						
  216
+			
190 217
 			// store the string part of an object member so
191 218
 			// that we can assign it a value in the object
192 219
 			var key:String
193 220
 			
194 221
 			// grab the next token from the tokenizer
195  
-			nextToken();
  222
+			nextValidToken();
196 223
 			
197 224
 			// check to see if we have an empty object
198  
-			if ( token.type == JSONTokenType.RIGHT_BRACE )
  225
+			if ( token.type == JSON_TOKEN::RIGHT_BRACE )
199 226
 			{
200 227
 				// we're done reading the object, so return it
201 228
 				return o;
202 229
 			}
203 230
 			// in non-strict mode an empty object is also a comma
204 231
 			// followed by a right bracket
205  
-			else if ( !strict && token.type == JSONTokenType.COMMA )
  232
+			else if ( !strict && token.type == JSON_TOKEN::COMMA )
206 233
 			{
207 234
 				// move past the comma
208  
-				nextToken();
  235
+				nextValidToken();
209 236
 				
210 237
 				// check to see if we're reached the end of the object
211  
-				if ( token.type == JSONTokenType.RIGHT_BRACE )
  238
+				if ( token.type == JSON_TOKEN::RIGHT_BRACE )
212 239
 				{
213 240
 					return o;
214 241
 				}
@@ -222,31 +249,31 @@ package com.adobe.serialization.json
222 249
 			// loop because we could have any amount of members
223 250
 			while ( true )
224 251
 			{
225  
-				if ( token.type == JSONTokenType.STRING )
  252
+				if ( token.type == JSON_TOKEN::STRING )
226 253
 				{
227 254
 					// the string value we read is the key for the object
228 255
 					key = String( token.value );
229 256
 					
230 257
 					// move past the string to see what's next
231  
-					nextToken();
  258
+					nextValidToken();
232 259
 					
233 260
 					// after the string there should be a :
234  
-					if ( token.type == JSONTokenType.COLON )
235  
-					{	
  261
+					if ( token.type == JSON_TOKEN::COLON )
  262
+					{
236 263
 						// move past the : and read/assign a value for the key
237 264
 						nextToken();
238  
-						o[key] = parseValue();	
  265
+						o[ key ] = parseValue();
239 266
 						
240 267
 						// move past the value to see what's next
241  
-						nextToken();
  268
+						nextValidToken();
242 269
 						
243 270
 						// after the value there's either a } or a ,
244  
-						if ( token.type == JSONTokenType.RIGHT_BRACE )
  271
+						if ( token.type == JSON_TOKEN::RIGHT_BRACE )
245 272
 						{
246 273
 							// we're done reading the object, so return it
247  
-							return o;	
  274
+							return o;
248 275
 						}
249  
-						else if ( token.type == JSONTokenType.COMMA )
  276
+						else if ( token.type == JSON_TOKEN::COMMA )
250 277
 						{
251 278
 							// skip past the comma and read another member
252 279
 							nextToken();
@@ -255,8 +282,10 @@ package com.adobe.serialization.json
255 282
 							// if the decoder is not in strict mode
256 283
 							if ( !strict )
257 284
 							{
  285
+								checkValidToken();
  286
+								
258 287
 								// Reached ",}" as the end of the object, so return it
259  
-								if ( token.type == JSONTokenType.RIGHT_BRACE )
  288
+								if ( token.type == JSON_TOKEN::RIGHT_BRACE )
260 289
 								{
261 290
 									return o;
262 291
 								}
@@ -273,40 +302,36 @@ package com.adobe.serialization.json
273 302
 					}
274 303
 				}
275 304
 				else
276  
-				{	
  305
+				{
277 306
 					tokenizer.parseError( "Expecting string but found " + token.value );
278 307
 				}
279 308
 			}
280  
-            return null;
  309
+			return null;
281 310
 		}
282 311
 		
283 312
 		/**
284 313
 		 * Attempt to parse a value
285 314
 		 */
286  
-		private function parseValue():Object
  315
+		private final function parseValue():Object
287 316
 		{
288  
-			// Catch errors when the input stream ends abruptly
289  
-			if ( token == null )
290  
-			{
291  
-				tokenizer.parseError( "Unexpected end of input" );
292  
-			}
293  
-					
  317
+			checkValidToken();
  318
+			
294 319
 			switch ( token.type )
295 320
 			{
296  
-				case JSONTokenType.LEFT_BRACE:
  321
+				case JSON_TOKEN::LEFT_BRACE:
297 322
 					return parseObject();
298  
-					
299  
-				case JSONTokenType.LEFT_BRACKET:
  323
+				
  324
+				case JSON_TOKEN::LEFT_BRACKET:
300 325
 					return parseArray();
301  
-					
302  
-				case JSONTokenType.STRING:
303  
-				case JSONTokenType.NUMBER:
304  
-				case JSONTokenType.TRUE:
305  
-				case JSONTokenType.FALSE:
306  
-				case JSONTokenType.NULL:
  326
+				
  327
+				case JSON_TOKEN::STRING:
  328
+				case JSON_TOKEN::NUMBER:
  329
+				case JSON_TOKEN::TRUE:
  330
+				case JSON_TOKEN::FALSE:
  331
+				case JSON_TOKEN::NULL:
307 332
 					return token.value;
308  
-					
309  
-				case JSONTokenType.NAN:
  333
+				
  334
+				case JSON_TOKEN::NAN:
310 335
 					if ( !strict )
311 336
 					{
312 337
 						return token.value;
@@ -315,13 +340,13 @@ package com.adobe.serialization.json
315 340
 					{
316 341
 						tokenizer.parseError( "Unexpected " + token.value );
317 342
 					}
318  
-
  343
+				
319 344
 				default:
320 345
 					tokenizer.parseError( "Unexpected " + token.value );
321  
-					
  346
+			
322 347
 			}
323 348
 			
324  
-            return null;
  349
+			return null;
325 350
 		}
326 351
 	}
327 352
 }
157  src/com/adobe/serialization/json/JSONEncoder.as
@@ -8,11 +8,11 @@
8 8
 
9 9
   * Redistributions of source code must retain the above copyright notice, 
10 10
     this list of conditions and the following disclaimer.
11  
-  
  11
+
12 12
   * Redistributions in binary form must reproduce the above copyright
13 13
     notice, this list of conditions and the following disclaimer in the 
14 14
     documentation and/or other materials provided with the distribution.
15  
-  
  15
+
16 16
   * Neither the name of Adobe Systems Incorporated nor the names of its 
17 17
     contributors may be used to endorse or promote products derived from 
18 18
     this software without specific prior written permission.
@@ -30,13 +30,14 @@
30 30
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 31
 */
32 32
 
33  
-package com.adobe.serialization.json 
  33
+package com.adobe.serialization.json
34 34
 {
35  
-
  35
+	
36 36
 	import flash.utils.describeType;
37  
-
38  
-	public class JSONEncoder {
39 37
 	
  38
+	public class JSONEncoder
  39
+	{
  40
+		
40 41
 		/** The string that is going to represent the object we're encoding */
41 42
 		private var jsonString:String;
42 43
 		
@@ -48,9 +49,9 @@ package com.adobe.serialization.json
48 49
 		 * @playerversion Flash 9.0
49 50
 		 * @tiptext
50 51
 		 */
51  
-		public function JSONEncoder( value:* ) {
  52
+		public function JSONEncoder( value:* )
  53
+		{
52 54
 			jsonString = convertToString( value );
53  
-		
54 55
 		}
55 56
 		
56 57
 		/**
@@ -62,45 +63,47 @@ package com.adobe.serialization.json
62 63
 		 * @playerversion Flash 9.0
63 64
 		 * @tiptext
64 65
 		 */
65  
-		public function getString():String {
  66
+		public function getString():String
  67
+		{
66 68
 			return jsonString;
67 69
 		}
68 70
 		
69 71
 		/**
70 72
 		 * Converts a value to it's JSON string equivalent.
71 73
 		 *
72  
-		 * @param value The value to convert.  Could be any 
  74
+		 * @param value The value to convert.  Could be any
73 75
 		 *		type (object, number, array, etc)
74 76
 		 */
75  
-		private function convertToString( value:* ):String {
76  
-			
  77
+		private function convertToString( value:* ):String
  78
+		{
77 79
 			// determine what value is and convert it based on it's type
78  
-			if ( value is String ) {
79  
-				
  80
+			if ( value is String )
  81
+			{
80 82
 				// escape the string so it's formatted correctly
81 83
 				return escapeString( value as String );
82  
-				
83  
-			} else if ( value is Number ) {
84  
-				
  84
+			}
  85
+			else if ( value is Number )
  86
+			{
85 87
 				// only encode numbers that finate
86  
-				return isFinite( value as Number) ? value.toString() : "null";
87  
-
88  
-			} else if ( value is Boolean ) {
89  
-				
  88
+				return isFinite( value as Number ) ? value.toString() : "null";
  89
+			}
  90
+			else if ( value is Boolean )
  91
+			{
90 92
 				// convert boolean to string easily
91 93
 				return value ? "true" : "false";
92  
-
93  
-			} else if ( value is Array ) {
94  
-			
  94
+			}
  95
+			else if ( value is Array )
  96
+			{
95 97
 				// call the helper method to convert an array
96 98
 				return arrayToString( value as Array );
97  
-			
98  
-			} else if ( value is Object && value != null ) {
99  
-			
  99
+			}
  100
+			else if ( value is Object && value != null )
  101
+			{
100 102
 				// call the helper method to convert an object
101 103
 				return objectToString( value );
102 104
 			}
103  
-            return "null";
  105
+
  106
+			return "null";
104 107
 		}
105 108
 		
106 109
 		/**
@@ -110,7 +113,8 @@ package com.adobe.serialization.json
110 113
 		 * @return The string with escaped special characters
111 114
 		 * 		according to the JSON specification
112 115
 		 */
113  
-		private function escapeString( str:String ):String {
  116
+		private function escapeString( str:String ):String
  117
+		{
114 118
 			// create a string to store the string's jsonstring value
115 119
 			var s:String = "";
116 120
 			// current character in the string we're processing
@@ -119,48 +123,49 @@ package com.adobe.serialization.json
119 123
 			var len:Number = str.length;
120 124
 			
121 125
 			// loop over all of the characters in the string
122  
-			for ( var i:int = 0; i < len; i++ ) {
123  
-			
  126
+			for ( var i:int = 0; i < len; i++ )
  127
+			{
124 128
 				// examine the character to determine if we have to escape it
125 129
 				ch = str.charAt( i );
126  
-				switch ( ch ) {
127  
-				
128  
-					case '"':	// quotation mark
  130
+				switch ( ch )
  131
+				{
  132
+					case '"': // quotation mark
129 133
 						s += "\\\"";
130 134
 						break;
131  
-						
  135
+					
132 136
 					//case '/':	// solidus
133 137
 					//	s += "\\/";
134 138
 					//	break;
135  
-						
136  
-					case '\\':	// reverse solidus
  139
+					
  140
+					case '\\': // reverse solidus
137 141
 						s += "\\\\";
138 142
 						break;
139  
-						
140  
-					case '\b':	// bell
  143
+					
  144
+					case '\b': // bell
141 145
 						s += "\\b";
142 146
 						break;
143  
-						
144  
-					case '\f':	// form feed
  147
+					
  148
+					case '\f': // form feed
145 149
 						s += "\\f";
146 150
 						break;
147  
-						
148  
-					case '\n':	// newline
  151
+					
  152
+					case '\n': // newline
149 153
 						s += "\\n";
150 154
 						break;
151  
-						
152  
-					case '\r':	// carriage return
  155
+					
  156
+					case '\r': // carriage return
153 157
 						s += "\\r";
154 158
 						break;
155  
-						
156  
-					case '\t':	// horizontal tab
  159
+					
  160
+					case '\t': // horizontal tab
157 161
 						s += "\\t";
158 162
 						break;
159  
-						
160  
-					default:	// everything else
  163
+					
  164
+					default: // everything else
161 165
 						
162 166
 						// check for a control character and escape as unicode
163  
-						if ( ch < ' ' ) {
  167
+						if ( ch < ' ' )
  168
+						{
164 169
 							// get the hex digit(s) of the character (either 1 or 2 digits)
165 170
 							var hexCode:String = ch.charCodeAt( 0 ).toString( 16 );
166 171
 							
@@ -170,16 +175,18 @@ package com.adobe.serialization.json
170 175
 							
171 176
 							// create the unicode escape sequence with 4 hex digits
172 177
 							s += "\\u" + zeroPad + hexCode;
173  
-						} else {
174  
-						
  178
+						}
  179
+						else
  180
+						{
  181
+							
175 182
 							// no need to do any special encoding, just pass-through
176 183
 							s += ch;
177 184
 							
178 185
 						}
179  
-				}	// end switch
  186
+				} // end switch
180 187
 				
181  
-			}	// end for loop
182  
-						
  188
+			} // end for loop
  189
+			
183 190
 			return "\"" + s + "\"";
184 191
 		}
185 192
 		
@@ -189,22 +196,26 @@ package com.adobe.serialization.json
189 196
 		 * @param a The array to convert
190 197
 		 * @return The JSON string representation of <code>a</code>
191 198
 		 */
192  
-		private function arrayToString( a:Array ):String {
  199
+		private function arrayToString( a:Array ):String
  200
+		{
193 201
 			// create a string to store the array's jsonstring value
194 202
 			var s:String = "";
195 203
 			
196 204
 			// loop over the elements in the array and add their converted
197 205
 			// values to the string
198  
-			for ( var i:int = 0; i < a.length; i++ ) {
  206
+			var length:int = a.length;
  207
+			for ( var i:int = 0; i < length; i++ )
  208
+			{
199 209
 				// when the length is 0 we're adding the first element so
200 210
 				// no comma is necessary
201  
-				if ( s.length > 0 ) {
  211
+				if ( s.length > 0 )
  212
+				{
202 213
 					// we've already added an element, so add the comma separator
203 214
 					s += ","
204 215
 				}
205 216
 				
206 217
 				// convert the value to a string
207  
-				s += convertToString( a[i] );	
  218
+				s += convertToString( a[ i ] );
208 219
 			}
209 220
 			
210 221
 			// KNOWN ISSUE:  In ActionScript, Arrays can also be associative
@@ -222,7 +233,7 @@ package com.adobe.serialization.json
222 233
 			// A possible solution is to instead encode the Array as an Object
223 234
 			// but then it won't get decoded correctly (and won't be an
224 235
 			// Array instance)
225  
-						
  236
+			
226 237
 			// close the array and return it's string value
227 238
 			return "[" + s + "]";
228 239
 		}
@@ -252,7 +263,7 @@ package com.adobe.serialization.json
252 263
 				for ( var key:String in o )
253 264
 				{
254 265
 					// assign value to a variable for quick lookup
255  
-					value = o[key];
  266
+					value = o[ key ];
256 267
 					
257 268
 					// don't add function's to the JSON string
258 269
 					if ( value is Function )
@@ -263,7 +274,8 @@ package com.adobe.serialization.json
263 274
 					
264 275
 					// when the length is 0 we're adding the first item so
265 276
 					// no comma is necessary
266  
-					if ( s.length > 0 ) {
  277
+					if ( s.length > 0 )
  278
+					{
267 279
 						// we've already added an item, so add the comma separator
268 280
 						s += ","
269 281
 					}
@@ -275,13 +287,13 @@ package com.adobe.serialization.json
275 287
 			{
276 288
 				// Loop over all of the variables and accessors in the class and 
277 289
 				// serialize them along with their values.
278  
-				for each ( var v:XML in classInfo..*.( 
  290
+				for each ( var v:XML in classInfo..*.(
279 291
 					name() == "variable"
280 292
 					||
281  
-					( 
  293
+					(
282 294
 						name() == "accessor"
283 295
 						// Issue #116 - Make sure accessors are readable
284  
-						&& attribute( "access" ).charAt( 0 ) == "r" ) 
  296
+						&& attribute( "access" ).charAt( 0 ) == "r" )
285 297
 					) )
286 298
 				{
287 299
 					// Issue #110 - If [Transient] metadata exists, then we should skip
@@ -292,21 +304,20 @@ package com.adobe.serialization.json
292 304
 					
293 305
 					// When the length is 0 we're adding the first item so
294 306
 					// no comma is necessary
295  
-					if ( s.length > 0 ) {
  307
+					if ( s.length > 0 )
  308
+					{
296 309
 						// We've already added an item, so add the comma separator
297 310
 						s += ","
298 311
 					}
299 312
 					
300  
-					s += escapeString( v.@name.toString() ) + ":" 
301  
-							+ convertToString( o[ v.@name ] );
  313
+					s += escapeString( v.@name.toString() ) + ":"
  314
+						+ convertToString( o[ v.@name ] );
302 315
 				}
303  
-				
304 316
 			}
305 317
 			
306 318
 			return "{" + s + "}";
307 319
 		}
308  
-
309  
-		
310  
-	}
311 320
 	
312  
-}
  321
+	}
  322
+
  323
+}
25  src/com/adobe/serialization/json/JSONParseError.as
@@ -30,20 +30,22 @@
30 30
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 31
 */
32 32
 
33  
-package com.adobe.serialization.json {
34  
-