001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 *  
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 *  
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License. 
018 *  
019 */
020package org.apache.directory.shared.ldap.trigger;
021
022
023import org.apache.directory.shared.ldap.model.name.Dn;
024
025
026/**
027 * An entity that represents a stored procedure parameter which can be
028 * specified in an LDAP Trigger Specification.
029 * 
030 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
031 */
032public abstract class StoredProcedureParameter
033{
034    public static final class Generic_LDAP_CONTEXT extends StoredProcedureParameter
035    {
036        private Dn ctxName;
037        
038        private Generic_LDAP_CONTEXT( Dn ctxName )
039        {
040            super( "$ldapContext" );
041            this.ctxName = ctxName;
042        }
043        
044        public static StoredProcedureParameter instance( Dn ctxName )
045        {
046            return new Generic_LDAP_CONTEXT( ctxName );
047        }
048        
049        public Dn getCtxName()
050        {
051            return ctxName;
052        }
053        
054        public String toString()
055        {
056            return name + " \"" + ctxName.getName() + "\"";
057        }
058    }
059
060    
061    public static final class Generic_OPERATION_PRINCIPAL extends StoredProcedureParameter
062    {
063        private static Generic_OPERATION_PRINCIPAL instance = new Generic_OPERATION_PRINCIPAL( "$operationPrincipal" );
064        
065        private Generic_OPERATION_PRINCIPAL( String identifier )
066        {
067            super( identifier );
068        }
069        
070        public static StoredProcedureParameter instance()
071        {
072            return instance;
073        }
074    }
075
076    
077    protected final String name;
078
079
080    protected StoredProcedureParameter( String name )
081    {
082        this.name = name;
083    }
084
085
086    /**
087     * Returns the name of this Stored Procedure Parameter.
088     */
089    public String getName()
090    {
091        return name;
092    }
093
094
095    public String toString()
096    {
097        return name;
098    }
099    
100
101    /**
102     * @see java.lang.Object#hashCode()
103     * @return the instance's hash code 
104     */
105    public int hashCode()
106    {
107        int h = 37;
108        
109        h = h*17 + ( ( name == null ) ? 0 : name.hashCode() );
110        
111        return h;
112    }
113
114
115    /**
116     * @see java.lang.Object#equals(java.lang.Object)
117     */
118    public boolean equals( Object obj )
119    {
120        if ( this == obj )
121        {
122            return true;
123        }
124        if ( obj == null )
125        {
126            return false;
127        }
128        if ( getClass() != obj.getClass() )
129        {
130            return false;
131        }
132        final StoredProcedureParameter other = ( StoredProcedureParameter ) obj;
133        if ( name == null )
134        {
135            if ( other.name != null )
136            {
137                return false;
138            }
139        }
140        else if ( !name.equals( other.name ) )
141        {
142            return false;
143        }
144        return true;
145    }
146
147    
148    public static final class Modify_OBJECT extends StoredProcedureParameter
149    {
150        private static Modify_OBJECT instance = new Modify_OBJECT( "$object" );
151        
152        private Modify_OBJECT( String identifier )
153        {
154            super( identifier );
155        }
156        
157        public static StoredProcedureParameter instance()
158        {
159            return instance;
160        }
161    }
162    
163    
164    public static final class Modify_MODIFICATION extends StoredProcedureParameter
165    {
166        private static Modify_MODIFICATION instance = new Modify_MODIFICATION( "$modification" );
167        
168        private Modify_MODIFICATION( String identifier )
169        {
170            super( identifier );
171        }
172        
173        public static StoredProcedureParameter instance()
174        {
175            return instance;
176        }
177    }
178    
179    
180    public static final class Modify_OLD_ENTRY extends StoredProcedureParameter
181    {
182        private static Modify_OLD_ENTRY instance = new Modify_OLD_ENTRY( "$oldEntry" );
183        
184        private Modify_OLD_ENTRY( String identifier )
185        {
186            super( identifier );
187        }
188        
189        public static StoredProcedureParameter instance()
190        {
191            return instance;
192        }
193    }
194    
195    
196    public static final class Modify_NEW_ENTRY extends StoredProcedureParameter
197    {
198        private static Modify_NEW_ENTRY instance = new Modify_NEW_ENTRY( "$newEntry" );
199        
200        private Modify_NEW_ENTRY( String identifier )
201        {
202            super( identifier );
203        }
204        
205        public static StoredProcedureParameter instance()
206        {
207            return instance;
208        }
209    }
210
211    
212    public static final class Add_ENTRY extends StoredProcedureParameter
213    {
214        private static Add_ENTRY instance = new Add_ENTRY( "$entry" );
215        
216        private Add_ENTRY( String identifier )
217        {
218            super( identifier );
219        }
220        
221        public static StoredProcedureParameter instance()
222        {
223            return instance;
224        }
225    }
226    
227    
228    public static final class Add_ATTRIBUTES extends StoredProcedureParameter
229    {
230        private static Add_ATTRIBUTES instance = new Add_ATTRIBUTES( "$attributes" );
231        
232        private Add_ATTRIBUTES( String identifier )
233        {
234            super( identifier );
235        }
236        
237        public static StoredProcedureParameter instance()
238        {
239            return instance;
240        }
241    }
242
243    
244    public static final class Delete_NAME extends StoredProcedureParameter
245    {
246        private static Delete_NAME instance = new Delete_NAME( "$name" );
247        
248        private Delete_NAME( String identifier )
249        {
250            super( identifier );
251        }
252        
253        public static StoredProcedureParameter instance()
254        {
255            return instance;
256        }
257    }
258    
259    
260    public static final class Delete_DELETED_ENTRY extends StoredProcedureParameter
261    {
262        private static Delete_DELETED_ENTRY instance = new Delete_DELETED_ENTRY( "$deletedEntry" );
263        
264        private Delete_DELETED_ENTRY( String identifier )
265        {
266            super( identifier );
267        }
268        
269        public static StoredProcedureParameter instance()
270        {
271            return instance;
272        }
273    }
274
275    
276    public static final class ModifyDN_ENTRY extends StoredProcedureParameter
277    {
278        private static ModifyDN_ENTRY instance = new ModifyDN_ENTRY( "$entry" );
279        
280        private ModifyDN_ENTRY( String identifier )
281        {
282            super( identifier );
283        }
284        
285        public static StoredProcedureParameter instance()
286        {
287            return instance;
288        }
289    }
290    
291    
292    public static final class ModifyDN_NEW_RDN extends StoredProcedureParameter
293    {
294        private static ModifyDN_NEW_RDN instance = new ModifyDN_NEW_RDN( "$newrdn" );
295        
296        private ModifyDN_NEW_RDN( String identifier )
297        {
298            super( identifier );
299        }
300        
301        public static StoredProcedureParameter instance()
302        {
303            return instance;
304        }
305    }
306    
307    
308    public static final class ModifyDN_DELETE_OLD_RDN extends StoredProcedureParameter
309    {
310        private static ModifyDN_DELETE_OLD_RDN instance = new ModifyDN_DELETE_OLD_RDN( "$deleteoldrdn" );
311        
312        private ModifyDN_DELETE_OLD_RDN( String identifier )
313        {
314            super( identifier );
315        }
316        
317        public static StoredProcedureParameter instance()
318        {
319            return instance;
320        }
321    }
322    
323    
324    public static final class ModifyDN_NEW_SUPERIOR extends StoredProcedureParameter
325    {
326        private static ModifyDN_NEW_SUPERIOR instance = new ModifyDN_NEW_SUPERIOR( "$newSuperior" );
327        
328        private ModifyDN_NEW_SUPERIOR( String identifier )
329        {
330            super( identifier );
331        }
332        
333        public static StoredProcedureParameter instance()
334        {
335            return instance;
336        }
337    }
338    
339    
340    public static final class ModifyDN_OLD_RDN extends StoredProcedureParameter
341    {
342        private static ModifyDN_OLD_RDN instance = new ModifyDN_OLD_RDN( "$oldRDN" );
343        
344        private ModifyDN_OLD_RDN( String identifier )
345        {
346            super( identifier );
347        }
348        
349        public static StoredProcedureParameter instance()
350        {
351            return instance;
352        }
353    }
354    
355    
356    public static final class ModifyDN_OLD_SUPERIOR_DN extends StoredProcedureParameter
357    {
358        private static ModifyDN_OLD_SUPERIOR_DN instance = new ModifyDN_OLD_SUPERIOR_DN( "$oldRDN" );
359        
360        private ModifyDN_OLD_SUPERIOR_DN( String identifier )
361        {
362            super( identifier );
363        }
364        
365        public static StoredProcedureParameter instance()
366        {
367            return instance;
368        }
369    }
370    
371    
372    public static final class ModifyDN_NEW_DN extends StoredProcedureParameter
373    {
374        private static ModifyDN_NEW_DN instance = new ModifyDN_NEW_DN( "$oldRDN" );
375        
376        private ModifyDN_NEW_DN( String identifier )
377        {
378            super( identifier );
379        }
380        
381        public static StoredProcedureParameter instance()
382        {
383            return instance;
384        }
385    }
386}