Converts the specified info string to a node fragment. @param name name of the root node @param string string to be converted @param qc query context @return node
(final QNm name, final String string, final QueryContext qc)
| 30 | * @return node |
| 31 | */ |
| 32 | static FNode toNode(final QNm name, final String string, final QueryContext qc) { |
| 33 | final FBuilder root = FElem.build(name); |
| 34 | |
| 35 | FBuilder header = null; |
| 36 | for(final String line : string.split(Prop.NL)) { |
| 37 | final String[] cols = line.split(": ", 2); |
| 38 | if(cols[0].isEmpty()) continue; |
| 39 | |
| 40 | final String col = cols[0].replaceAll("[ -:]", "").toLowerCase(Locale.ENGLISH); |
| 41 | final FBuilder node = FElem.build(qc.shared.qName(Token.token(col))); |
| 42 | if(Strings.startsWith(cols[0], ' ')) { |
| 43 | header.node(node.text(cols[1])); |
| 44 | } else { |
| 45 | if(header != null) root.node(header); |
| 46 | header = node; |
| 47 | } |
| 48 | } |
| 49 | return root.node(header).finish(); |
| 50 | } |
| 51 | } |
no test coverage detected