|
|||||||||||||||||||
| This license of Clover is provided to support the development of JBind only. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover. | |||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| ElementCollector.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 |
/* |
|
| 2 |
* JBind |
|
| 3 |
* |
|
| 4 |
* Copyright (c) by Stefan Wachter. All rights reserved. |
|
| 5 |
* |
|
| 6 |
* Usage, modification, and redistribution is subject to license terms that are |
|
| 7 |
* available at 'http://www.jbind.org'. The JBind license is like the |
|
| 8 |
* 'Apache Software License V 1.1'. |
|
| 9 |
*/ |
|
| 10 |
package org.jbind.xml.dom3.core; |
|
| 11 |
|
|
| 12 |
import org.jbind.xml.dom3.types.IDomDocument; |
|
| 13 |
import org.jbind.xml.dom3.types.IDomElement; |
|
| 14 |
import org.jbind.xml.dom3.types.IDomNodeList; |
|
| 15 |
import org.w3c.dom.Node; |
|
| 16 |
|
|
| 17 |
public class ElementCollector extends DomVisitor {
|
|
| 18 |
|
|
| 19 |
private static final short[] ourAllowedNodeTypes = new short[]{ Node.ELEMENT_NODE };
|
|
| 20 |
|
|
| 21 |
private IDomNodeList myList = null; |
|
| 22 |
|
|
| 23 |
private String myNamespaceUri = null; |
|
| 24 |
private String myLocalName = null; |
|
| 25 |
private String myTagName = null; |
|
| 26 |
|
|
| 27 | 0 |
public ElementCollector(IDomDocument aDomDocument, String aNamespaceUri, String aLocalName) {
|
| 28 |
assert null != aLocalName : "local name must not be null"; |
|
| 29 | 0 |
myList = new DomNodeList(null, aDomDocument, ourAllowedNodeTypes); |
| 30 | 0 |
myNamespaceUri = aNamespaceUri; |
| 31 | 0 |
myLocalName = aLocalName; |
| 32 |
} |
|
| 33 |
|
|
| 34 | 0 |
public ElementCollector(IDomDocument aDomDocument, String aTagName) {
|
| 35 |
assert null != aTagName : "tag name must not be null"; |
|
| 36 | 0 |
myList = new DomNodeList(null, aDomDocument, ourAllowedNodeTypes); |
| 37 | 0 |
myTagName = aTagName; |
| 38 |
} |
|
| 39 |
|
|
| 40 | 0 |
public void visitElementStart(IDomElement anElement) {
|
| 41 | 0 |
if (myTagName == null) {
|
| 42 | 0 |
if ("*".equals(myNamespaceUri) || ((myNamespaceUri == null) && (anElement.getNamespaceURI() == null)) || ((myNamespaceUri != null) && myNamespaceUri.equals(anElement.getNamespaceURI()))) {
|
| 43 | 0 |
if ("*".equals(myLocalName) || myLocalName.equals(anElement.getLocalName())) {
|
| 44 | 0 |
myList.add(anElement); |
| 45 |
} |
|
| 46 |
} |
|
| 47 |
} else {
|
|
| 48 | 0 |
if ("*".equals(myTagName) || myTagName.equals(anElement.getNodeName())) {
|
| 49 | 0 |
myList.add(anElement); |
| 50 |
} |
|
| 51 |
} |
|
| 52 |
} |
|
| 53 |
|
|
| 54 | 0 |
public IDomNodeList getElements() {
|
| 55 | 0 |
return myList; |
| 56 |
} |
|
| 57 |
} |
|
| 58 |
|
|
||||||||||