(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / Commons.Xml.Relaxng / Commons.Xml.Relaxng.Derivative / RdpNameClasses.cs
blob8e1eb9fbdb0682e72bc9b080cd1ba7ede8a61125
1 //
2 // Commons.Xml.Relaxng.Derivative.RdpNameClasses.cs
3 //
4 // Author:
5 // Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
6 //
7 // 2003 Atsushi Enomoto "No rights reserved."
8 //
9 // Copyright (c) 2004 Novell Inc.
10 // All rights reserved
14 // Permission is hereby granted, free of charge, to any person obtaining
15 // a copy of this software and associated documentation files (the
16 // "Software"), to deal in the Software without restriction, including
17 // without limitation the rights to use, copy, modify, merge, publish,
18 // distribute, sublicense, and/or sell copies of the Software, and to
19 // permit persons to whom the Software is furnished to do so, subject to
20 // the following conditions:
21 //
22 // The above copyright notice and this permission notice shall be
23 // included in all copies or substantial portions of the Software.
24 //
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using System;
35 using System.Xml;
37 namespace Commons.Xml.Relaxng.Derivative
39 public enum RdpNameClassType
41 None = 0,
42 AnyName = 1,
43 AnyNameExcept = 2,
44 NsName = 3,
45 NsNameExcept = 4,
46 Name = 5,
47 NameClassChoice = 6
50 public abstract class RdpNameClass
52 public abstract RdpNameClassType NameClassType { get; }
53 public abstract bool Contains (string name, string ns);
56 public class RdpAnyName : RdpNameClass
58 static RdpAnyName instance;
59 static RdpAnyName ()
61 instance = new RdpAnyName ();
64 public static RdpAnyName Instance {
65 get { return instance; }
68 private RdpAnyName () {}
70 public override RdpNameClassType NameClassType {
71 get { return RdpNameClassType.AnyName; }
74 public override bool Contains (string name, string ns)
76 return true;
80 public class RdpAnyNameExcept : RdpNameClass
82 RdpNameClass except;
84 public RdpAnyNameExcept (RdpNameClass except)
86 this.except = except;
89 public override RdpNameClassType NameClassType {
90 get { return RdpNameClassType.AnyNameExcept; }
93 public RdpNameClass ExceptNameClass {
94 get { return except; }
97 public override bool Contains (string name, string ns)
99 return (except == null) || !except.Contains (name, ns);
103 public class RdpNsName : RdpNameClass
105 string ns;
107 public RdpNsName (string ns)
109 this.ns = ns;
112 public override RdpNameClassType NameClassType {
113 get { return RdpNameClassType.NsName; }
116 public string NamespaceURI {
117 get { return ns; }
120 public override bool Contains (string name, string ns)
122 return NamespaceURI == ns;
126 public class RdpNsNameExcept : RdpNsName
128 string ns;
129 RdpNameClass except;
131 public RdpNsNameExcept (string ns, RdpNameClass except)
132 : base (ns)
134 this.ns = ns;
135 this.except = except;
138 public override RdpNameClassType NameClassType {
139 get { return RdpNameClassType.NsNameExcept; }
142 public RdpNameClass ExceptNameClass {
143 get { return except; }
146 public override bool Contains (string name, string ns)
148 return this.ns == ns &&
149 (except == null || !except.Contains (name, ns));
153 public class RdpName : RdpNameClass
155 string local;
156 string ns;
158 public RdpName (string local, string ns)
160 this.ns = ns;
161 this.local = local;
164 public override RdpNameClassType NameClassType {
165 get { return RdpNameClassType.Name; }
168 public string NamespaceURI {
169 get { return ns; }
172 public string LocalName {
173 get { return local; }
176 public override bool Contains (string name, string ns)
178 return this.ns == ns && this.local == name;
182 public class RdpNameClassChoice : RdpNameClass
184 RdpNameClass l;
185 RdpNameClass r;
187 public RdpNameClassChoice (RdpNameClass l, RdpNameClass r)
189 this.l = l;
190 this.r = r;
193 public override RdpNameClassType NameClassType {
194 get { return RdpNameClassType.NameClassChoice; }
197 public RdpNameClass LValue {
198 get { return l; }
201 public RdpNameClass RValue {
202 get { return r; }
205 public override bool Contains (string name, string ns)
207 return l.Contains (name, ns) || r.Contains (name, ns);