| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 
 |  
	public List parseLog(String nameLog, String compte, String enquete, List queryList) throws IOException{
 
		BufferedReader in = null;
		try {in = new BufferedReader(new FileReader(nameLog));} 
		catch (IOException e) {throw new IOException("FichierNonTrouvé->"+nameLog);}
 
		List theList = new LinkedList();
		Structure struct;
		String aLine;
		StringTokenizer lineTokens;
 
		String code="",dateHeure="",date="",heure="",ip="",account="",survey="",query="",ref="";
		String page="",pages="",key="";
		String compteEnquete="",requete="";
 
		int ind1, ind2;
 
 
 
		try{
 
			while ((aLine = in.readLine()) != null) {
				lineTokens=new StringTokenizer(aLine,"\t");
 
				if (lineTokens.hasMoreTokens())code=lineTokens.nextToken();
				if (lineTokens.hasMoreTokens())dateHeure=lineTokens.nextToken();
				if (lineTokens.hasMoreTokens())ip=lineTokens.nextToken();
				if (lineTokens.hasMoreTokens())compteEnquete=lineTokens.nextToken();
				if (lineTokens.hasMoreTokens()) {
					requete = lineTokens.nextToken();
					try{
						requete=URLDecoder.decode(requete,"UTF-8");
					}catch(IllegalArgumentException e){}
					ind1=requete.indexOf("query=");
 
					if (ind1<0)continue;
 
					//on cherche le parametre Query
					ind2=requete.indexOf("&", ind1);
					if(ind2<0)ind2=requete.length();
					ind1=ind1+6;
 
					query=requete.substring(ind1, ind2);
 
					if(!queryList.contains(query))continue;
 
					//on cherche le compte
					ind1=1;
					ind2=compteEnquete.indexOf("/", ind1);
					if (ind1>-1 && ind2>0)account=compteEnquete.substring(ind1,ind2);
 
					//on cherche l'enquete
					ind1=compteEnquete.indexOf("/",ind2+1);
					ind2=compteEnquete.indexOf(".",ind1);
					if (ind1>-1 && ind2>0)survey=compteEnquete.substring(ind1+1,ind2);
 
					if (  !((account.equals(compte) || compte.equals(""))
							&&
						    (survey.equals(enquete) || enquete.equals("")))
						) continue;
 
 
					struct=new Structure();
 
					int indDH=dateHeure.indexOf(" ");
					if(indDH>-1){
						struct.date=dateHeure.substring(0,indDH);
						struct.heure=dateHeure.substring(indDH,dateHeure.length());
					}
 
					struct.code=code; struct.ip=ip;
					struct.compte=account; struct.enquete=survey; struct.query=query;
 
					//on récupère le "ref"
					ind1 = requete.indexOf("ref=");
 
					if (ind1 > -1) {
						ind2 = requete.indexOf("&", ind1);
						if (ind2 < 0) ind2 = requete.length();
						ind1=ind1+4;
 
						struct.ref=requete.substring(ind1,ind2);
					}
 
					//on récupère le "page"
					ind1 = requete.indexOf("page=");
 
					if (ind1>-1) {
						ind2=requete.indexOf("&", ind1);
						if (ind2 < 0)ind2 = requete.length();
						ind1 = ind1 + 5;
						struct.page=requete.substring(ind1, ind2);
					}
 
					//on récupère le "pages"
					ind1 = requete.indexOf("pages=");
 
					if (ind1>-1) {
						ind2=requete.indexOf("&", ind1);
						if (ind2<0)ind2 = requete.length();
						ind1 = ind1 + 6;
						struct.pages=requete.substring(ind1,ind2);
 
					}
 
					//on récupère le "key"
					ind1 = requete.indexOf("key=");
					if (ind1 > -1) {
						ind2 = requete.indexOf("&", ind1);
						if (ind2 < 0)ind2 = requete.length();
						ind1=ind1+4;
						//else ind1=ind1+6;
						//struct.key = URLDecoder.decode(requete.substring(ind1, ind2));
						struct.key=requete.substring(ind1,ind2);
 
					}
 
					//on récupère les "vi"
					ind1=requete.indexOf("&v");
					if (ind1>-1) {
						if (requete.charAt(ind1 + 2)>=48 && requete.charAt(ind1 + 2)<=57) {
							ind2=requete.length();
							if (ind2 > -1) {
								StringBuffer sb=new StringBuffer(requete.substring(ind1+1,ind2));
								int lastI=sb.lastIndexOf("&");
								while (sb.length()>lastI+1 && sb.charAt(lastI+1)!='v') {
									sb.delete(lastI, sb.length());
									lastI = sb.lastIndexOf("&");
								}
 
								//////////////////////////////////////////////////////////
								struct.variables=sb.toString();
								requete=requete.replace(struct.variables,"");
								struct.parametres=requete;
 
								struct.variables = struct.variables.replace("&", "<br>");
							}
								//////////////////////////////////////////////////////////
 
						}
					}		
 
					theList.add(struct);			
 
				}
 
 
			}//while ((aLine = in.readLine()) != null)
 
		}//try
		catch(IOException e){}
		return theList;
	} | 
Partager