/[projects]/android/TrainInfoService/WebContent/namesearch2.jsp
ViewVC logotype

Contents of /android/TrainInfoService/WebContent/namesearch2.jsp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1517 - (show annotations) (download)
Sun Jun 12 07:28:00 2011 UTC (12 years, 11 months ago) by torben
File size: 1325 byte(s)
add count parameter to namesearch views
1 <%@ page import="java.util.*" %>
2 <%@ page import="java.io.*" %>
3 <%@ page import="dk.thoerup.traininfoservice.RequestPlotter" %>
4 <%@ page import="dk.thoerup.traininfoservice.RequestPlotter" %>
5 <%@ page import="dk.thoerup.genericjavautils.HttpUtil" %>
6
7 <h2>searches byName</h2>
8
9 <table border='0'>
10 <tr><th>name</th><th>count</th></tr>
11 <%
12
13 int fcount = 14;
14 if (request.getParameter("count") != null) {
15 fcount = Integer.parseInt( request.getParameter("count") );
16 }
17 File files[] = RequestPlotter.getFiles(fcount);
18 TreeMap<String,Integer> names = new TreeMap<String,Integer>();
19
20 for (File f : files ) {
21 if ( !f.exists() ) {
22 continue;
23 }
24
25 InputStream input = new FileInputStream(f);
26
27
28 BufferedReader in = new BufferedReader( new InputStreamReader(input) );
29 String line;
30 while ( (line=in.readLine()) != null) {
31 if (line.indexOf("LocateStation") == -1 ){
32 continue;
33 }
34
35 if (line.indexOf("name=") == -1 ) {
36 continue;
37 }
38 String parts[] = line.split(" ");
39
40 String uri = parts[5];
41 String name = HttpUtil.decodeUri(uri).get("name");
42 Integer count = names.get(name);
43 if (count == null) {
44 count = 0;
45 }
46 names.put(name, count + 1);
47 }
48 }
49 for (Map.Entry<String,Integer> entry : names.entrySet() ) {
50 %>
51 <tr><td><%= entry.getKey() %></td><td><%= entry.getValue() %></td></tr>
52 <%
53 }
54
55 %>
56
57
58 </table>

  ViewVC Help
Powered by ViewVC 1.1.20