private void initialize ( Map context ) { // Guard against recursion. context . put ( jsTypeTree , this ) ; // Create temporary accumulators for the contents of the fields and variants instance // variables. List tmpFields = new ArrayList ( ) ; List tmpVariants = new ArrayList ( ) ; // Perform tasks assigned to the recursive 'number' subroutine (see comment there) number ( jsTypeTree , context , false , 0 , tmpFields , tmpVariants ) ; // Move information from temporaries into permanent instance variables fields = ( JSField [ ] ) tmpFields . toArray ( new JSField [ 0 ] ) ; variants = ( JSVariant [ ] ) tmpVariants . toArray ( new JSVariant [ 0 ] ) ; // Compute the contents of the 'boxed' instance variable, which is deriveable from the // contents of those JSVariants which have found their way into 'fields.' These are // all intended to be boxed variants because they were detected to be underneath // JSRepeated nodes during the 'number' process. int boxLen = 0 ; // accumulate total length of boxed array for ( int i = 0 ; i < fields . length ; i ++ ) if ( fields [ i ] instanceof JSVariant ) // On the first pass, we box the variant and accumulate its accessor count boxLen += ( ( JSVariant ) fields [ i ] ) . box ( context ) . getAccessorCount ( ) ; boxed = new int [ boxLen ] [ ] ; int boxIndex = 0 ; // On the second pass through the boxed variants, we get their accessor count a second // time and use it this time to fill in the contents of the 'boxed' instance variable // proper. for ( int i = 0 ; i < fields . length ; i ++ ) if ( fields [ i ] instanceof JSVariant ) for ( int j = 0 ; j < ( ( JSVariant ) fields [ i ] ) . getBoxed ( ) . getAccessorCount ( ) ; j ++ ) boxed [ boxIndex ++ ] = new int [ ] { i , j } ; // Set the 'accessor' property of every JSField in the tree (see comment on // setAccessors). setAccessors ( 0 , this ) ; // Set the multiChoiceCount for each node in the tree. Note this must be done // after boxing any variants found underneath JSRepeated nodes, since boxing changes // the multiChoiceCount. setMultiChoiceCount is a recursive method that will set // counts starting from the leaves working back to the root. jsTypeTree . setMultiChoiceCount ( ) ; // Compute the serialForm if it isn't already there due to the deserializing // constructor if ( serialForm == null ) { // Store the name in a convenient non-null form name = jsTypeTree . getFeatureName ( ) ; if ( name == null ) name = "" ; try { byte [ ] utfname = name . getBytes ( "UTF8" ) ; serialForm = new byte [ 2 + utfname . length + 2 + jsTypeTree . encodedTypeLength ( ) ] ; ArrayUtil . writeShort ( serialForm , 0 , ( short ) utfname . length ) ; System . arraycopy ( utfname , 0 , serialForm , 2 , utfname . length ) ; int limits [ ] = new int [ ] { 2 + utfname . length , serialForm . length } ; JSType . setCount ( serialForm , limits , version ) ; jsTypeTree . encodeType ( serialForm , limits ) ; } catch ( UnsupportedEncodingException e ) { FFDCFilter . processException ( e , "initialize" , "604" ) ; IllegalArgumentException ex = new IllegalArgumentException ( ) ; ex . initCause ( e ) ; throw ex ; } } // Compute the schemaID, which is a 64-bit truncated SHA-1 hash over the serialForm. schemaID = CryptoHash . hash ( serialForm ) ; schemaLongID = Long . valueOf ( schemaID ) ; }
calculates the multiChoiceCounts for each node in the tree .