-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTAGController.java
More file actions
63 lines (53 loc) · 1.56 KB
/
TAGController.java
File metadata and controls
63 lines (53 loc) · 1.56 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
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
public class TAGController {
PrintWriter pw;
String[] key = {"TITULO", "SUBTITULO","TEXTO","LISTA","LISTA_ORD"};
String[] tags_open = {"<h1>","<h2>","<p>","<ul>","<ol>"};
String[] tags_close = new String[tags_open.length];
char INDICE = 99;
Map<String, Character> map = new HashMap<>();
public TAGController(PrintWriter pw){
this.pw = pw;
inicializaDados();
}
private void inicializaDados(){
for(char i = 0; i < tags_open.length; i++){
tags_close[i] = tags_open[i];
tags_close[i] = tags_close[i].replace("<", "</");
map.put(key[i], i);
}
}
public boolean defineTAG(String command){
boolean mudou = false;
if(map.containsKey(command)){
mudou = true;
INDICE = map.get(command);
}
return mudou;
}
public void abreTAG(){
pw.println(tags_open[INDICE]);
}
public void fechaTAG(){
pw.println(tags_close[INDICE]);
}
public void insereDado(String d){
if(key[INDICE].equals("LISTA")||key[INDICE].equals("LISTA_ORD")){
pw.println("<li>" +d +"</li>");
return;
}
pw.println(d);
}
public void init(){
pw.println("<html>");
pw.println("<body>");
}
public void close(){
pw.println("</body>");
pw.println("</html>");
pw.flush();
pw.close();
}
}