Debian Codegraph @

java-sdk/ietfldap/org/ietf/ldap/util/LDIFModDNContent.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.util;
39
40 /**
41 * An object of this class represents the content of an LDIF record that
42 * specifies changes to an RDN or the DN of an entry. This class
43 * implements the <CODE>LDIFContent</CODE> interface.
44 * <P>
45 *
46 * To get this object from an <CODE>LDIFRecord</CODE> object,
47 * use the <CODE>getContent</CODE> method and cast the return value as
48 * <CODE>LDIFModDNContent</CODE>.
49 * <P>
50 *
51 * @version 1.0
52 * @see org.ietf.ldap.util.LDIFRecord#getContent
53 */
54 public class LDIFModDNContent extends LDIFBaseContent {
55 /**
56 * Internal variables
57 */
58 private String m_newParent = null;
59 private String m_rdn = null;
60 private boolean m_deleteOldRDN = false;
61 static final long serialVersionUID = 1352504898614557791L;
62
63 /**
64 * Constructs an empty <CODE>LDIFModDNContent</CODE> object.
65 * To specify the modifications to be made to the entry, use
66 * the <CODE>setRDN</CODE>, <CODE>setNewParent</CODE>,
67 * and <CODE>setDeleteOldRDN</CODE> methods.
68 * @see org.ietf.ldap.util.LDIFModDNContent#setRDN
69 * @see org.ietf.ldap.util.LDIFModDNContent#setNewParent
70 * @see org.ietf.ldap.util.LDIFModDNContent#setDeleteOldRDN
71 */
72 public LDIFModDNContent() {
73 }
74
75 /**
76 * Returns the content type. You can use this with the
77 * <CODE>getContent</CODE> method of the <CODE>LDIFRecord</CODE>
78 * object to determine the type of content specified in the record.
79 * @return the content type (which is
80 * <CODE>LDIFContent.MODDN_CONTENT</CODE>).
81 * @see org.ietf.ldap.util.LDIFRecord#getContent
82 */
83 public int getType() {
84 return MODDN_CONTENT;
85 }
86
87 /**
88 * Sets the new RDN that should be assigned to the entry.
89 * @param rdn the new RDN
90 * @see org.ietf.ldap.util.LDIFModDNContent#getRDN
91 */
92 public void setRDN(String rdn) {
93 m_rdn = rdn;
94 }
95
96 /**
97 * Returns the new RDN specified in the content of the LDIF record.
98 * @return the new RDN.
99 * @see org.ietf.ldap.util.LDIFModDNContent#setRDN
100 */
101 public String getRDN() {
102 return m_rdn;
103 }
104
105 /**
106 * Sets the new parent DN that should be assigned to the entry.
107 * @param parent the new parent DN for the entry
108 * @see org.ietf.ldap.util.LDIFModDNContent#getNewParent
109 */
110 public void setNewParent(String parent) {
111 m_newParent = parent;
112 }
113
114 /**
115 * Returns the entry's new parent DN, if specified in the content
116 * of the LDIF record.
117 * @return the new parent of the entry.
118 * @see org.ietf.ldap.util.LDIFModDNContent#setNewParent
119 */
120 public String getNewParent() {
121 return m_newParent;
122 }
123
124 /**
125 * Sets whether or not the old RDN should be removed as an
126 * attribute in the entry.
127 * @param bool if <CODE>true</CODE>, remove the attribute representing
128 * the RDN. If <CODE>false</CODE>, leave the attribute in the entry.
129 * @see org.ietf.ldap.util.LDIFModDNContent#getDeleteOldRDN
130 */
131 public void setDeleteOldRDN(boolean bool) {
132 m_deleteOldRDN = bool;
133 }
134
135 /**
136 * Determines if the content of the LDIF record specifies that
137 * the old RDN should be removed as an attribute in the entry.
138 * @return <CODE>true</CODE> if the change specifies that the
139 * the attribute representing the RDN should be removed,
140 * <CODE>false</CODE> if the change specifies that the attribute
141 * should be left in the entry.
142 * @see org.ietf.ldap.util.LDIFModDNContent#setDeleteOldRDN
143 */
144 public boolean getDeleteOldRDN() {
145 return m_deleteOldRDN;
146 }
147
148 /**
149 * Returns string representation of the content of the LDIF record.
150 * @return the string representation of the content of the LDIF record.
151 */
152 public String toString() {
153 String s = "";
154 if (m_newParent == null)
155 s = s + "new parent() ";
156 else
157 s = s + "new parent( "+m_newParent+" ), ";
158 if (m_deleteOldRDN)
159 s = s + "deleteOldRDN( true ), ";
160 else
161 s = s + "deleteOldRDN( false ), ";
162 if (m_rdn == null)
163 s = s + "new rdn()";
164 else
165 s = s + "new rdn( "+m_rdn+" )";
166
167 if ( getControls() != null ) {
168 s += getControlString();
169 }
170 return "LDIFModDNContent {" + s + "}";
171 }
172 }