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 *    https://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.api.ldap.trigger;
021
022
023import org.apache.directory.api.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    /**
035     * The generic LdapContext factory
036     */
037    public static final class Generic_LDAP_CONTEXT extends StoredProcedureParameter
038    {
039        private Dn ctxName;
040
041
042        private Generic_LDAP_CONTEXT( Dn ctxName )
043        {
044            super( "$ldapContext" );
045            this.ctxName = ctxName;
046        }
047
048
049        /**
050         * Creates a new instance of StoredProcedureParameter
051         * 
052         * @param ctxName The context name
053         * @return A new instance of StoredProcedureParameter
054         */
055        public static StoredProcedureParameter instance( Dn ctxName )
056        {
057            return new Generic_LDAP_CONTEXT( ctxName );
058        }
059
060
061        /**
062         * @return The context name
063         */
064        public Dn getCtxName()
065        {
066            return ctxName;
067        }
068
069
070        /**
071         * @see Object#toString()
072         */
073        @Override
074        public String toString()
075        {
076            return name + " \"" + ctxName.getName() + "\"";
077        }
078    }
079
080
081    /**
082     * The generic Operation Principal factory
083     */
084    public static final class Generic_OPERATION_PRINCIPAL extends StoredProcedureParameter
085    {
086        private static Generic_OPERATION_PRINCIPAL instance = new Generic_OPERATION_PRINCIPAL( "$operationPrincipal" );
087
088
089        private Generic_OPERATION_PRINCIPAL( String identifier )
090        {
091            super( identifier );
092        }
093
094
095        /**
096         * @return The generic Operation Principal instance
097         */
098        public static StoredProcedureParameter instance()
099        {
100            return instance;
101        }
102    }
103
104    protected final String name;
105
106
107    protected StoredProcedureParameter( String name )
108    {
109        this.name = name;
110    }
111
112
113    /**
114     * @return the name of this Stored Procedure Parameter.
115     */
116    public String getName()
117    {
118        return name;
119    }
120
121
122    /**
123     * {@inheritDoc}
124     */
125    @Override
126    public String toString()
127    {
128        return name;
129    }
130
131
132    /**
133     * @see java.lang.Object#hashCode()
134     * @return the instance's hash code 
135     */
136    @Override
137    public int hashCode()
138    {
139        int h = 37;
140
141        h = h * 17 + ( ( name == null ) ? 0 : name.hashCode() );
142
143        return h;
144    }
145
146
147    /**
148     * @see java.lang.Object#equals(java.lang.Object)
149     */
150    @Override
151    public boolean equals( Object obj )
152    {
153        if ( this == obj )
154        {
155            return true;
156        }
157
158        if ( obj == null )
159        {
160            return false;
161        }
162        
163        if ( getClass() != obj.getClass() )
164        {
165            return false;
166        }
167        
168        StoredProcedureParameter other = ( StoredProcedureParameter ) obj;
169        
170        if ( name == null )
171        {
172            if ( other.name != null )
173            {
174                return false;
175            }
176        }
177        else if ( !name.equals( other.name ) )
178        {
179            return false;
180        }
181        
182        return true;
183    }
184    
185
186    /**
187     * The Modify Object factory
188     */
189    public static final class Modify_OBJECT extends StoredProcedureParameter
190    {
191        private static Modify_OBJECT instance = new Modify_OBJECT( "$object" );
192
193
194        private Modify_OBJECT( String identifier )
195        {
196            super( identifier );
197        }
198
199
200        /**
201         * @return The Modify Object instance
202         */
203        public static StoredProcedureParameter instance()
204        {
205            return instance;
206        }
207    }
208
209
210    /**
211     * The Modify Modification factory
212     */
213    public static final class Modify_MODIFICATION extends StoredProcedureParameter
214    {
215        private static Modify_MODIFICATION instance = new Modify_MODIFICATION( "$modification" );
216
217
218        private Modify_MODIFICATION( String identifier )
219        {
220            super( identifier );
221        }
222
223
224        /**
225         * @return The Modify Modification instance
226         */
227        public static StoredProcedureParameter instance()
228        {
229            return instance;
230        }
231    }
232
233
234    /**
235     * The Modify Old Entry factory
236     */
237    public static final class Modify_OLD_ENTRY extends StoredProcedureParameter
238    {
239        private static Modify_OLD_ENTRY instance = new Modify_OLD_ENTRY( "$oldEntry" );
240
241
242        private Modify_OLD_ENTRY( String identifier )
243        {
244            super( identifier );
245        }
246
247
248        /**
249         * @return The Modify Old Entry instance
250         */
251        public static StoredProcedureParameter instance()
252        {
253            return instance;
254        }
255    }
256
257
258    /**
259     * The Modify New Entry factory
260     */
261    public static final class Modify_NEW_ENTRY extends StoredProcedureParameter
262    {
263        private static Modify_NEW_ENTRY instance = new Modify_NEW_ENTRY( "$newEntry" );
264
265
266        private Modify_NEW_ENTRY( String identifier )
267        {
268            super( identifier );
269        }
270
271
272        /**
273         * @return The Modify New Entry instance
274         */
275        public static StoredProcedureParameter instance()
276        {
277            return instance;
278        }
279    }
280
281
282    /**
283     * The Add Entry factory
284     */
285    public static final class Add_ENTRY extends StoredProcedureParameter
286    {
287        private static Add_ENTRY instance = new Add_ENTRY( "$entry" );
288
289
290        private Add_ENTRY( String identifier )
291        {
292            super( identifier );
293        }
294
295
296        /**
297         * @return The Add Entry instance
298         */
299        public static StoredProcedureParameter instance()
300        {
301            return instance;
302        }
303    }
304
305
306    /**
307     * The Add Attributes factory
308     */
309    public static final class Add_ATTRIBUTES extends StoredProcedureParameter
310    {
311        private static Add_ATTRIBUTES instance = new Add_ATTRIBUTES( "$attributes" );
312
313
314        private Add_ATTRIBUTES( String identifier )
315        {
316            super( identifier );
317        }
318
319
320        /**
321         * @return The Add Attributes instance
322         */
323        public static StoredProcedureParameter instance()
324        {
325            return instance;
326        }
327    }
328
329
330    /**
331     * The Delete Name factory
332     */
333    public static final class Delete_NAME extends StoredProcedureParameter
334    {
335        private static Delete_NAME instance = new Delete_NAME( "$name" );
336
337
338        private Delete_NAME( String identifier )
339        {
340            super( identifier );
341        }
342
343
344        /**
345         * @return The Delete Name instance
346         */
347        public static StoredProcedureParameter instance()
348        {
349            return instance;
350        }
351    }
352
353
354    /**
355     * The Delete Deleted  factory
356     */
357    public static final class Delete_DELETED_ENTRY extends StoredProcedureParameter
358    {
359        private static Delete_DELETED_ENTRY instance = new Delete_DELETED_ENTRY( "$deletedEntry" );
360
361
362        private Delete_DELETED_ENTRY( String identifier )
363        {
364            super( identifier );
365        }
366
367
368        /**
369         * @return The Delete Deleted instance
370         */
371        public static StoredProcedureParameter instance()
372        {
373            return instance;
374        }
375    }
376
377
378    /**
379     * The Modify DN Entry factory
380     */
381    public static final class ModifyDN_ENTRY extends StoredProcedureParameter
382    {
383        private static ModifyDN_ENTRY instance = new ModifyDN_ENTRY( "$entry" );
384
385
386        private ModifyDN_ENTRY( String identifier )
387        {
388            super( identifier );
389        }
390
391
392        /**
393         * @return The Modify DN Entry instance
394         */
395        public static StoredProcedureParameter instance()
396        {
397            return instance;
398        }
399    }
400
401
402    /**
403     * The Modify New Rdn factory
404     */
405    public static final class ModifyDN_NEW_RDN extends StoredProcedureParameter
406    {
407        private static ModifyDN_NEW_RDN instance = new ModifyDN_NEW_RDN( "$newrdn" );
408
409
410        private ModifyDN_NEW_RDN( String identifier )
411        {
412            super( identifier );
413        }
414
415
416        /**
417         * @return The Modify New Rdn instance
418         */
419        public static StoredProcedureParameter instance()
420        {
421            return instance;
422        }
423    }
424
425
426    /**
427     * The Modify DN Delete Old RDN factory
428     */
429    public static final class ModifyDN_DELETE_OLD_RDN extends StoredProcedureParameter
430    {
431        private static ModifyDN_DELETE_OLD_RDN instance = new ModifyDN_DELETE_OLD_RDN( "$deleteoldrdn" );
432
433
434        private ModifyDN_DELETE_OLD_RDN( String identifier )
435        {
436            super( identifier );
437        }
438
439
440        /**
441         * @return The Modify DN Delete Old RDN instance
442         */
443        public static StoredProcedureParameter instance()
444        {
445            return instance;
446        }
447    }
448
449
450    /**
451     * The Modify DN New Superior factory
452     */
453    public static final class ModifyDN_NEW_SUPERIOR extends StoredProcedureParameter
454    {
455        private static ModifyDN_NEW_SUPERIOR instance = new ModifyDN_NEW_SUPERIOR( "$newSuperior" );
456
457
458        private ModifyDN_NEW_SUPERIOR( String identifier )
459        {
460            super( identifier );
461        }
462
463
464        /**
465         * @return The Modify DN New Superior instance
466         */
467        public static StoredProcedureParameter instance()
468        {
469            return instance;
470        }
471    }
472
473
474    /**
475     * The Modify DN Old RDN factory
476     */
477    public static final class ModifyDN_OLD_RDN extends StoredProcedureParameter
478    {
479        private static ModifyDN_OLD_RDN instance = new ModifyDN_OLD_RDN( "$oldRDN" );
480
481
482        private ModifyDN_OLD_RDN( String identifier )
483        {
484            super( identifier );
485        }
486
487
488        /**
489         * @return The Modify DN Old RDN instance
490         */
491        public static StoredProcedureParameter instance()
492        {
493            return instance;
494        }
495    }
496
497
498    /**
499     * The Modify DN Old Superior DN factory
500     */
501    public static final class ModifyDN_OLD_SUPERIOR_DN extends StoredProcedureParameter
502    {
503        private static ModifyDN_OLD_SUPERIOR_DN instance = new ModifyDN_OLD_SUPERIOR_DN( "$oldRDN" );
504
505
506        private ModifyDN_OLD_SUPERIOR_DN( String identifier )
507        {
508            super( identifier );
509        }
510
511
512        /**
513         * @return The Modify DN Old Superior DN instance
514         */
515        public static StoredProcedureParameter instance()
516        {
517            return instance;
518        }
519    }
520
521
522    /**
523     * The Modify DN New DN factory
524     */
525    public static final class ModifyDN_NEW_DN extends StoredProcedureParameter
526    {
527        private static ModifyDN_NEW_DN instance = new ModifyDN_NEW_DN( "$oldRDN" );
528
529
530        private ModifyDN_NEW_DN( String identifier )
531        {
532            super( identifier );
533        }
534
535
536        /**
537         * @return The Modify DN New DN instance
538         */
539        public static StoredProcedureParameter instance()
540        {
541            return instance;
542        }
543    }
544}