1 package org.esigate.aggregator;
2
3 import java.util.ArrayList;
4 import java.util.List;
5 import java.util.regex.Matcher;
6 import java.util.regex.Pattern;
7
8 import org.esigate.Driver;
9 import org.esigate.DriverFactory;
10
11
12
13
14
15
16 final class ElementAttributesFactory {
17 private ElementAttributesFactory() {
18
19 }
20
21
22
23
24
25
26
27
28 static ElementAttributes createElementAttributes(String tag) {
29
30
31
32
33
34 Pattern pattern = Pattern.compile("(?<=\\$)(?:[^\\$]|\\$\\()*(?=\\$)");
35 Matcher matcher = pattern.matcher(tag);
36 List<String> listparameters = new ArrayList<>();
37 while (matcher.find()) {
38 listparameters.add(matcher.group());
39 }
40
41 String[] parameters = listparameters.toArray(new String[listparameters.size()]);
42
43 Driver driver;
44 String page = "";
45 String name = null;
46
47 if (parameters.length > 1) {
48 driver = DriverFactory.getInstance(parameters[1]);
49 } else {
50 driver = DriverFactory.getInstance();
51 }
52
53 if (parameters.length > 2) {
54 page = parameters[2];
55 }
56
57 if (parameters.length > 3) {
58 name = parameters[3];
59 }
60 return new ElementAttributes(driver, page, name);
61
62 }
63 }