blob: ce6ac678a590761b708219dbf0c4437947b69a35 (
plain)
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
|
package org.jsoup.nodes;
/**
* An XML Declaration.
*
* @author Jonathan Hedley, jonathan@hedley.net
*/
public class XmlDeclaration extends Node {
private static final String DECL_KEY = "declaration";
private final boolean isProcessingInstruction; // <! if true, <? if false,
// declaration (and last data
// char should be ?)
/**
* Create a new XML declaration
*
* @param data
* data
* @param baseUri
* base uri
* @param isProcessingInstruction
* is processing instruction
*/
public XmlDeclaration(String data, String baseUri,
boolean isProcessingInstruction) {
super(baseUri);
attributes.put(DECL_KEY, data);
this.isProcessingInstruction = isProcessingInstruction;
}
@Override
public String nodeName() {
return "#declaration";
}
/**
* Get the unencoded XML declaration.
*
* @return XML declaration
*/
public String getWholeDeclaration() {
return attributes.get(DECL_KEY);
}
@Override
void outerHtmlHead(StringBuilder accum, int depth,
Document.OutputSettings out) {
accum.append("<").append(isProcessingInstruction ? "!" : "?")
.append(getWholeDeclaration()).append(">");
}
@Override
void outerHtmlTail(StringBuilder accum, int depth,
Document.OutputSettings out) {
}
@Override
public String toString() {
return outerHtml();
}
}
|