1 /*
2 * Copyright (c) 2002-2026 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 * @author Ronald Brill
26 */
27 public interface ElementFactory {
28
29 /**
30 * Creates an element according to this factory's specification. Note that even though this method
31 * takes a page parameter, the element is <em>not</em> automatically added to the page's DOM tree.
32 *
33 * @param page the enclosing page for the new element
34 * @param tagName the tag name (most factories will be responsible for a specific tag, but this
35 * parameter is passed in for factories that don't follow this rule)
36 * @param attributes the attributes encountered during XML/HTML parsing (possibly {@code null}
37 * if no attributes specified
38 * @return the newly created and initialized element
39 */
40 DomElement createElement(SgmlPage page, String tagName, Attributes attributes);
41
42 /**
43 * Creates an element according to this factory's specification. Note that even though this method
44 * takes a page parameter, the element is <em>not</em> automatically added to the page's DOM tree.
45 *
46 * @param page the enclosing page for the new element
47 * @param namespaceURI the URI that identifies an XML namespace
48 * @param qualifiedName the qualified name of the element type to instantiate
49 * @param attributes the attributes encountered during XML/HTML parsing (possibly {@code null}
50 * if no attributes specified
51 * @return the newly created and initialized element
52 */
53 DomElement createElementNS(SgmlPage page, String namespaceURI, String qualifiedName, Attributes attributes);
54 }