New test.
[mono.git] / mcs / class / System.XML / System.Xml / XmlWriterSettings.cs
1 //
2 // XmlWriterSettings.cs
3 //
4 // Author:
5 //   Atsushi Enomoto <atsushi@ximian.com>
6 //
7 // (C) 2004 Novell Inc.
8 //
9
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 #if NET_2_0
32
33 using System;
34 using System.IO;
35 using System.Text;
36 using System.Xml.Schema;
37
38 namespace System.Xml
39 {
40         public sealed class XmlWriterSettings
41         {
42                 private bool checkCharacters;
43                 private bool closeOutput;
44                 private ConformanceLevel conformance;
45                 private Encoding encoding;
46                 private bool indent;
47                 private string indentChars;
48                 private string newLineChars;
49                 private bool newLineOnAttributes;
50                 private NewLineHandling newLineHandling;
51                 private bool omitXmlDeclaration;
52                 private XmlOutputMethod outputMethod;
53
54                 public XmlWriterSettings ()
55                 {
56                         Reset ();
57                 }
58
59                 private XmlWriterSettings (XmlWriterSettings org)
60                 {
61                         checkCharacters = org.checkCharacters;
62                         closeOutput = org.closeOutput;
63                         conformance = org.conformance;
64                         encoding = org.encoding;
65                         indent = org.indent;
66                         indentChars = org.indentChars;
67                         newLineChars = org.newLineChars;
68                         newLineOnAttributes = org.newLineOnAttributes;
69                         newLineHandling = org.newLineHandling;
70                         outputMethod = org.outputMethod;
71                         omitXmlDeclaration = org.omitXmlDeclaration;
72                 }
73
74                 public XmlWriterSettings Clone ()
75                 {
76                         return new XmlWriterSettings (this);
77                 }
78
79                 public void Reset ()
80                 {
81                         checkCharacters = true;
82                         closeOutput = false; // ? not documented
83                         conformance = ConformanceLevel.Document;
84                         encoding = Encoding.UTF8;
85                         indent = false;
86                         indentChars = "  ";
87                         // LAMESPEC: MS.NET says it is "\r\n", but it is silly decision.
88                         newLineChars = Environment.NewLine;
89                         newLineOnAttributes = false;
90                         newLineHandling = NewLineHandling.None;
91                         omitXmlDeclaration = false;
92                         outputMethod = XmlOutputMethod.AutoDetect;
93                 }
94
95                 // It affects only on XmlTextWriter
96                 public bool CheckCharacters {
97                         get { return checkCharacters; }
98                         set { checkCharacters = value; }
99                 }
100
101                 // It affects only on XmlTextWriter
102                 public bool CloseOutput {
103                         get { return closeOutput; }
104                         set { closeOutput = value; }
105                 }
106
107                 // It affects only on XmlTextWriter????
108                 public ConformanceLevel ConformanceLevel {
109                         get { return conformance; }
110                         set { conformance = value; }
111                 }
112
113                 public Encoding Encoding {
114                         get { return encoding; }
115                         set { encoding = value; }
116                 }
117
118                 // It affects only on XmlTextWriter
119                 public bool Indent {
120                         get { return indent; }
121                         set { indent = value; }
122                 }
123
124                 // It affects only on XmlTextWriter
125                 public string IndentChars {
126                         get { return indentChars; }
127                         set { indentChars = value; }
128                 }
129
130                 // It affects only on XmlTextWriter
131                 public string NewLineChars {
132                         get { return newLineChars; }
133                         set {
134                                 if (value == null)
135                                         throw new ArgumentNullException ("value");
136                                 newLineChars = value;
137                         }
138                 }
139
140                 // It affects only on XmlTextWriter
141                 public bool NewLineOnAttributes {
142                         get { return newLineOnAttributes; }
143                         set { newLineOnAttributes = value; }
144                 }
145
146                 // It affects only on XmlTextWriter
147                 public NewLineHandling NewLineHandling {
148                         get { return newLineHandling; }
149                         set { newLineHandling = value; }
150                 }
151
152                 // It affects only on XmlTextWriter
153                 public bool OmitXmlDeclaration {
154                         get { return omitXmlDeclaration; }
155                         set { omitXmlDeclaration = value; }
156                 }
157
158                 // does it affect only on XmlTextWriter?
159                 public XmlOutputMethod OutputMethod {
160                         get { return outputMethod; }
161                         //set { outputMethod = value; }
162                 }
163         }
164 }
165
166 #endif