(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / Novell.Directory.Ldap / Novell.Directory.Ldap.Asn1 / Asn1Tagged.cs
blob8f89ef6fce3b9aaa0b7ce5a07997c1fa1f8d0bb6
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:
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
21 * SOFTWARE.
22 *******************************************************************************/
24 // Novell.Directory.Ldap.Asn1.Asn1Tagged.cs
26 // Author:
27 // Sunil Kumar (Sunilk@novell.com)
29 // (C) 2003 Novell, Inc (http://www.novell.com)
32 using System;
34 namespace Novell.Directory.Ldap.Asn1
37 /// <summary> The Asn1Tagged class can hold a base Asn1Object with a distinctive tag
38 /// describing the type of that base object. It also maintains a boolean value
39 /// indicating whether the value should be encoded by EXPLICIT or IMPLICIT
40 /// means. (Explicit is true by default.)
41 ///
42 /// If the type is encoded IMPLICITLY, the base types form, length and content
43 /// will be encoded as usual along with the class type and tag specified in
44 /// the constructor of this Asn1Tagged class.
45 ///
46 /// If the type is to be encoded EXPLICITLY, the base type will be encoded as
47 /// usual after the Asn1Tagged identifier has been encoded.
48 /// </summary>
49 [CLSCompliantAttribute(true)]
50 public class Asn1Tagged:Asn1Object
52 /// <summary> Sets the Asn1Object tagged value</summary>
53 [CLSCompliantAttribute(false)]
54 virtual public Asn1Object TaggedValue
56 set
58 this.content = value;
59 if (!explicit_Renamed && value != null)
61 // replace object's id with new tag.
62 value.setIdentifier(this.getIdentifier());
67 /// <summary> Returns a boolean value indicating if this object uses
68 /// EXPLICIT tagging.
69 /// </summary>
70 virtual public bool Explicit
72 get
74 return explicit_Renamed;
79 private bool explicit_Renamed;
80 private Asn1Object content;
82 /* Constructors for Asn1Tagged
85 /// <summary> Constructs an Asn1Tagged object using the provided
86 /// AN1Identifier and the Asn1Object.
87 ///
88 /// The explicit flag defaults to true as per the spec.
89 /// </summary>
90 public Asn1Tagged(Asn1Identifier identifier, Asn1Object object_Renamed):this(identifier, object_Renamed, true)
92 return ;
95 /// <summary> Constructs an Asn1Tagged object.</summary>
96 public Asn1Tagged(Asn1Identifier identifier, Asn1Object object_Renamed, bool explicit_Renamed):base(identifier)
98 this.content = object_Renamed;
99 this.explicit_Renamed = explicit_Renamed;
101 if (!explicit_Renamed && content != null)
103 // replace object's id with new tag.
104 content.setIdentifier(identifier);
106 return ;
109 /// <summary> Constructs an Asn1Tagged object by decoding data from an
110 /// input stream.
111 ///
112 /// </summary>
113 /// <param name="dec">The decoder object to use when decoding the
114 /// input stream. Sometimes a developer might want to pass
115 /// in his/her own decoder object
116 ///
117 /// </param>
118 /// <param name="in">A byte stream that contains the encoded ASN.1
119 ///
120 /// </param>
121 [CLSCompliantAttribute(false)]
122 public Asn1Tagged(Asn1Decoder dec, System.IO.Stream in_Renamed, int len, Asn1Identifier identifier):base(identifier)
125 // If we are decoding an implicit tag, there is no way to know at this
126 // low level what the base type really is. We can place the content
127 // into an Asn1OctetString type and pass it back to the application who
128 // will be able to create the appropriate ASN.1 type for this tag.
129 content = new Asn1OctetString(dec, in_Renamed, len);
130 return ;
133 /* Asn1Object implementation
136 /// <summary> Call this method to encode the current instance into the
137 /// specified output stream using the specified encoder object.
138 ///
139 /// </summary>
140 /// <param name="enc">Encoder object to use when encoding self.
141 ///
142 /// </param>
143 /// <param name="out">The output stream onto which the encoded byte
144 /// stream is written.
145 /// </param>
146 public override void encode(Asn1Encoder enc, System.IO.Stream out_Renamed)
148 enc.encode(this, out_Renamed);
149 return ;
152 /* Asn1Tagged specific methods
155 /// <summary> Returns the Asn1Object stored in this Asn1Tagged object</summary>
156 public Asn1Object taggedValue()
158 return content;
161 /// <summary> Return a String representation of this Asn1Object.</summary>
162 public override System.String ToString()
164 if (explicit_Renamed)
166 return base.ToString() + content.ToString();
168 // implicit tagging
169 return content.ToString();