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.html;
16
17 import org.htmlunit.SgmlPage;
18 import org.xml.sax.Attributes;
19
20 /**
21 * Specification of a factory capable of creating {@link DomElement} objects.
22 *
23 * @author Christian Sell
24 * @author Ahmed Ashour
25 */
26 public interface ElementFactory {
27
28 /**
29 * Creates an element according to this factory's specification. Note that even though this method
30 * takes a page parameter, the element is <em>not</em> automatically added to the page's DOM tree.
31 *
32 * @param page the enclosing page for the new element
33 * @param tagName the tag name (most factories will be responsible for a specific tag, but this
34 * parameter is passed in for factories that don't follow this rule)
35 * @param attributes the attributes encountered during XML/HTML parsing (possibly {@code null}
36 * if no attributes specified
37 * @return the newly created and initialized element
38 */
39 DomElement createElement(SgmlPage page, String tagName, Attributes attributes);
40
41 /**
42 * Creates an element according to this factory's specification. Note that even though this method
43 * takes a page parameter, the element is <em>not</em> automatically added to the page's DOM tree.
44 *
45 * @param page the enclosing page for the new element
46 * @param namespaceURI the URI that identifies an XML namespace
47 * @param qualifiedName the qualified name of the element type to instantiate
48 * @param attributes the attributes encountered during XML/HTML parsing (possibly {@code null}
49 * if no attributes specified
50 * @return the newly created and initialized element
51 */
52 DomElement createElementNS(SgmlPage page, String namespaceURI, String qualifiedName, Attributes attributes);
53 }