ModifiableHTMLContent.java
3.59 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
/*
* Decompiled with CFR 0_118.
*/
package com.day.cq.wcm.designimporter.parser;
import com.day.cq.wcm.designimporter.parser.HTMLContent;
import com.day.cq.wcm.designimporter.parser.HTMLContentType;
import java.util.Collection;
import java.util.List;
import java.util.Map;
public class ModifiableHTMLContent
extends HTMLContent {
private StringBuffer markupBuffer;
private StringBuffer cssBuffer;
private StringBuffer scriptBuffer;
private List<String> referencedScripts;
private List<String> referencedStyleSheets;
private Map<String, String> metaData;
public ModifiableHTMLContent(HTMLContent htmlContent) {
this.markupBuffer = new StringBuffer((String)htmlContent.get(HTMLContentType.MARKUP));
this.cssBuffer = new StringBuffer((String)htmlContent.get(HTMLContentType.STYLES_INLINE));
this.scriptBuffer = new StringBuffer((String)htmlContent.get(HTMLContentType.SCRIPT_INLINE));
this.referencedScripts = (List)htmlContent.get(HTMLContentType.SCRIPT_INCLUDE);
this.referencedStyleSheets = (List)htmlContent.get(HTMLContentType.STYLESHEET_INCLUDE);
this.metaData = (Map)htmlContent.get(HTMLContentType.META);
}
public void set(HTMLContentType htmlContentType, Object content) {
switch (htmlContentType) {
case META: {
this.metaData = (Map)content;
break;
}
case MARKUP: {
this.markupBuffer = new StringBuffer((String)content);
break;
}
case SCRIPT_INCLUDE: {
this.referencedScripts = (List)content;
break;
}
case SCRIPT_INLINE: {
this.scriptBuffer = new StringBuffer((String)content);
break;
}
case STYLES_INLINE: {
this.cssBuffer = new StringBuffer((String)content);
break;
}
case STYLESHEET_INCLUDE: {
this.referencedStyleSheets = (List)content;
}
}
}
@Override
public Object get(HTMLContentType htmlContentType) {
switch (htmlContentType) {
case META: {
return this.metaData;
}
case MARKUP: {
return this.markupBuffer.toString();
}
case SCRIPT_INCLUDE: {
return this.referencedScripts;
}
case SCRIPT_INLINE: {
return this.scriptBuffer.toString();
}
case STYLES_INLINE: {
return this.cssBuffer.toString();
}
case STYLESHEET_INCLUDE: {
return this.referencedStyleSheets;
}
}
return null;
}
@Override
public void add(HTMLContentType htmlContentType, Object content) {
switch (htmlContentType) {
case META: {
this.metaData.putAll((Map)content);
break;
}
case MARKUP: {
this.markupBuffer.append(content);
break;
}
case SCRIPT_INCLUDE: {
this.referencedScripts.addAll((Collection)content);
break;
}
case SCRIPT_INLINE: {
this.scriptBuffer.append(content);
break;
}
case STYLES_INLINE: {
this.cssBuffer.append(content);
break;
}
case STYLESHEET_INCLUDE: {
this.referencedStyleSheets.addAll((Collection)content);
}
}
}
}