View Javadoc
1   /**
2    *    Copyright 2006-2016 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    *       http://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;
17  
18  import org.mybatis.generator.api.dom.xml.Document;
19  
20  /**
21   * The Class GeneratedXmlFile.
22   *
23   * @author Jeff Butler
24   */
25  public class GeneratedXmlFile extends GeneratedFile {
26      
27      /** The document. */
28      private Document document;
29  
30      /** The file name. */
31      private String fileName;
32  
33      /** The target package. */
34      private String targetPackage;
35  
36      /** The is mergeable. */
37      private boolean isMergeable;
38      
39      /** The xml formatter. */
40      private XmlFormatter xmlFormatter;
41  
42      /**
43       * Instantiates a new generated xml file.
44       *
45       * @param document
46       *            the document
47       * @param fileName
48       *            the file name
49       * @param targetPackage
50       *            the target package
51       * @param targetProject
52       *            the target project
53       * @param isMergeable
54       *            true if the file can be merged by the built in XML file merger.
55       * @param xmlFormatter
56       *            the xml formatter
57       */
58      public GeneratedXmlFile(Document document, String fileName,
59              String targetPackage, String targetProject, boolean isMergeable,
60              XmlFormatter xmlFormatter) {
61          super(targetProject);
62          this.document = document;
63          this.fileName = fileName;
64          this.targetPackage = targetPackage;
65          this.isMergeable = isMergeable;
66          this.xmlFormatter = xmlFormatter;
67      }
68  
69      /* (non-Javadoc)
70       * @see org.mybatis.generator.api.GeneratedFile#getFormattedContent()
71       */
72      @Override
73      public String getFormattedContent() {
74          return xmlFormatter.getFormattedContent(document);
75      }
76  
77      /**
78       * Gets the file name.
79       *
80       * @return Returns the fileName.
81       */
82      @Override
83      public String getFileName() {
84          return fileName;
85      }
86  
87      /**
88       * Gets the target package.
89       *
90       * @return Returns the targetPackage.
91       */
92      @Override
93      public String getTargetPackage() {
94          return targetPackage;
95      }
96  
97      /* (non-Javadoc)
98       * @see org.mybatis.generator.api.GeneratedFile#isMergeable()
99       */
100     @Override
101     public boolean isMergeable() {
102         return isMergeable;
103     }
104 }