View Javadoc
1   /*
2    *    Copyright 2006-2026 the original author or authors.
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    *
8    *       https://www.apache.org/licenses/LICENSE-2.0
9    *
10   *    Unless required by applicable law or agreed to in writing, software
11   *    distributed under the License is distributed on an "AS IS" BASIS,
12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *    See the License for the specific language governing permissions and
14   *    limitations under the License.
15   */
16  package org.mybatis.generator.api.dom.xml;
17  
18  import java.util.Optional;
19  
20  import org.jspecify.annotations.Nullable;
21  
22  public class Document {
23  
24      private @Nullable DocType docType;
25  
26      private final XmlElement rootElement;
27  
28      public Document(String publicId, String systemId, XmlElement rootElement) {
29          this(rootElement);
30          docType = new PublicDocType(publicId, systemId);
31      }
32  
33      public Document(String systemId, XmlElement rootElement) {
34          this(rootElement);
35          docType = new SystemDocType(systemId);
36      }
37  
38      public Document(XmlElement rootElement) {
39          this.rootElement = rootElement;
40      }
41  
42      public XmlElement getRootElement() {
43          return rootElement;
44      }
45  
46      public Optional<DocType> getDocType() {
47          return Optional.ofNullable(docType);
48      }
49  }