System.XML: Remove more NET_2_0 directives
[mono.git] / mcs / class / System.XML / System.Xml.Schema / XmlSchemaParticle.cs
old mode 100755 (executable)
new mode 100644 (file)
index 6f1bdda..ef2b058
@@ -1,5 +1,5 @@
-// Author: Dwivedi, Ajay kumar\r
-//            Adwiv@Yahoo.com\r
+// Author: Dwivedi, Ajay kumar
+//            Adwiv@Yahoo.com
 
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-using System;\r
-using System.Collections;\r
+using System;
+using System.Collections;
 using System.Globalization;
-using System.Xml.Serialization;\r
-\r
-namespace System.Xml.Schema\r
-{\r
-       /// <summary>\r
-       /// Summary description for XmlSchemaParticle.\r
-       /// </summary>\r
-       public abstract class XmlSchemaParticle : XmlSchemaAnnotated\r
-       {\r
-               internal static XmlSchemaParticle Empty {\r
-                       get {\r
-                               if (empty == null) {\r
-                                       empty = new EmptyParticle ();\r
-                               }\r
-                               return empty;\r
-                       }\r
-               }\r
-\r
-               decimal minOccurs, maxOccurs;\r
-               string  minstr, maxstr;\r
-               static XmlSchemaParticle empty;\r
-               decimal validatedMinOccurs = 1, validatedMaxOccurs = 1;\r
-               internal int recursionDepth = -1;\r
-               private decimal minEffectiveTotalRange = -1;\r
-               internal bool parentIsGroupDefinition;\r
-\r
-               protected XmlSchemaParticle()\r
-               {\r
-                       minOccurs = decimal.One;\r
-                       maxOccurs = decimal.One;\r
-               }\r
-\r
-               #region Attributes\r
-\r
-               [System.Xml.Serialization.XmlAttribute("minOccurs")]\r
-               public string MinOccursString\r
-               {\r
-                       get{ return minstr; }\r
-                       set\r
-                       {\r
-                               if (value == null) {\r
-                                       minOccurs = decimal.One;\r
-                                       minstr = value;\r
-                                       return;\r
-                               }\r
-\r
-                               decimal val = decimal.Parse (value, CultureInfo.InvariantCulture);\r
-                               if(val >= 0 && (val == Decimal.Truncate(val)))\r
-                               {\r
-                                       minOccurs = val;\r
-                                       minstr   = val.ToString (CultureInfo.InvariantCulture);\r
-                               }\r
-                               else\r
-                               {\r
-                                       throw new XmlSchemaException\r
-                                               ("MinOccursString must be a non-negative number",null);                                         \r
-                               }\r
-                       }\r
-               }\r
-\r
-               [System.Xml.Serialization.XmlAttribute("maxOccurs")]\r
-               public string MaxOccursString\r
-               {\r
-                       get{ return maxstr; }\r
-                       set\r
-                       {\r
-                               if(value == "unbounded")\r
-                               {\r
-                                       maxstr = value;\r
-                                       maxOccurs = decimal.MaxValue;\r
-                               }\r
-                               else\r
-                               {\r
-                                       decimal val = decimal.Parse (value, CultureInfo.InvariantCulture);\r
-                                       if(val >= 0 && (val == Decimal.Truncate(val)))\r
-                                       {\r
-                                               maxOccurs = val;\r
-                                               maxstr = val.ToString (CultureInfo.InvariantCulture);\r
-                                       }\r
-                                       else\r
-                                       {\r
-                                               throw new XmlSchemaException\r
-                                                       ("MaxOccurs must be a non-negative integer",null);\r
-                                       }\r
-                                       if (val == 0 && minstr == null)\r
-                                               minOccurs = 0;\r
-                               }\r
-                       }\r
-               }\r
-\r
-               #endregion\r
-\r
-               #region XmlIgnore\r
-\r
-               [XmlIgnore]\r
-               public decimal MinOccurs\r
-               {\r
-                       get{ return  minOccurs; }\r
-                       set\r
-                       {\r
-                               MinOccursString = value.ToString (CultureInfo.InvariantCulture);\r
-                       }\r
-               }\r
-\r
-               [XmlIgnore]\r
-               public decimal MaxOccurs \r
-               {\r
-                       get{ return  maxOccurs; } \r
-                       set\r
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+       /// <summary>
+       /// Summary description for XmlSchemaParticle.
+       /// </summary>
+       public abstract class XmlSchemaParticle : XmlSchemaAnnotated
+       {
+               internal static XmlSchemaParticle Empty {
+                       get {
+                               if (empty == null) {
+                                       empty = new EmptyParticle ();
+                               }
+                               return empty;
+                       }
+               }
+
+               decimal minOccurs, maxOccurs;
+               string  minstr, maxstr;
+               static XmlSchemaParticle empty;
+               decimal validatedMinOccurs = 1, validatedMaxOccurs = 1;
+               internal int recursionDepth = -1;
+               private decimal minEffectiveTotalRange = -1;
+               internal bool parentIsGroupDefinition;
+
+               protected XmlSchemaParticle()
+               {
+                       minOccurs = decimal.One;
+                       maxOccurs = decimal.One;
+               }
+
+               #region Attributes
+
+               [System.Xml.Serialization.XmlAttribute("minOccurs")]
+               public string MinOccursString
+               {
+                       get{ return minstr; }
+                       set
+                       {
+                               if (value == null) {
+                                       minOccurs = decimal.One;
+                                       minstr = value;
+                                       return;
+                               }
+
+                               decimal val = decimal.Parse (value, CultureInfo.InvariantCulture);
+                               if(val >= 0 && (val == Decimal.Truncate(val)))
+                               {
+                                       minOccurs = val;
+                                       minstr   = val.ToString (CultureInfo.InvariantCulture);
+                               }
+                               else
+                               {
+                                       throw new XmlSchemaException
+                                               ("MinOccursString must be a non-negative number",null);                                         
+                               }
+                       }
+               }
+
+               [System.Xml.Serialization.XmlAttribute("maxOccurs")]
+               public string MaxOccursString
+               {
+                       get{ return maxstr; }
+                       set
+                       {
+                               if(value == "unbounded")
+                               {
+                                       maxstr = value;
+                                       maxOccurs = decimal.MaxValue;
+                               }
+                               else
+                               {
+                                       decimal val = decimal.Parse (value, CultureInfo.InvariantCulture);
+                                       if(val >= 0 && (val == Decimal.Truncate(val)))
+                                       {
+                                               maxOccurs = val;
+                                               maxstr = val.ToString (CultureInfo.InvariantCulture);
+                                       }
+                                       else
+                                       {
+                                               throw new XmlSchemaException
+                                                       ("MaxOccurs must be a non-negative integer",null);
+                                       }
+                                       if (val == 0 && minstr == null)
+                                               minOccurs = 0;
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region XmlIgnore
+
+               [XmlIgnore]
+               public decimal MinOccurs
+               {
+                       get{ return  minOccurs; }
+                       set
+                       {
+                               MinOccursString = value.ToString (CultureInfo.InvariantCulture);
+                       }
+               }
+
+               [XmlIgnore]
+               public decimal MaxOccurs 
+               {
+                       get{ return  maxOccurs; } 
+                       set
                        {
                                if (value == decimal.MaxValue)
-                                       MaxOccursString = "unbounded";\r
-                               else\r
-                                       MaxOccursString = value.ToString (CultureInfo.InvariantCulture);\r
-                       }\r
-               }\r
-\r
-               internal decimal ValidatedMinOccurs\r
-               {\r
-                       get { return validatedMinOccurs; }\r
-               }\r
-\r
-               internal decimal ValidatedMaxOccurs\r
-               {\r
-                       get { return validatedMaxOccurs; }\r
-//                     set { validatedMaxOccurs = value; }\r
-               }\r
-               #endregion\r
-\r
-               internal XmlSchemaParticle OptimizedParticle;\r
-\r
-               internal abstract XmlSchemaParticle GetOptimizedParticle (bool isTop);\r
-\r
-               internal XmlSchemaParticle GetShallowClone ()\r
-               {\r
-                       return (XmlSchemaParticle) MemberwiseClone ();\r
-               }\r
-\r
-               internal void CompileOccurence (ValidationEventHandler h, XmlSchema schema)\r
-               {\r
-                       if (MinOccurs > MaxOccurs && !(MaxOccurs == 0 && MinOccursString == null))\r
-                               error(h,"minOccurs must be less than or equal to maxOccurs");\r
-                       else {\r
-                               if (MaxOccursString == "unbounded")\r
-                                       this.validatedMaxOccurs = decimal.MaxValue;\r
-                               else\r
-                                       this.validatedMaxOccurs = maxOccurs;\r
-                               if (this.validatedMaxOccurs == 0)\r
-                                       this.validatedMinOccurs = 0;\r
-                               else\r
-                                       this.validatedMinOccurs = minOccurs;\r
-                       }\r
-               }\r
-\r
-               internal override void CopyInfo (XmlSchemaParticle obj)\r
-               {\r
-                       base.CopyInfo (obj);\r
-                       if (MaxOccursString == "unbounded")\r
-                               obj.maxOccurs = obj.validatedMaxOccurs = decimal.MaxValue;\r
-                       else \r
-                               obj.maxOccurs = obj.validatedMaxOccurs = this.ValidatedMaxOccurs;\r
-                       if (MaxOccurs == 0)\r
-                               obj.minOccurs = obj.validatedMinOccurs = 0;\r
-                       else\r
-                               obj.minOccurs = obj.validatedMinOccurs = this.ValidatedMinOccurs;\r
-                       if (MinOccursString != null)\r
-                               obj.MinOccursString = MinOccursString;\r
-                       if (MaxOccursString != null)\r
-                               obj.MaxOccursString = MaxOccursString;\r
-               }\r
-\r
-               internal virtual bool ValidateOccurenceRangeOK (XmlSchemaParticle other,\r
-                       ValidationEventHandler h, XmlSchema schema, bool raiseError)\r
-               {\r
-                       if ((this.ValidatedMinOccurs < other.ValidatedMinOccurs) ||\r
-                               (other.ValidatedMaxOccurs != decimal.MaxValue &&\r
-                               this.ValidatedMaxOccurs > other.ValidatedMaxOccurs)) {\r
-                               if (raiseError)\r
-                                       error (h, "Invalid derivation occurence range was found.");\r
-                               return false;\r
-                       }\r
-                       return true;\r
-               }\r
-\r
-               internal virtual decimal GetMinEffectiveTotalRange ()\r
-               {\r
-                       return ValidatedMinOccurs;\r
-               }\r
-\r
-               internal decimal GetMinEffectiveTotalRangeAllAndSequence ()\r
-               {\r
-                       if (minEffectiveTotalRange >= 0)\r
-                               return minEffectiveTotalRange;\r
-\r
-                       decimal product = 0; //this.ValidatedMinOccurs;\r
-                       XmlSchemaObjectCollection col = null;\r
-                       if (this is XmlSchemaAll)\r
-                               col = ((XmlSchemaAll) this).Items;\r
-                       else\r
-                               col = ((XmlSchemaSequence) this).Items;\r
-                       foreach (XmlSchemaParticle p in col)\r
-                               product += p.GetMinEffectiveTotalRange ();\r
-\r
-                       minEffectiveTotalRange = product;\r
-                       return product;\r
-               }\r
-\r
-               // 3.9.6 Particle Emptiable\r
-               internal virtual bool ValidateIsEmptiable ()\r
-               {\r
-                       return this.validatedMinOccurs == 0 || this.GetMinEffectiveTotalRange () == 0;\r
-               }\r
-\r
-               internal abstract bool ValidateDerivationByRestriction (XmlSchemaParticle baseParticle,\r
-                       ValidationEventHandler h, XmlSchema schema, bool raiseError);\r
-\r
-               internal abstract void ValidateUniqueParticleAttribution (\r
-                       XmlSchemaObjectTable qnames, ArrayList nsNames,\r
-                       ValidationEventHandler h, XmlSchema schema);\r
-\r
-               internal abstract void ValidateUniqueTypeAttribution (XmlSchemaObjectTable labels,\r
-                       ValidationEventHandler h, XmlSchema schema);\r
-\r
-               // See http://www.thaiopensource.com/relaxng/simplify.html\r
-               internal abstract void CheckRecursion (int depth, ValidationEventHandler h, XmlSchema schema);\r
-\r
-               internal abstract bool ParticleEquals (XmlSchemaParticle other);\r
-\r
-               #region Internal Class\r
-               internal class EmptyParticle : XmlSchemaParticle\r
-               {\r
-                       internal EmptyParticle ()\r
-                       {\r
-                       }\r
-\r
-                       internal override XmlSchemaParticle GetOptimizedParticle (bool isTop)\r
-                       {\r
-                               return this;\r
-                       }\r
-\r
-                       internal override bool ParticleEquals (XmlSchemaParticle other)\r
-                       {\r
-                               return other == this || other == XmlSchemaParticle.Empty;\r
-                       }\r
-\r
-                       internal override bool ValidateDerivationByRestriction (XmlSchemaParticle baseParticle,\r
-                               ValidationEventHandler h, XmlSchema schema, bool raiseError)\r
-                       {\r
-                               return true;\r
-                       }\r
-\r
-                       internal override void CheckRecursion (int depth, \r
-                               ValidationEventHandler h, XmlSchema schema)\r
-                       {\r
-                               // do nothing\r
-                       }\r
-\r
-                       internal override void ValidateUniqueParticleAttribution (XmlSchemaObjectTable qnames,\r
-                               ArrayList nsNames, ValidationEventHandler h, XmlSchema schema)\r
-                       {\r
-                               // do nothing\r
-                       }\r
-\r
-                       internal override void ValidateUniqueTypeAttribution (XmlSchemaObjectTable labels,\r
-                               ValidationEventHandler h, XmlSchema schema)\r
-                       {\r
-                               // do nothing\r
-                       }\r
-\r
-               }\r
-               #endregion\r
-       }\r
+                                       MaxOccursString = "unbounded";
+                               else
+                                       MaxOccursString = value.ToString (CultureInfo.InvariantCulture);
+                       }
+               }
+
+               internal decimal ValidatedMinOccurs
+               {
+                       get { return validatedMinOccurs; }
+               }
+
+               internal decimal ValidatedMaxOccurs
+               {
+                       get { return validatedMaxOccurs; }
+//                     set { validatedMaxOccurs = value; }
+               }
+               #endregion
+
+               internal XmlSchemaParticle OptimizedParticle;
+
+               internal virtual XmlSchemaParticle GetOptimizedParticle (bool isTop)
+               {
+                       return null;
+               }
+
+               internal XmlSchemaParticle GetShallowClone ()
+               {
+                       return (XmlSchemaParticle) MemberwiseClone ();
+               }
+
+               internal void CompileOccurence (ValidationEventHandler h, XmlSchema schema)
+               {
+                       if (MinOccurs > MaxOccurs && !(MaxOccurs == 0 && MinOccursString == null))
+                               error(h,"minOccurs must be less than or equal to maxOccurs");
+                       else {
+                               if (MaxOccursString == "unbounded")
+                                       this.validatedMaxOccurs = decimal.MaxValue;
+                               else
+                                       this.validatedMaxOccurs = maxOccurs;
+                               if (this.validatedMaxOccurs == 0)
+                                       this.validatedMinOccurs = 0;
+                               else
+                                       this.validatedMinOccurs = minOccurs;
+                       }
+               }
+
+               internal override void CopyInfo (XmlSchemaParticle obj)
+               {
+                       base.CopyInfo (obj);
+                       if (MaxOccursString == "unbounded")
+                               obj.maxOccurs = obj.validatedMaxOccurs = decimal.MaxValue;
+                       else 
+                               obj.maxOccurs = obj.validatedMaxOccurs = this.ValidatedMaxOccurs;
+                       if (MaxOccurs == 0)
+                               obj.minOccurs = obj.validatedMinOccurs = 0;
+                       else
+                               obj.minOccurs = obj.validatedMinOccurs = this.ValidatedMinOccurs;
+                       if (MinOccursString != null)
+                               obj.MinOccursString = MinOccursString;
+                       if (MaxOccursString != null)
+                               obj.MaxOccursString = MaxOccursString;
+               }
+
+               internal virtual bool ValidateOccurenceRangeOK (XmlSchemaParticle other,
+                       ValidationEventHandler h, XmlSchema schema, bool raiseError)
+               {
+                       if ((this.ValidatedMinOccurs < other.ValidatedMinOccurs) ||
+                               (other.ValidatedMaxOccurs != decimal.MaxValue &&
+                               this.ValidatedMaxOccurs > other.ValidatedMaxOccurs)) {
+                               if (raiseError)
+                                       error (h, "Invalid derivation occurence range was found.");
+                               return false;
+                       }
+                       return true;
+               }
+
+               internal virtual decimal GetMinEffectiveTotalRange ()
+               {
+                       return ValidatedMinOccurs;
+               }
+
+               internal decimal GetMinEffectiveTotalRangeAllAndSequence ()
+               {
+                       if (minEffectiveTotalRange >= 0)
+                               return minEffectiveTotalRange;
+
+                       decimal product = 0; //this.ValidatedMinOccurs;
+                       XmlSchemaObjectCollection col = null;
+                       if (this is XmlSchemaAll)
+                               col = ((XmlSchemaAll) this).Items;
+                       else
+                               col = ((XmlSchemaSequence) this).Items;
+                       foreach (XmlSchemaParticle p in col)
+                               product += p.GetMinEffectiveTotalRange ();
+
+                       minEffectiveTotalRange = product;
+                       return product;
+               }
+
+               // 3.9.6 Particle Emptiable
+               internal virtual bool ValidateIsEmptiable ()
+               {
+                       return this.validatedMinOccurs == 0 || this.GetMinEffectiveTotalRange () == 0;
+               }
+
+               internal virtual bool ValidateDerivationByRestriction (XmlSchemaParticle baseParticle,
+                       ValidationEventHandler h, XmlSchema schema, bool raiseError)
+               {
+                       return false;
+               }
+
+               internal virtual void ValidateUniqueParticleAttribution (
+                       XmlSchemaObjectTable qnames, ArrayList nsNames,
+                       ValidationEventHandler h, XmlSchema schema)
+               {
+               }
+
+               internal virtual void ValidateUniqueTypeAttribution (XmlSchemaObjectTable labels,
+                       ValidationEventHandler h, XmlSchema schema)
+               {
+               }
+
+               // See http://www.thaiopensource.com/relaxng/simplify.html
+               internal virtual void CheckRecursion (int depth, ValidationEventHandler h, XmlSchema schema)
+               {
+               }
+
+               internal virtual bool ParticleEquals (XmlSchemaParticle other)
+               {
+                       return false;
+               }
+
+               #region Internal Class
+               internal class EmptyParticle : XmlSchemaParticle
+               {
+                       internal EmptyParticle ()
+                       {
+                       }
+
+                       internal override XmlSchemaParticle GetOptimizedParticle (bool isTop)
+                       {
+                               return this;
+                       }
+
+                       internal override bool ParticleEquals (XmlSchemaParticle other)
+                       {
+                               return other == this || other == XmlSchemaParticle.Empty;
+                       }
+
+                       internal override bool ValidateDerivationByRestriction (XmlSchemaParticle baseParticle,
+                               ValidationEventHandler h, XmlSchema schema, bool raiseError)
+                       {
+                               return true;
+                       }
+
+                       internal override void CheckRecursion (int depth, 
+                               ValidationEventHandler h, XmlSchema schema)
+                       {
+                               // do nothing
+                       }
+
+                       internal override void ValidateUniqueParticleAttribution (XmlSchemaObjectTable qnames,
+                               ArrayList nsNames, ValidationEventHandler h, XmlSchema schema)
+                       {
+                               // do nothing
+                       }
+
+                       internal override void ValidateUniqueTypeAttribution (XmlSchemaObjectTable labels,
+                               ValidationEventHandler h, XmlSchema schema)
+                       {
+                               // do nothing
+                       }
+
+               }
+               #endregion
+       }
 }