-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUrlConnect.java
More file actions
executable file
·48 lines (42 loc) · 1.38 KB
/
UrlConnect.java
File metadata and controls
executable file
·48 lines (42 loc) · 1.38 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
/*
* Projet : Trustopics
* Version : 0.2.1
* Fichier : UrlConnect.java
*/
import java.net.MalformedURLException;
import java.net.URL;
public class UrlConnect {
public UrlConnect() throws TrustException {
TrustDatas lcl_trustDatas = new TrustDatas();
WebParser lcl_webFiles = new WebParser();
if (TestUrl(lcl_trustDatas)) throw
new TrustException("L'URL n'est pas valable.");
if (TestUrlConnection(lcl_webFiles,lcl_trustDatas)) throw
new TrustException("Problème de connexion.");
if (TestUrlTrustonme(lcl_webFiles,lcl_trustDatas)) throw
new TrustException("Problème de lecture de la page d'acceuil de Trustonme.");
}
private boolean TestUrl(TrustDatas lcl_trustDatas) {
URL lcl_page = null;
try {
lcl_page = new URL(lcl_trustDatas.GetTrustSite());
}
catch (MalformedURLException mue) {
return(true);
}
return(false);
}
private boolean TestUrlConnection(WebParser prm_webFiles,TrustDatas prm_trustDatas) {
if (prm_webFiles.LoadPage(prm_trustDatas.GetTrustSite())) {
return(true);
}
return(false);
}
private boolean TestUrlTrustonme(WebParser prm_webFiles,TrustDatas prm_trustDatas) {
boolean lcl_result = true;
lcl_result = prm_webFiles.SeekPatternLine(prm_trustDatas.GetDatTitle(1),prm_trustDatas.GetDatTitle(2));
if (lcl_result || !prm_trustDatas.GetTrustTitle().equals(prm_webFiles.GetPattern()))
return(true);
return(false);
}
}