1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.devacfr.maven.skins.reflow.model;
17
18 import static java.util.Objects.requireNonNull;
19
20 import com.google.common.base.Strings;
21 import com.google.common.collect.Lists;
22 import java.util.List;
23 import javax.annotation.Nonnull;
24 import org.codehaus.plexus.util.xml.Xpp3Dom;
25 import org.devacfr.maven.skins.reflow.ISkinConfig;
26
27
28
29
30
31
32
33 public class Header extends BsComponent {
34
35
36 private static final String COMPONENT = "header";
37
38 private static final List<String> HEADER_TYPES = Lists.newArrayList("jumbotron", "banner", "custom");
39
40
41 private boolean enabled = true;
42
43
44 private String type;
45
46
47 private String content;
48
49
50
51
52
53
54
55 public Header(@Nonnull final ISkinConfig config) {
56 super(config, COMPONENT);
57 requireNonNull(config);
58 this.setTheme(config.getAttributeValue(COMPONENT, "theme", String.class, null));
59 this.setBackground(config.getAttributeValue(COMPONENT, "background", String.class, null));
60 this.setCssClass(config.getAttributeValue(COMPONENT, "cssClass", String.class, null));
61
62 this.type = config.getAttributeValue(COMPONENT, "type", String.class, HEADER_TYPES.get(0)).toLowerCase();
63 if (!HEADER_TYPES.contains(this.type)) {
64 this.type = HEADER_TYPES.get(0);
65 }
66 this.enabled = config.getAttributeValue(COMPONENT, "enabled", Boolean.class, true);
67
68 Xpp3Dom component = config.get(COMPONENT);
69 if (component != null) {
70 this.content = component.getValue();
71 if (!Strings.isNullOrEmpty(this.content)) {
72 this.type = HEADER_TYPES.get(2);
73 }
74 }
75 }
76
77
78
79
80
81
82 public boolean isEnabled() {
83 return enabled;
84 }
85
86
87
88
89
90
91 public String getType() {
92 return type;
93 }
94
95
96
97
98 public String getContent() {
99 return content;
100 }
101 }