| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| DOMDocument |
|
| 1.0;1 |
| 1 | /* | |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
| 3 | * contributor license agreements. See the NOTICE file distributed with | |
| 4 | * this work for additional information regarding copyright ownership. | |
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
| 6 | * (the "License"); you may not use this file except in compliance with | |
| 7 | * the License. You may obtain a copy of the License at | |
| 8 | * | |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 10 | * | |
| 11 | * Unless required by applicable law or agreed to in writing, software | |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 14 | * See the License for the specific language governing permissions and | |
| 15 | * limitations under the License. | |
| 16 | */ | |
| 17 | ||
| 18 | package org.apache.any23.validator; | |
| 19 | ||
| 20 | import org.w3c.dom.Document; | |
| 21 | import org.w3c.dom.Node; | |
| 22 | ||
| 23 | import java.net.URI; | |
| 24 | import java.util.List; | |
| 25 | ||
| 26 | /** | |
| 27 | * This interface models a document to be processed | |
| 28 | * by the {@link Validator}. | |
| 29 | * | |
| 30 | * @author Michele Mostarda (mostarda@fbk.eu) | |
| 31 | * @author Davide Palmisano (palmisano@fbk.eu) | |
| 32 | */ | |
| 33 | public interface DOMDocument { | |
| 34 | ||
| 35 | /** | |
| 36 | * @return the original document URI. | |
| 37 | */ | |
| 38 | URI getDocumentURI(); | |
| 39 | ||
| 40 | /** | |
| 41 | * Returns the original document. | |
| 42 | * | |
| 43 | * @return the original document. | |
| 44 | */ | |
| 45 | Document getOriginalDocument(); | |
| 46 | ||
| 47 | /** | |
| 48 | * Returns the list of nodes addressed by the given <i>XPath</i>. | |
| 49 | * | |
| 50 | * @param xPath a valid XPath | |
| 51 | * @return a not null list of nodes. | |
| 52 | */ | |
| 53 | List<Node> getNodes(String xPath); | |
| 54 | ||
| 55 | /** | |
| 56 | * Returns the node addressed by the given <i>XPath</i>, if more then | |
| 57 | * one an exception will be raised. | |
| 58 | * | |
| 59 | * @param xPath a valid XPath. | |
| 60 | * @return a node or <code>null</code> if nothing found. | |
| 61 | */ | |
| 62 | Node getNode(String xPath); | |
| 63 | ||
| 64 | /** | |
| 65 | * Adds an attribute to a node addressed by the given <i>XPath</i>. | |
| 66 | * | |
| 67 | * @param xPath the XPath pointing the node. | |
| 68 | * @param attrName the name of the attribute. | |
| 69 | * @param attrValue the value of the attribute. | |
| 70 | */ | |
| 71 | void addAttribute(String xPath, String attrName, String attrValue); | |
| 72 | ||
| 73 | /** | |
| 74 | * Returns all the nodes declaring an attribute with the specified name. | |
| 75 | * | |
| 76 | * @param attrName name of attribute to use for filtering. | |
| 77 | * @return a list of nodes. <code>null</node> if no matches found. | |
| 78 | */ | |
| 79 | List<Node> getNodesWithAttribute(String attrName); | |
| 80 | } |