Debian Codegraph @

java-sdk/ietfldap/org/ietf/ldap/client/opers/JDAPModifyRequest.java

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * The Original Code is mozilla.org code.
17 *
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1999
21 * the Initial Developer. All Rights Reserved.
22 *
23 * Contributor(s):
24 *
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
36 *
37 * ***** END LICENSE BLOCK ***** */
38 package org.ietf.ldap.client.opers;
39
40 import org.ietf.ldap.LDAPModification;
41 import org.ietf.ldap.ber.stream.BERElement;
42 import org.ietf.ldap.ber.stream.BEROctetString;
43 import org.ietf.ldap.ber.stream.BERSequence;
44 import org.ietf.ldap.ber.stream.BERTag;
45
46 /**
47 * This class implements the modify request.
48 * <pre>
49 * ModifyRequest ::= [APPLICATION 6] SEQUENCE {
50 * object LDAPDN,
51 * modification SEQUENCE OF SEQUENCE {
52 * operation ENUMERATED {
53 * add (0),
54 * delete (1),
55 * replace (2)
56 * },
57 * modification SEQUENCE {
58 * type AttributeType,
59 * values SET OF AttributeValue
60 * }
61 * }
62 * }
63 * </pre>
64 *
65 * @version 1.0
66 */
67 public class JDAPModifyRequest extends JDAPBaseDNRequest
68 implements JDAPProtocolOp {
69 /**
70 * Internal variables
71 */
72 protected String m_dn = null;
73 protected LDAPModification m_mod[] = null;
74
75 /**
76 * Constructs the modify request
77 * @param dn distinguished name of modifying
78 * @param mod list of modifications
79 */
80 public JDAPModifyRequest(String dn, LDAPModification mod[]) {
81 m_dn = dn;
82 m_mod = mod;
83 }
84
85 /**
86 * Retrieves protocol operation type.
87 * @return protocol type
88 */
89 public int getType() {
90 return JDAPProtocolOp.MODIFY_REQUEST;
91 }
92
93 /**
94 * Sets the base dn component.
95 * @param basedn base dn
96 */
97 public void setBaseDN(String basedn) {
98 m_dn = basedn;
99 }
100
101 /**
102 * Gets the base dn component.
103 * @return base dn
104 */
105 public String getBaseDN() {
106 return m_dn;
107 }
108
109 /**
110 * Gets the ber representation of modify request.
111 * @return ber representation of modify request
112 */
113 public BERElement getBERElement() {
114 BERSequence seq = new BERSequence();
115 seq.addElement(new BEROctetString(m_dn));
116 BERSequence mod_list = new BERSequence();
117 for (int i = 0; i < m_mod.length; i++) {
118 mod_list.addElement(m_mod[i].getBERElement());
119 }
120 seq.addElement(mod_list);
121 BERTag element = new BERTag(BERTag.APPLICATION|BERTag.CONSTRUCTED|6,
122 seq, true);
123 return element;
124 }
125
126 /**
127 * Retrieves string representation of modify request.
128 * @return string representation of request
129 */
130 public String toString() {
131 String s = "";
132 for (int i = 0; i < m_mod.length; i++) {
133 if (i != 0)
134 s = s + "+";
135 s = s + m_mod[i].toString();
136 }
137 return "ModifyRequest {object=" + m_dn + ", modification=" + s + "}";
138 }
139 }