1 /******************************************************************************
3 * Copyright (c) 2003 Novell Inc. www.novell.com
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:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
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
22 *******************************************************************************/
24 // Novell.Directory.Ldap.Asn1.Asn1Choice.cs
27 // Sunil Kumar (Sunilk@novell.com)
29 // (C) 2003 Novell, Inc (http://www.novell.com)
34 namespace Novell.Directory.Ldap.Asn1
37 /// <summary> The Asn1Choice object represents the choice of any Asn1Object. All
38 /// Asn1Object methods are delegated to the object this Asn1Choice contains.
40 /* Can a CHOICE contain anything BUT a TAGGED Type?
42 [CLSCompliantAttribute(true)]
43 public class Asn1Choice:Asn1Object
45 /// <summary> Sets the CHOICE value stored in this Asn1Choice.
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.
52 [CLSCompliantAttribute(false)]
53 virtual protected internal Asn1Object ChoiceValue
63 private Asn1Object content;
65 /* Constructors for Asn1Choice
68 /// <summary> Constructs an Asn1Choice object using an Asn1Object value.
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.
75 public Asn1Choice(Asn1Object content):base(null)
77 this.content = content;
81 /// <summary> No arg Constructor. This is used by Filter, who subsequently sets the
82 /// content after parsing the RFC 2254 Search Filter String.
84 protected internal Asn1Choice():base(null)
90 /* Asn1Object implementation
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.
99 /// <param name="enc">Encoder object to use when encoding self.
102 /// <param name="out">The output stream onto which the encoded byte
103 /// stream is written.
105 public override void encode(Asn1Encoder enc, System.IO.Stream out_Renamed)
107 content.encode(enc, out_Renamed);
111 /* Asn1Choice specific methods
114 /// <summary> Returns the CHOICE value stored in this Asn1Choice
115 /// as an Asn1Object.
117 public Asn1Object choiceValue()
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.
127 public override Asn1Identifier getIdentifier()
129 return content.getIdentifier();
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.
137 public override void setIdentifier(Asn1Identifier id)
139 content.setIdentifier(id);
143 /// <summary> Return a String representation of this Asn1Object.</summary>
144 public override System.String ToString()
146 return content.ToString();