New test.
[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         public class Asn1Choice:Asn1Object
43         {
44                 /// <summary> Sets the CHOICE value stored in this Asn1Choice.
45                 /// 
46                 /// </summary>
47                 /// <param name="content">The Asn1Object that this Asn1Choice will
48                 /// encode.  Since all Asn1 objects are derived from Asn1Object
49                 /// any basic type can be passed in.    
50                 /// </param>
51                 [CLSCompliantAttribute(false)]
52                 virtual protected internal Asn1Object ChoiceValue
53                 {
54                         set
55                         {
56                                 this.content = value;
57                                 return ;
58                         }
59                         
60                 }
61                 
62                 private Asn1Object content;
63                 
64                 /* Constructors for Asn1Choice
65                 */
66                 
67                 /// <summary> Constructs an Asn1Choice object using an Asn1Object value.
68                 /// 
69                 /// </summary>
70                 /// <param name="content">The Asn1Object that this Asn1Choice will
71                 /// encode.  Since all Asn1 objects are derived from Asn1Object
72                 /// any basic type can be passed in.
73                 /// </param>
74                 public Asn1Choice(Asn1Object content):base(null)
75                 {
76                         this.content = content;
77                         return ;
78                 }
79                 
80                 /// <summary> No arg Constructor. This is used by Filter, who subsequently sets the
81                 /// content after parsing the RFC 2254 Search Filter String.
82                 /// </summary>
83                 protected internal Asn1Choice():base(null)
84                 {
85                         this.content = null;
86                         return ;
87                 }
88                 
89                 /* Asn1Object implementation
90                 */
91                 
92                 
93                 /// <summary> Call this method to encode the contents of this Asn1Choice
94                 /// instance into the specified output stream using the 
95                 /// specified encoder object.
96                 /// 
97                 /// </summary>
98                 /// <param name="enc">Encoder object to use when encoding self.
99                 /// 
100                 /// </param>
101                 /// <param name="out">The output stream onto which the encoded byte 
102                 /// stream is written.
103                 /// </param>
104                 public override void  encode(Asn1Encoder enc, System.IO.Stream out_Renamed)
105                 {
106                         content.encode(enc, out_Renamed);
107                         return ;
108                 }
109                 
110                 /* Asn1Choice specific methods
111                 */
112                 
113                 /// <summary> Returns the CHOICE value stored in this Asn1Choice
114                 /// as an Asn1Object. 
115                 /// </summary>
116                 public Asn1Object choiceValue()
117                 {
118                         return content;
119                 }
120                 
121                 /// <summary> This method will return the Asn1Identifier of the 
122                 /// encoded Asn1Object.We  override the parent method
123                 /// as the identifier of an Asn1Choice depends on the 
124                 /// type of the object encoded by this Asn1Choice.
125                 /// </summary>
126                 public override Asn1Identifier getIdentifier()
127                 {
128                         return content.getIdentifier();
129                 }
130                 
131                 /// <summary> Sets the identifier of the contained Asn1Object. We
132                 /// override the parent method as the identifier of 
133                 /// an Asn1Choice depends on the type of the object 
134                 /// encoded by this Asn1Choice.
135                 /// </summary>
136                 public override void  setIdentifier(Asn1Identifier id)
137                 {
138                         content.setIdentifier(id);
139                         return ;
140                 }
141                 
142                 /// <summary> Return a String representation of this Asn1Object.</summary>
143                 public override System.String ToString()
144                 {
145                         return content.ToString();
146                 }
147         }
148 }