private Map < String , TemplateSourceInfo > retrieveTemplateMap ( ) { Map < String , TemplateSourceInfo > templateMap = new TreeMap < String , TemplateSourceInfo > ( ) ; String remoteSource = mRemoteSourceDir ; if ( ! remoteSource . endsWith ( "/" ) ) { remoteSource = remoteSource + "/" ; } try { HttpClient tsClient = getTemplateServerClient ( remoteSource ) ; HttpClient . Response response = tsClient . setURI ( createTemplateServerRequest ( remoteSource , null ) ) . setPersistent ( true ) . getResponse ( ) ; if ( response != null && response . getStatusCode ( ) == 200 ) { Reader rin = new InputStreamReader ( new BufferedInputStream ( response . getInputStream ( ) ) ) ; StreamTokenizer st = new StreamTokenizer ( rin ) ; st . resetSyntax ( ) ; st . wordChars ( ' ' , ' ' ) ; st . wordChars ( ' ' , ' ' ) ; st . whitespaceChars ( 0 , ' ' ) ; st . parseNumbers ( ) ; st . quoteChar ( ' ' ) ; st . eolIsSignificant ( true ) ; String templateName = null ; int tokenID = 0 ; // ditching the headers by looking for "\r\n\r\n" /* * no longer needed now that HttpClient is being used but leave * in for the moment. * * while (!((tokenID = st.nextToken()) == StreamTokenizer.TT_EOL * && st.nextToken() == StreamTokenizer.TT_EOL) * && tokenID != StreamTokenizer.TT_EOF) { * } */ while ( ( tokenID = st . nextToken ( ) ) != StreamTokenizer . TT_EOF ) { if ( tokenID == ' ' || tokenID == StreamTokenizer . TT_WORD ) { templateName = st . sval ; } else if ( tokenID == StreamTokenizer . TT_NUMBER && templateName != null ) { templateName = templateName . substring ( 1 ) ; //System.out.println(templateName); templateMap . put ( templateName . replace ( ' ' , ' ' ) , new TemplateSourceInfo ( templateName , remoteSource , ( long ) st . nval ) ) ; templateName = null ; } } } } catch ( IOException ioe ) { ioe . printStackTrace ( ) ; } return templateMap ; }
creates a map relating the templates found on the template server to the timestamp on the sourcecode