updating to the latest module.
[mono.git] / mcs / class / Novell.Directory.Ldap / Novell.Directory.Ldap.Asn1 / Asn1Choice.cs
1 /******************************************************************************
2 * The MIT License
3 * Copyright (c) 2003 Novell Inc.  www.novell.com
4
5 * Permission is hereby granted, free of charge, to any person obtaining  a copy
6 * of this software and associated documentation files (the Software), to deal
7 * in the Software without restriction, including  without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
9 * copies of the Software, and to  permit persons to whom the Software is 
10 * furnished to do so, subject to the following conditions:
11
12 * The above copyright notice and this permission notice shall be included in 
13 * all copies or substantial portions of the Software.
14
15 * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 *******************************************************************************/
23 //
24 // Novell.Directory.Ldap.Asn1.Asn1Choice.cs
25 //
26 // Author:
27 //   Sunil Kumar (Sunilk@novell.com)
28 //
29 // (C) 2003 Novell, Inc (http://www.novell.com)
30 //
31
32 using System;
33
34 namespace Novell.Directory.Ldap.Asn1
35 {
36         
37         /// <summary> The Asn1Choice object represents the choice of any Asn1Object. All
38         /// Asn1Object methods are delegated to the object this Asn1Choice contains.
39         /// </summary>
40         /* Can a CHOICE contain anything BUT a TAGGED Type?
41         */
42         [CLSCompliantAttribute(true)]
43         public class Asn1Choice:Asn1Object
44         {
45                 /// <summary> Sets the CHOICE value stored in this Asn1Choice.
46                 /// 
47                 /// </summary>
48                 /// <param name="content">The Asn1Object that this Asn1Choice will
49                 /// encode.  Since all Asn1 objects are derived from Asn1Object
50                 /// any basic type can be passed in.    
51                 /// </param>
52                 [CLSCompliantAttribute(false)]
53                 virtual protected internal Asn1Object ChoiceValue
54                 {
55                         set
56                         {
57                                 this.content = value;
58                                 return ;
59                         }
60                         
61                 }
62                 
63                 private Asn1Object content;
64                 
65                 /* Constructors for Asn1Choice
66                 */
67                 
68                 /// <summary> Constructs an Asn1Choice object using an Asn1Object value.
69                 /// 
70                 /// </summary>
71                 /// <param name="content">The Asn1Object that this Asn1Choice will
72                 /// encode.  Since all Asn1 objects are derived from Asn1Object
73                 /// any basic type can be passed in.
74                 /// </param>
75                 public Asn1Choice(Asn1Object content):base(null)
76                 {
77                         this.content = content;
78                         return ;
79                 }
80                 
81                 /// <summary> No arg Constructor. This is used by Filter, who subsequently sets the
82                 /// content after parsing the RFC 2254 Search Filter String.
83                 /// </summary>
84                 protected internal Asn1Choice():base(null)
85                 {
86                         this.content = null;
87                         return ;
88                 }
89                 
90                 /* Asn1Object implementation
91                 */
92                 
93                 
94                 /// <summary> Call this method to encode the contents of this Asn1Choice
95                 /// instance into the specified output stream using the 
96                 /// specified encoder object.
97                 /// 
98                 /// </summary>
99                 /// <param name="enc">Encoder object to use when encoding self.
100                 /// 
101                 /// </param>
102                 /// <param name="out">The output stream onto which the encoded byte 
103                 /// stream is written.
104                 /// </param>
105                 public override void  encode(Asn1Encoder enc, System.IO.Stream out_Renamed)
106                 {
107                         content.encode(enc, out_Renamed);
108                         return ;
109                 }
110                 
111                 /* Asn1Choice specific methods
112                 */
113                 
114                 /// <summary> Returns the CHOICE value stored in this Asn1Choice
115                 /// as an Asn1Object. 
116                 /// </summary>
117                 public Asn1Object choiceValue()
118                 {
119                         return content;
120                 }
121                 
122                 /// <summary> This method will return the Asn1Identifier of the 
123                 /// encoded Asn1Object.We  override the parent method
124                 /// as the identifier of an Asn1Choice depends on the 
125                 /// type of the object encoded by this Asn1Choice.
126                 /// </summary>
127                 public override Asn1Identifier getIdentifier()
128                 {
129                         return content.getIdentifier();
130                 }
131                 
132                 /// <summary> Sets the identifier of the contained Asn1Object. We
133                 /// override the parent method as the identifier of 
134                 /// an Asn1Choice depends on the type of the object 
135                 /// encoded by this Asn1Choice.
136                 /// </summary>
137                 public override void  setIdentifier(Asn1Identifier id)
138                 {
139                         content.setIdentifier(id);
140                         return ;
141                 }
142                 
143                 /// <summary> Return a String representation of this Asn1Object.</summary>
144                 public override System.String ToString()
145                 {
146                         return content.ToString();
147                 }
148         }
149 }