Debian Codegraph @

mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapSuperDN.cs

raw
1 //
2 // Novell.Directory.Ldap.Rfc2251.RfcLdapSuperDN.cs
3 //
4 // Author:
5 // Boris Kirzner ([email protected])
6 //
7
8 using System;
9 using Novell.Directory.Ldap.Asn1;
10
11 namespace Novell.Directory.Ldap.Rfc2251
12 {
13 ///<summary>Represents an [0] LDAP DN OPTIONAL used as newSuperior attribute of
14 /// ModifyDNRequest (For more detail on this Syntax refer to rfc2251).
15 /// </summary>
16 public class RfcLdapSuperDN : Asn1Tagged
17 {
18 private sbyte[] content;
19
20 /// <summary>
21 /// ASN.1 [0] LDAP DN OPTIONAL tag definition.
22 /// </summary>
23 public static readonly int TAG = 0x00;
24
25 /// <summary> ID is added for Optimization.
26 /// Id needs only be one Value for every instance, thus we create it only once.
27 /// </summary>
28 protected static readonly Asn1Identifier ID = new Asn1Identifier(Asn1Identifier.CONTEXT, false, TAG);
29
30 /// <summary> Constructs an RfcLDAPSuperDN object from a String object.
31 /// </summary>
32 /// <param name="content"> A string value that will be contained in the this RfcLDAPSuperDN object </param>
33 public RfcLdapSuperDN(String s) : base(ID, new Asn1OctetString(s), false) //type is encoded IMPLICITLY
34 {
35 try {
36 System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8");
37 byte[] ibytes = encoder.GetBytes(s);
38 sbyte[] sbytes=SupportClass.ToSByteArray(ibytes);
39
40 this.content = sbytes;
41 }
42 catch(System.IO.IOException uee) {
43 throw new System.SystemException(uee.ToString());
44 }
45 }
46
47 /// <summary> Constructs an RfcLDAPSuperDN object from a byte array. </summary>
48 /// <param name="content"> A byte array representing the string that will be contained in the this RfcLDAPSuperDN object </param>
49 [CLSCompliantAttribute(false)]
50 public RfcLdapSuperDN(sbyte[] ba) : base(ID, new Asn1OctetString(ba), false) //type is encoded IMPLICITLY
51 {
52 this.content = ba;
53 }
54
55 /// <summary> Encodes the current instance into the
56 /// specified output stream using the specified encoder object.
57 ///
58 /// </summary>
59 /// <param name="enc">Encoder object to use when encoding self.
60 ///
61 /// </param>
62 /// <param name="out">The output stream onto which the encoded byte
63 /// stream is written.
64 /// </param>
65 public override void encode(Asn1Encoder enc, System.IO.Stream out_Renamed)
66 {
67 enc.encode(this, out_Renamed);
68 return ;
69 }
70
71 /// <summary> Returns the content of this RfcLdapSuperDN as a byte array.</summary>
72 [CLSCompliantAttribute(false)]
73 public sbyte[] byteValue()
74 {
75 return content;
76 }
77
78
79 /// <summary> Returns the content of this RfcLdapSuperDN as a String.</summary>
80 public System.String stringValue()
81 {
82 System.String s = null;
83 try {
84 System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8");
85 char[] dchar = encoder.GetChars(SupportClass.ToByteArray(content));
86 s = new String(dchar);
87 }
88 catch (System.IO.IOException uee) {
89 throw new System.SystemException(uee.ToString());
90 }
91 return s;
92 }
93
94
95 /// <summary> Return a String representation of this RfcLdapSuperDN.</summary>
96 public override System.String ToString()
97 {
98 return base.ToString() + " " + stringValue();
99 }
100
101 }
102 }