| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.rendering.wikimodel.confluence; |
| 21 |
|
|
| 22 |
|
import java.io.Reader; |
| 23 |
|
import java.io.StringReader; |
| 24 |
|
import java.util.Stack; |
| 25 |
|
|
| 26 |
|
import org.xwiki.rendering.wikimodel.CompositeListener; |
| 27 |
|
import org.xwiki.rendering.wikimodel.IWemListener; |
| 28 |
|
import org.xwiki.rendering.wikimodel.WikiParameters; |
| 29 |
|
import org.xwiki.rendering.wikimodel.WikiParserException; |
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
@version |
| 37 |
|
@since |
| 38 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 39 |
|
public class ConfluenceExtendedWikiParser extends ConfluenceWikiParser |
| 40 |
|
{ |
|
|
|
| 55.7% |
Uncovered Elements: 31 (70) |
Complexity: 23 |
Complexity Density: 0.61 |
|
| 41 |
|
public static class EnhancedListener extends CompositeListener |
| 42 |
|
{ |
| 43 |
|
private Stack<Boolean> fSkipDocument = new Stack<Boolean>(); |
| 44 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 45 |
5
|
public EnhancedListener(IWemListener... listeners)... |
| 46 |
|
{ |
| 47 |
5
|
super(listeners); |
| 48 |
|
} |
| 49 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 50 |
5
|
@Override... |
| 51 |
|
public void beginDocument(WikiParameters params) |
| 52 |
|
{ |
| 53 |
5
|
if (!skipDocument()) { |
| 54 |
5
|
super.beginDocument(params); |
| 55 |
|
} |
| 56 |
|
} |
| 57 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 58 |
7
|
@Override... |
| 59 |
|
public void beginSection( |
| 60 |
|
int docLevel, |
| 61 |
|
int headerLevel, |
| 62 |
|
WikiParameters params) |
| 63 |
|
{ |
| 64 |
7
|
if (!skipDocument()) { |
| 65 |
7
|
super.beginSection(docLevel, headerLevel, params); |
| 66 |
|
} |
| 67 |
|
} |
| 68 |
|
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 69 |
7
|
@Override... |
| 70 |
|
public void beginSectionContent( |
| 71 |
|
int docLevel, |
| 72 |
|
int headerLevel, |
| 73 |
|
WikiParameters params) |
| 74 |
|
{ |
| 75 |
7
|
if (!skipDocument()) { |
| 76 |
7
|
super.beginSectionContent(docLevel, headerLevel, params); |
| 77 |
|
} |
| 78 |
7
|
push(false); |
| 79 |
|
} |
| 80 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 81 |
5
|
@Override... |
| 82 |
|
public void endDocument(WikiParameters params) |
| 83 |
|
{ |
| 84 |
5
|
if (!skipDocument()) { |
| 85 |
5
|
super.endDocument(params); |
| 86 |
|
} |
| 87 |
|
} |
| 88 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 89 |
7
|
@Override... |
| 90 |
|
public void endSection( |
| 91 |
|
int docLevel, |
| 92 |
|
int headerLevel, |
| 93 |
|
WikiParameters params) |
| 94 |
|
{ |
| 95 |
7
|
if (!skipDocument()) { |
| 96 |
7
|
super.endSection(docLevel, headerLevel, params); |
| 97 |
|
} |
| 98 |
|
} |
| 99 |
|
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 100 |
7
|
@Override... |
| 101 |
|
public void endSectionContent( |
| 102 |
|
int docLevel, |
| 103 |
|
int headerLevel, |
| 104 |
|
WikiParameters params) |
| 105 |
|
{ |
| 106 |
7
|
pop(); |
| 107 |
7
|
if (!skipDocument()) { |
| 108 |
7
|
super.endSectionContent(docLevel, headerLevel, params); |
| 109 |
|
} |
| 110 |
|
} |
| 111 |
|
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
| 112 |
0
|
@Override... |
| 113 |
|
public void onMacroBlock( |
| 114 |
|
String macroName, |
| 115 |
|
WikiParameters params, |
| 116 |
|
String content) |
| 117 |
|
{ |
| 118 |
0
|
String type = null; |
| 119 |
0
|
if ("note".equals(macroName)) { |
| 120 |
0
|
type = "N"; |
| 121 |
0
|
} else if ("tip".equals(macroName)) { |
| 122 |
0
|
type = "T"; |
| 123 |
|
} |
| 124 |
0
|
if (type != null) { |
| 125 |
0
|
beginInfoBlock(type, params); |
| 126 |
0
|
parseContent(content); |
| 127 |
0
|
endInfoBlock(type, params); |
| 128 |
|
} else { |
| 129 |
0
|
super.onMacroBlock(macroName, params, content); |
| 130 |
|
} |
| 131 |
|
} |
| 132 |
|
|
| 133 |
|
|
| 134 |
|
@param |
| 135 |
|
@throws |
| 136 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.29 |
|
| 137 |
0
|
private void parseContent(String content)... |
| 138 |
|
{ |
| 139 |
0
|
try { |
| 140 |
0
|
push(true); |
| 141 |
0
|
StringReader reader = new StringReader(content); |
| 142 |
0
|
ConfluenceWikiParser parser = new ConfluenceWikiParser(); |
| 143 |
0
|
parser.parse(reader, this); |
| 144 |
0
|
pop(); |
| 145 |
|
} catch (WikiParserException e) { |
| 146 |
0
|
throw new RuntimeException(e); |
| 147 |
|
} |
| 148 |
|
} |
| 149 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 150 |
7
|
private void pop()... |
| 151 |
|
{ |
| 152 |
7
|
fSkipDocument.pop(); |
| 153 |
|
} |
| 154 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 155 |
7
|
private void push(boolean b)... |
| 156 |
|
{ |
| 157 |
7
|
fSkipDocument.push(b); |
| 158 |
|
} |
| 159 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 160 |
38
|
private boolean skipDocument()... |
| 161 |
|
{ |
| 162 |
38
|
if (fSkipDocument.isEmpty()) { |
| 163 |
30
|
return false; |
| 164 |
|
} |
| 165 |
8
|
Boolean peek = fSkipDocument.peek(); |
| 166 |
8
|
return peek; |
| 167 |
|
} |
| 168 |
|
} |
| 169 |
|
|
| 170 |
|
|
| 171 |
|
|
| 172 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 173 |
5
|
public ConfluenceExtendedWikiParser()... |
| 174 |
|
{ |
| 175 |
5
|
super(); |
| 176 |
|
} |
| 177 |
|
|
| 178 |
|
|
| 179 |
|
@see |
| 180 |
|
|
| 181 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 182 |
5
|
@Override... |
| 183 |
|
public void parse(Reader reader, IWemListener listener) |
| 184 |
|
throws WikiParserException |
| 185 |
|
{ |
| 186 |
5
|
IWemListener composite = new EnhancedListener(listener); |
| 187 |
5
|
super.parse(reader, composite); |
| 188 |
|
} |
| 189 |
|
} |