KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > naming > ldap > BasicControl


1 /*
2  * @(#)BasicControl.java 1.3 03/12/19
3  *
4  *
5  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
6  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
7  */

8
9 package javax.naming.ldap;
10
11 /**
12  * This class provides a basic implementation of the <tt>Control</tt>
13  * interface. It represents an LDAPv3 Control as defined in
14  * <a HREF="http://www.ietf.org/rfc/rfc2251.txt">RFC 2251</a>.
15  *
16  * @since 1.5
17  * @author Vincent Ryan
18  */

19 public class BasicControl implements Control JavaDoc {
20
21     /**
22      * The control's object identifier string.
23      *
24      * @serial
25      */

26     protected String JavaDoc id;
27
28     /**
29      * The control's criticality.
30      *
31      * @serial
32      */

33     protected boolean criticality = false; // default
34

35     /**
36      * The control's ASN.1 BER encoded value.
37      *
38      * @serial
39      */

40     protected byte[] value = null;
41
42     private static final long serialVersionUID = -4233907508771791687L;
43
44     /**
45      * Constructs a non-critical control.
46      *
47      * @param id The control's object identifier string.
48      *
49      */

50     public BasicControl(String JavaDoc id) {
51     this.id = id;
52     }
53
54     /**
55      * Constructs a control using the supplied arguments.
56      *
57      * @param id The control's object identifier string.
58      * @param criticality The control's criticality.
59      * @param value The control's ASN.1 BER encoded value.
60      * It is not cloned - any changes to value
61      * will affect the contents of the control.
62      * It may be null.
63      */

64     public BasicControl(String JavaDoc id, boolean criticality, byte[] value) {
65     this.id = id;
66     this.criticality = criticality;
67     this.value = value;
68     }
69
70     /**
71      * Retrieves the control's object identifier string.
72      *
73      * @return The non-null object identifier string.
74      */

75     public String JavaDoc getID() {
76     return id;
77     }
78
79     /**
80      * Determines the control's criticality.
81      *
82      * @return true if the control is critical; false otherwise.
83      */

84     public boolean isCritical() {
85     return criticality;
86     }
87
88     /**
89      * Retrieves the control's ASN.1 BER encoded value.
90      * The result includes the BER tag and length for the control's value but
91      * does not include the control's object identifier and criticality setting.
92      *
93      * @return A possibly null byte array representing the control's
94      * ASN.1 BER encoded value. It is not cloned - any changes to the
95      * returned value will affect the contents of the control.
96      */

97     public byte[] getEncodedValue() {
98     return value;
99     }
100 }
101
Popular Tags