| FormatType.java |
1 /**
2 * Distribution License:
3 * JSword is free software; you can redistribute it and/or modify it under
4 * the terms of the GNU Lesser General Public License, version 2.1 as published by
5 * the Free Software Foundation. This program is distributed in the hope
6 * that it will be useful, but WITHOUT ANY WARRANTY; without even the
7 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8 * See the GNU Lesser General Public License for more details.
9 *
10 * The License is available on the internet at:
11 * http://www.gnu.org/copyleft/lgpl.html
12 * or by writing to:
13 * Free Software Foundation, Inc.
14 * 59 Temple Place - Suite 330
15 * Boston, MA 02111-1307, USA
16 *
17 * Copyright: 2005
18 * The copyright to this program is held by it's authors.
19 *
20 * ID: $Id: FormatType.java 2047 2010-12-07 03:49:58Z dmsmith $
21 */
22 package org.crosswire.common.xml;
23
24 /**
25 * The PrettySerializingContentHandler uses a FormatType to control its output.
26 *
27 * @see gnu.lgpl.License for license details.<br>
28 * The copyright to this program is held by it's authors.
29 * @author DM Smith [dmsmith555 at yahoo dot com]
30 */
31 public enum FormatType {
32 AS_IS (false, false, false),
33 ANALYSIS (true, false, false),
34 CLASSIC (true, false, true),
35 ANALYSIS_INDENT (true, true, false),
36 CLASSIC_INDENT (true, true, true);
37
38 /**
39 * Simple ctor
40 */
41 private FormatType(boolean displayNewlines, boolean doIndenting, boolean classicLines) {
42 multiline = displayNewlines;
43 // the following are true only if we add newlines.
44 indented = doIndenting && multiline;
45 classic = classicLines && multiline;
46 analytic = !classicLines && multiline;
47 }
48
49 /**
50 * Whether newlines are introduced into the document.
51 *
52 * @return true if newlines are added to the document
53 */
54 public boolean isMultiline() {
55 return multiline;
56 }
57
58 /**
59 * Whether indents are introduced into the document.
60 *
61 * @return true if indents are added to the document
62 */
63 public boolean isIndented() {
64 return indented;
65 }
66
67 /**
68 * Whether added whitespace is inside tags. Note, this does not change the
69 * document.
70 *
71 * @return true if whitespace is added inside tags of document
72 */
73 public boolean isAnalytic() {
74 return analytic;
75 }
76
77 /**
78 * Whether added whitespace is between tags. Note, this does change the
79 * document as whitespace is added to either side of existing text.
80 *
81 * @return true if whitespace is added inside tags of document
82 */
83 public boolean isClassic() {
84 return classic;
85 }
86
87 private boolean indented;
88 private boolean multiline;
89 private boolean analytic;
90 private boolean classic;
91 }
92