-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebConnect.java
More file actions
executable file
·182 lines (169 loc) · 8.32 KB
/
WebConnect.java
File metadata and controls
executable file
·182 lines (169 loc) · 8.32 KB
1
2
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*
* Projet : Trustopics
* Version : 0.2.1
* Fichier : WebConnect.java
*/
import java.util.Vector;
public class WebConnect {
private WebParser glb_webFiles;
public WebConnect() {
}
public String[] GetCategories() throws TrustException {
Vector lcl_vecteur = new Vector();
TrustDatas lcl_trustDatas = new TrustDatas();
WebParser lcl_webFiles = new WebParser();
int lcl_indice = 0;
boolean lcl_result;
String lcl_newUrl;
if (lcl_webFiles.LoadPage(lcl_trustDatas.GetDatCategorie(0)))
throw new TrustException("Problème de lecture de la page des catégories.");
while(true) {
lcl_indice ++;
lcl_newUrl = lcl_webFiles.SetParameter(lcl_trustDatas.GetDatCategorie(1),lcl_trustDatas.GetKeyCategorie(),String.valueOf(lcl_indice));
lcl_result = lcl_webFiles.SeekPatternLine(lcl_newUrl,lcl_trustDatas.GetDatCategorie(2));
if (lcl_result) {
break;
}
lcl_vecteur.add(lcl_webFiles.GetPattern());
}
if (lcl_vecteur.size() == 0)
throw new TrustException("Aucune catégorie trouvée.");
return(CopyVectorToTable(lcl_vecteur));
}
public void GetTopicsFile(int prm_categories,int prm_page) throws TrustException {
glb_webFiles = new WebParser();
TrustDatas lcl_trustDatas = new TrustDatas();
String lcl_urlPage;
lcl_urlPage = glb_webFiles.SetParameter(lcl_trustDatas.GetTopicsFile(),lcl_trustDatas.GetKeyCategorie(),String.valueOf(prm_categories));
if (glb_webFiles.LoadPage(glb_webFiles.SetParameter(lcl_urlPage,lcl_trustDatas.GetKeyPage(),String.valueOf(prm_page))))
throw new TrustException("Problème de lecture d'une page de topics (cat=" + prm_categories + ";page=" + prm_page + ").");
}
public String[] GetTopicsMessages() throws TrustException {
Vector lcl_vecteur = new Vector();
TrustDatas lcl_trustDatas = new TrustDatas();
String lcl_lineKeysReplace;
if (glb_webFiles.SeekUrlLines(lcl_trustDatas.GetDatTopic(1),lcl_trustDatas.UrlKeys(lcl_trustDatas.GetDatTopic(1))))
throw new TrustException("Aucune ligne de type URL n'a été trouvée.");
for (int i = 0 ; i < glb_webFiles.GetResultsPage().size() ; i++) {
lcl_lineKeysReplace = glb_webFiles.ReplaceKeys(lcl_trustDatas.GetDatTopic(1),glb_webFiles.GetResultLine(i),lcl_trustDatas.UrlKeys(lcl_trustDatas.GetDatTopic(1)));
if (glb_webFiles.SeekPattern(glb_webFiles.GetResultLine(i),lcl_lineKeysReplace,lcl_trustDatas.GetDatTopic(2)))
throw new TrustException("Un message de la liste des résultats n'a pas été trouvé.");
lcl_vecteur.add(glb_webFiles.GetPattern());
}
if (lcl_vecteur.size() == 0)
throw new TrustException("Aucun message n'a été trouvé.");
return(CopyVectorToTable(lcl_vecteur));
}
public String[] GetTopicsValues() throws TrustException {
Vector lcl_vecteur = new Vector();
TrustDatas lcl_trustDatas = new TrustDatas();
String lcl_topicValue;
if (glb_webFiles.SeekUrlLines(lcl_trustDatas.GetDatTopic(1),lcl_trustDatas.UrlKeys(lcl_trustDatas.GetDatTopic(1))))
throw new TrustException("Aucune ligne de type URL n'a été trouvée.");
for (int i = 0 ; i < glb_webFiles.GetResultsPage().size() ; i++) {
lcl_topicValue = glb_webFiles.GetParameter(glb_webFiles.GetResultLine(i),lcl_trustDatas.GetKeyTopic());
lcl_vecteur.add(lcl_topicValue);
}
if (lcl_vecteur.size() == 0)
throw new TrustException("Aucun numéro de topic n'a été trouvé.");
return(CopyVectorToTable(lcl_vecteur));
}
public String[] GetTopicsAnswers() throws TrustException {
Vector lcl_vecteur = new Vector();
TrustDatas lcl_trustDatas = new TrustDatas();
int lcl_indice,j;
boolean lcl_result;
if (glb_webFiles.SeekUrlLines(lcl_trustDatas.GetDatTopic(1),lcl_trustDatas.UrlKeys(lcl_trustDatas.GetDatTopic(1))))
throw new TrustException("Aucune ligne de type URL n'a été trouvée.");
for (int i = 0 ; i < glb_webFiles.GetIndicesResultsPage().size() ; i++) {
lcl_indice = Integer.valueOf(glb_webFiles.GetIndicesResultLine(i)).intValue();
for (j = lcl_indice ; j < glb_webFiles.GetPage().size() ; j++ ) {
lcl_result = glb_webFiles.SeekPattern(glb_webFiles.GetPageLine(j),lcl_trustDatas.GetDatAnswer(1),lcl_trustDatas.GetDatAnswer(2));
if (!lcl_result) {
lcl_vecteur.add(glb_webFiles.GetPattern());
break;
}
}
if (j == glb_webFiles.GetPage().size())
throw new TrustException("Un nombre de réponse de la liste des résultats n'a pas été trouvé.");
}
if (lcl_vecteur.size() == 0)
throw new TrustException("Aucun nombre de réponse n'a été trouvé.");
return(CopyVectorToTable(lcl_vecteur));
}
public String[] GetTopicsViews() throws TrustException {
Vector lcl_vecteur = new Vector();
TrustDatas lcl_trustDatas = new TrustDatas();
int lcl_indice,j;
boolean lcl_result1,lcl_result2;
if (glb_webFiles.SeekUrlLines(lcl_trustDatas.GetDatTopic(1),lcl_trustDatas.UrlKeys(lcl_trustDatas.GetDatTopic(1))))
throw new TrustException("Aucune ligne de type URL n'a été trouvée.");
for (int i = 0 ; i < glb_webFiles.GetIndicesResultsPage().size() ; i++) {
lcl_indice = Integer.valueOf(glb_webFiles.GetIndicesResultLine(i)).intValue();
for (j = lcl_indice ; j < glb_webFiles.GetPage().size() ; j++ ) {
lcl_result1 = glb_webFiles.SeekPattern(glb_webFiles.GetPageLine(j),lcl_trustDatas.GetDatAnswer(1),lcl_trustDatas.GetDatAnswer(2));
lcl_result2 = glb_webFiles.SeekPattern(glb_webFiles.GetPageLine(j+1),lcl_trustDatas.GetDatView(1),lcl_trustDatas.GetDatView(2));
if (!lcl_result1 && !lcl_result2) {
lcl_vecteur.add(glb_webFiles.GetPattern());
break;
}
}
if (j == glb_webFiles.GetPage().size())
throw new TrustException("Un nombre de vue de la liste des résultats n'a pas été trouvé.");
}
if (lcl_vecteur.size() == 0)
throw new TrustException("Aucun nombre de vue n'a été trouvé.");
return(CopyVectorToTable(lcl_vecteur));
}
public String[] GetTopicsAuthors() throws TrustException {
Vector lcl_vecteur = new Vector();
TrustDatas lcl_trustDatas = new TrustDatas();
int lcl_indice,j;
boolean lcl_result;
if (glb_webFiles.SeekUrlLines(lcl_trustDatas.GetDatTopic(1),lcl_trustDatas.UrlKeys(lcl_trustDatas.GetDatTopic(1))))
throw new TrustException("Aucune ligne de type URL n'a été trouvée.");
for (int i = 0 ; i < glb_webFiles.GetIndicesResultsPage().size() ; i++) {
lcl_indice = Integer.valueOf(glb_webFiles.GetIndicesResultLine(i)).intValue();
for (j = lcl_indice ; j < glb_webFiles.GetPage().size() ; j++ ) {
lcl_result = glb_webFiles.SeekPattern(glb_webFiles.GetPageLine(j),lcl_trustDatas.GetDatTopicAuthor(1),lcl_trustDatas.GetDatTopicAuthor(2));
if (!lcl_result) {
lcl_vecteur.add(glb_webFiles.GetPattern());
break;
}
}
if (j == glb_webFiles.GetPage().size())
throw new TrustException("Un auteur de topic de la liste des résultats n'a pas été trouvé.");
}
if (lcl_vecteur.size() == 0)
throw new TrustException("Aucun auteur de topic n'a été trouvé.");
return(CopyVectorToTable(lcl_vecteur));
}
public String[] GetTopicsAnswersAuthors() throws TrustException {
Vector lcl_vecteur = new Vector();
TrustDatas lcl_trustDatas = new TrustDatas();
String lcl_lineKeysReplace;
int lcl_testValue;
boolean lcl_testValueOk;
if (glb_webFiles.SeekUrlLines(lcl_trustDatas.GetDatAnswerAuthor(1),lcl_trustDatas.UrlKeys(lcl_trustDatas.GetDatAnswerAuthor(1))))
throw new TrustException("Aucune ligne de type URL n'a été trouvée.");
for (int i = 0 ; i < glb_webFiles.GetResultsPage().size() ; i++) {
lcl_lineKeysReplace = glb_webFiles.ReplaceKeys(lcl_trustDatas.GetDatAnswerAuthor(1),glb_webFiles.GetResultLine(i),lcl_trustDatas.UrlKeys(lcl_trustDatas.GetDatAnswerAuthor(1)));
if (glb_webFiles.SeekPattern(glb_webFiles.GetResultLine(i),lcl_lineKeysReplace,lcl_trustDatas.GetDatAnswerAuthor(2)))
throw new TrustException("Un auteur du dernier message de la liste des résultats n'a pas été trouvé.");
lcl_testValueOk = false;
try { lcl_testValue = Integer.valueOf(glb_webFiles.GetPattern()).intValue(); }
catch(NumberFormatException err) { lcl_testValueOk = true; }
if (lcl_testValueOk == true) lcl_vecteur.add(glb_webFiles.GetPattern());
}
if (lcl_vecteur.size() == 0)
throw new TrustException("Aucun auteur du dernier message n'a été trouvé.");
return(CopyVectorToTable(lcl_vecteur));
}
private String[] CopyVectorToTable(Vector prm_vecteur) {
String lcl_table[] = new String[prm_vecteur.size()];
for (int i = 0 ; i < prm_vecteur.size() ; i++) {
lcl_table[i] = (String)prm_vecteur.elementAt(i);
}
return(lcl_table);
}
}