View Javadoc
1   /*
2    * Copyright (c) 2002-2025 Gargoyle Software Inc.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * https://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS,
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   * See the License for the specific language governing permissions and
13   * limitations under the License.
14   */
15  package org.htmlunit;
16  
17  /**
18   * An exception that is thrown when a specified XML element cannot be found in the DOM model.
19   *
20   * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
21   */
22  public class ElementNotFoundException extends RuntimeException {
23  
24      private final String elementName_;
25      private final String attributeName_;
26      private final String attributeValue_;
27  
28      /**
29       * Creates an instance from the variables that were used to search for the XML element.
30       *
31       * @param elementName the name of the element
32       * @param attributeName the name of the attribute
33       * @param attributeValue the value of the attribute
34       */
35      public ElementNotFoundException(
36              final String elementName, final String attributeName, final String attributeValue) {
37          super("elementName=[" + elementName
38                   + "] attributeName=[" + attributeName
39                   + "] attributeValue=[" + attributeValue + "]");
40  
41          elementName_ = elementName;
42          attributeName_ = attributeName;
43          attributeValue_ = attributeValue;
44      }
45  
46      /**
47       * Returns the name of the element.
48       *
49       * @return the name of the element
50       */
51      public String getElementName() {
52          return elementName_;
53      }
54  
55      /**
56       * Returns the name of the attribute.
57       *
58       * @return the name of the attribute
59       */
60      public String getAttributeName() {
61          return attributeName_;
62      }
63  
64      /**
65       * Returns the value of the attribute.
66       *
67       * @return the value of the attribute
68       */
69      public String getAttributeValue() {
70          return attributeValue_;
71      }
72  }
73