2002-12-24 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
[mono.git] / mcs / class / System.XML / System.Xml / XmlSignificantWhitespace.cs
1 //
2 // System.Xml.XmlSignificantWhitespace.cs
3 //
4 // Author:
5 //      Duncan Mak  (duncan@ximian.com)
6 //
7 // (C) Ximian, Inc. http://www.ximian.com
8 //
9
10 using System;
11 using System.Xml.XPath;
12
13 namespace System.Xml
14 {
15         public class XmlSignificantWhitespace : XmlCharacterData
16         {
17                 // Constructor
18                 protected internal XmlSignificantWhitespace (string strData, XmlDocument doc)
19                         : base (strData, doc)
20                 {
21                 }
22                 
23                 // Properties
24                 public override string LocalName {
25                         get { return "#significant-whitespace"; }
26                 }
27
28                 public override string Name {
29                         get { return "#significant-whitespace"; }
30                 }
31
32                 public override XmlNodeType NodeType {
33                         get { return XmlNodeType.SignificantWhitespace; }
34                 }
35
36                 internal override XPathNodeType XPathNodeType {
37                         get {
38                                 return XPathNodeType.SignificantWhitespace;
39                         }
40                 }
41                 
42                 public override string Value {
43                         get { return Data; }
44                         set {
45                                 if (IsValidWhitespaceChar (value) == false)
46                                         throw new ArgumentException ("Invalid whitespace characters.");
47                                 base.Data = value;
48                         }
49                 }
50
51                 // Methods
52                 public override XmlNode CloneNode (bool deep)
53                 {
54                         return new XmlSignificantWhitespace (Data, OwnerDocument);
55                 }
56
57                 public override void WriteContentTo (XmlWriter w) {}
58
59                 public override void WriteTo (XmlWriter w)
60                 {
61                         w.WriteWhitespace (Data);
62                 }
63
64                 private bool IsValidWhitespaceChar (string text)
65                 {
66                         foreach (char c in text)
67                                 if ((c != ' ') && (c != '\r') && (c != '\n') && (c != '\t'))
68                                         return false;
69                         return true;
70                 }
71         }
72 }