2 // Novell.Directory.Ldap.Rfc2251.RfcLdapSuperDN.cs
5 // Boris Kirzner (borisk@mainsoft.com)
9 using Novell.Directory.Ldap.Asn1;
11 namespace Novell.Directory.Ldap.Rfc2251
\r
13 ///<summary>Represents an [0] LDAP DN OPTIONAL used as newSuperior attribute of
\r
14 /// ModifyDNRequest (For more detail on this Syntax refer to rfc2251).
\r
16 public class RfcLdapSuperDN : Asn1Tagged
\r
18 private sbyte[] content;
\r
21 /// ASN.1 [0] LDAP DN OPTIONAL tag definition.
\r
23 public static readonly int TAG = 0x00;
\r
25 /// <summary> ID is added for Optimization.
\r
26 /// Id needs only be one Value for every instance, thus we create it only once.
\r
28 protected static readonly Asn1Identifier ID = new Asn1Identifier(Asn1Identifier.CONTEXT, false, TAG);
\r
30 /// <summary> Constructs an RfcLDAPSuperDN object from a String object.
\r
32 /// <param name="content"> A string value that will be contained in the this RfcLDAPSuperDN object </param>
\r
33 public RfcLdapSuperDN(String s) : base(ID, new Asn1OctetString(s), false) //type is encoded IMPLICITLY
\r
36 System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8");
37 byte[] ibytes = encoder.GetBytes(s);
38 sbyte[] sbytes=SupportClass.ToSByteArray(ibytes);
40 this.content = sbytes;
\r
42 catch(System.IO.IOException uee) {
\r
43 throw new System.SystemException(uee.ToString());
\r
47 /// <summary> Constructs an RfcLDAPSuperDN object from a byte array. </summary>
\r
48 /// <param name="content"> A byte array representing the string that will be contained in the this RfcLDAPSuperDN object </param>
\r
49 [CLSCompliantAttribute(false)]
\r
50 public RfcLdapSuperDN(sbyte[] ba) : base(ID, new Asn1OctetString(ba), false) //type is encoded IMPLICITLY
\r
55 /// <summary> Encodes the current instance into the
56 /// specified output stream using the specified encoder object.
59 /// <param name="enc">Encoder object to use when encoding self.
62 /// <param name="out">The output stream onto which the encoded byte
63 /// stream is written.
65 public override void encode(Asn1Encoder enc, System.IO.Stream out_Renamed)
67 enc.encode(this, out_Renamed);
71 /// <summary> Returns the content of this RfcLdapSuperDN as a byte array.</summary>
72 [CLSCompliantAttribute(false)]
73 public sbyte[] byteValue()
79 /// <summary> Returns the content of this RfcLdapSuperDN as a String.</summary>
80 public System.String stringValue()
82 System.String s = null;
84 System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8");
85 char[] dchar = encoder.GetChars(SupportClass.ToByteArray(content));
86 s = new String(dchar);
88 catch (System.IO.IOException uee) {
89 throw new System.SystemException(uee.ToString());
95 /// <summary> Return a String representation of this RfcLdapSuperDN.</summary>
96 public override System.String ToString()
98 return base.ToString() + " " + stringValue();