question: Element createApiMap ( TreeSet < String > packageNames , Document outputObject ) { ArrayList < String > alreadyAdded = new ArrayList < String > ( ) ; Element apiMap = outputObject . createElement ( "apiMap" ) ; String addedPackage = null ; String currentPackage = null ; Iterator < String > packages = packageNames . iterator ( ) ; if ( packages == null ) { return apiMap ; } while ( packages . hasNext ( ) ) { currentPackage = packages . next ( ) ; boolean found = false ; for ( int ix = 0 ; ix < alreadyAdded . size ( ) ; ix ++ ) { addedPackage = alreadyAdded . get ( ix ) ; if ( currentPackage . indexOf ( addedPackage ) == 0 && currentPackage . charAt ( addedPackage . length ( ) ) == '.' ) { Element apiItemRef = getPackageNode ( apiMap , addedPackage ) ; Element newApiItemRef = outputObject . createElement ( "apiItemRef" ) ; newApiItemRef . setAttribute ( "href" , currentPackage + ".xml" ) ; apiItemRef . appendChild ( newApiItemRef ) ; alreadyAdded . add ( currentPackage ) ; found = true ; break ; } } if ( ! found ) { Element apiItemRef = outputObject . createElement ( "apiItemRef" ) ; apiItemRef . setAttribute ( "href" , currentPackage + ".xml" ) ; apiMap . appendChild ( apiItemRef ) ; alreadyAdded . add ( currentPackage ) ; } } return apiMap ; }
target:  Creates the nested TOC for packages.