| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.kuali.rice.ken.util; |
| 17 |
|
|
| 18 |
|
import java.util.ArrayList; |
| 19 |
|
import java.util.Iterator; |
| 20 |
|
import java.util.List; |
| 21 |
|
|
| 22 |
|
import javax.xml.namespace.NamespaceContext; |
| 23 |
|
|
| 24 |
|
import org.apache.log4j.Logger; |
| 25 |
|
import org.w3c.dom.Document; |
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
@author |
| 31 |
|
|
|
|
|
| 0% |
Uncovered Elements: 33 (33) |
Complexity: 9 |
Complexity Density: 0.47 |
|
| 32 |
|
public class DocumentNamespaceContext implements NamespaceContext { |
| 33 |
|
private static final Logger LOG = Logger.getLogger(DocumentNamespaceContext.class); |
| 34 |
|
|
| 35 |
|
|
| 36 |
|
private final Document doc; |
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
@param |
| 41 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 42 |
0
|
public DocumentNamespaceContext(Document doc) {... |
| 43 |
0
|
this.doc = doc; |
| 44 |
|
} |
| 45 |
|
|
| 46 |
|
|
| 47 |
|
@see |
| 48 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 49 |
0
|
public String getNamespaceURI(String prefix) {... |
| 50 |
0
|
LOG.debug("getNamespaceURI(" + prefix + ")"); |
| 51 |
0
|
if (prefix == null) { |
| 52 |
0
|
throw new IllegalArgumentException("The prefix cannot be null."); |
| 53 |
|
} |
| 54 |
0
|
if (prefix.length() == 0) { |
| 55 |
0
|
return doc.lookupNamespaceURI(null); |
| 56 |
|
} |
| 57 |
0
|
return doc.lookupNamespaceURI(prefix); |
| 58 |
|
} |
| 59 |
|
|
| 60 |
|
|
| 61 |
|
@see |
| 62 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 63 |
0
|
public String getPrefix(String namespaceURI) {... |
| 64 |
0
|
LOG.debug("getPrefix(" + namespaceURI + ")"); |
| 65 |
0
|
if (namespaceURI == null) { |
| 66 |
0
|
throw new IllegalArgumentException("The namespace uri cannot be null."); |
| 67 |
|
} |
| 68 |
0
|
return doc.lookupPrefix(namespaceURI); |
| 69 |
|
} |
| 70 |
|
|
| 71 |
|
|
| 72 |
|
@see |
| 73 |
|
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
| 74 |
0
|
public Iterator getPrefixes(String namespaceURI) {... |
| 75 |
0
|
LOG.debug("getPrefixes(" + namespaceURI + ")"); |
| 76 |
0
|
if (namespaceURI == null) { |
| 77 |
0
|
throw new IllegalArgumentException("The namespace uri cannot be null."); |
| 78 |
|
} |
| 79 |
0
|
List<String> list = new ArrayList<String>(1); |
| 80 |
0
|
String s = getPrefix(namespaceURI); |
| 81 |
0
|
if (s != null) { |
| 82 |
0
|
list.add(s); |
| 83 |
|
} |
| 84 |
0
|
return list.iterator(); |
| 85 |
|
} |
| 86 |
|
} |