View Javadoc
1   /*
2    *    Copyright 2006-2023 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;
17  
18  public class OutputUtilities {
19  
20      /**
21       * Utility class - no instances allowed.
22       */
23      private OutputUtilities() {
24          super();
25      }
26  
27      /**
28       * Utility method that indents the buffer by the default amount for Java
29       * (four spaces per indent level).
30       *
31       * @param sb
32       *            a StringBuilder to append to
33       * @param indentLevel
34       *            the required indent level
35       */
36      public static void javaIndent(StringBuilder sb, int indentLevel) {
37          for (int i = 0; i < indentLevel; i++) {
38              sb.append("    "); //$NON-NLS-1$
39          }
40      }
41  
42      /**
43       * Utility method that indents the buffer by the default amount for Kotlin
44       * (four spaces per indent level).
45       *
46       * @param sb
47       *            a StringBuilder to append to
48       * @param indentLevel
49       *            the required indent level
50       */
51      public static void kotlinIndent(StringBuilder sb, int indentLevel) {
52          javaIndent(sb, indentLevel);
53      }
54  
55      /**
56       * Utility method that indents the buffer by the default amount for XML (two
57       * spaces per indent level).
58       *
59       * @param sb
60       *            a StringBuilder to append to
61       * @param indentLevel
62       *            the required indent level
63       */
64      public static void xmlIndent(StringBuilder sb, int indentLevel) {
65          for (int i = 0; i < indentLevel; i++) {
66              sb.append("  "); //$NON-NLS-1$
67          }
68      }
69  }