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     */
020    package org.apache.directory.shared.ldap.trigger;
021    
022    
023    import org.apache.directory.shared.ldap.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     * @version $Rev:$, $Date:$
032     */
033    public abstract class StoredProcedureParameter
034    {
035        public static class Generic_LDAP_CONTEXT extends StoredProcedureParameter
036        {
037            private DN ctxName;
038            
039            private Generic_LDAP_CONTEXT( DN ctxName )
040            {
041                super( "$ldapContext" );
042                this.ctxName = ctxName;
043            }
044            
045            public static StoredProcedureParameter instance( DN ctxName )
046            {
047                return new Generic_LDAP_CONTEXT( ctxName );
048            }
049            
050            public DN getCtxName()
051            {
052                return ctxName;
053            }
054            
055            public String toString()
056            {
057                return name + " \"" + ctxName.getName() + "\"";
058            }
059        }
060    
061        
062        public static class Generic_OPERATION_PRINCIPAL extends StoredProcedureParameter
063        {
064            private static Generic_OPERATION_PRINCIPAL instance = new Generic_OPERATION_PRINCIPAL( "$operationPrincipal" );
065            
066            private Generic_OPERATION_PRINCIPAL( String identifier )
067            {
068                super( identifier );
069            }
070            
071            public static StoredProcedureParameter instance()
072            {
073                return instance;
074            }
075        }
076    
077        
078        protected final String name;
079    
080    
081        protected StoredProcedureParameter( String name )
082        {
083            this.name = name;
084        }
085    
086    
087        /**
088         * Returns the name of this Stored Procedure Parameter.
089         */
090        public String getName()
091        {
092            return name;
093        }
094    
095    
096        public String toString()
097        {
098            return name;
099        }
100        
101    
102        /**
103         * @see java.lang.Object#hashCode()
104         * @return the instance's hash code 
105         */
106        public int hashCode()
107        {
108            int h = 37;
109            
110            h = h*17 + ( ( name == null ) ? 0 : name.hashCode() );
111            
112            return h;
113        }
114    
115    
116        /* (non-Javadoc)
117         * @see java.lang.Object#equals(java.lang.Object)
118         */
119        public boolean equals( Object obj )
120        {
121            if ( this == obj )
122                return true;
123            if ( obj == null )
124                return false;
125            if ( getClass() != obj.getClass() )
126                return false;
127            final StoredProcedureParameter other = ( StoredProcedureParameter ) obj;
128            if ( name == null )
129            {
130                if ( other.name != null )
131                    return false;
132            }
133            else if ( !name.equals( other.name ) )
134                return false;
135            return true;
136        }
137    
138        
139        public static class Modify_OBJECT extends StoredProcedureParameter
140        {
141            private static Modify_OBJECT instance = new Modify_OBJECT( "$object" );
142            
143            private Modify_OBJECT( String identifier )
144            {
145                super( identifier );
146            }
147            
148            public static StoredProcedureParameter instance()
149            {
150                return instance;
151            }
152        }
153        
154        
155        public static class Modify_MODIFICATION extends StoredProcedureParameter
156        {
157            private static Modify_MODIFICATION instance = new Modify_MODIFICATION( "$modification" );
158            
159            private Modify_MODIFICATION( String identifier )
160            {
161                super( identifier );
162            }
163            
164            public static StoredProcedureParameter instance()
165            {
166                return instance;
167            }
168        }
169        
170        
171        public static class Modify_OLD_ENTRY extends StoredProcedureParameter
172        {
173            private static Modify_OLD_ENTRY instance = new Modify_OLD_ENTRY( "$oldEntry" );
174            
175            private Modify_OLD_ENTRY( String identifier )
176            {
177                super( identifier );
178            }
179            
180            public static StoredProcedureParameter instance()
181            {
182                return instance;
183            }
184        }
185        
186        
187        public static class Modify_NEW_ENTRY extends StoredProcedureParameter
188        {
189            private static Modify_NEW_ENTRY instance = new Modify_NEW_ENTRY( "$newEntry" );
190            
191            private Modify_NEW_ENTRY( String identifier )
192            {
193                super( identifier );
194            }
195            
196            public static StoredProcedureParameter instance()
197            {
198                return instance;
199            }
200        }
201    
202        
203        public static class Add_ENTRY extends StoredProcedureParameter
204        {
205            private static Add_ENTRY instance = new Add_ENTRY( "$entry" );
206            
207            private Add_ENTRY( String identifier )
208            {
209                super( identifier );
210            }
211            
212            public static StoredProcedureParameter instance()
213            {
214                return instance;
215            }
216        }
217        
218        
219        public static class Add_ATTRIBUTES extends StoredProcedureParameter
220        {
221            private static Add_ATTRIBUTES instance = new Add_ATTRIBUTES( "$attributes" );
222            
223            private Add_ATTRIBUTES( String identifier )
224            {
225                super( identifier );
226            }
227            
228            public static StoredProcedureParameter instance()
229            {
230                return instance;
231            }
232        }
233    
234        
235        public static class Delete_NAME extends StoredProcedureParameter
236        {
237            private static Delete_NAME instance = new Delete_NAME( "$name" );
238            
239            private Delete_NAME( String identifier )
240            {
241                super( identifier );
242            }
243            
244            public static StoredProcedureParameter instance()
245            {
246                return instance;
247            }
248        }
249        
250        
251        public static class Delete_DELETED_ENTRY extends StoredProcedureParameter
252        {
253            private static Delete_DELETED_ENTRY instance = new Delete_DELETED_ENTRY( "$deletedEntry" );
254            
255            private Delete_DELETED_ENTRY( String identifier )
256            {
257                super( identifier );
258            }
259            
260            public static StoredProcedureParameter instance()
261            {
262                return instance;
263            }
264        }
265    
266        
267        public static class ModifyDN_ENTRY extends StoredProcedureParameter
268        {
269            private static ModifyDN_ENTRY instance = new ModifyDN_ENTRY( "$entry" );
270            
271            private ModifyDN_ENTRY( String identifier )
272            {
273                super( identifier );
274            }
275            
276            public static StoredProcedureParameter instance()
277            {
278                return instance;
279            }
280        }
281        
282        
283        public static class ModifyDN_NEW_RDN extends StoredProcedureParameter
284        {
285            private static ModifyDN_NEW_RDN instance = new ModifyDN_NEW_RDN( "$newrdn" );
286            
287            private ModifyDN_NEW_RDN( String identifier )
288            {
289                super( identifier );
290            }
291            
292            public static StoredProcedureParameter instance()
293            {
294                return instance;
295            }
296        }
297        
298        
299        public static class ModifyDN_DELETE_OLD_RDN extends StoredProcedureParameter
300        {
301            private static ModifyDN_DELETE_OLD_RDN instance = new ModifyDN_DELETE_OLD_RDN( "$deleteoldrdn" );
302            
303            private ModifyDN_DELETE_OLD_RDN( String identifier )
304            {
305                super( identifier );
306            }
307            
308            public static StoredProcedureParameter instance()
309            {
310                return instance;
311            }
312        }
313        
314        
315        public static class ModifyDN_NEW_SUPERIOR extends StoredProcedureParameter
316        {
317            private static ModifyDN_NEW_SUPERIOR instance = new ModifyDN_NEW_SUPERIOR( "$newSuperior" );
318            
319            private ModifyDN_NEW_SUPERIOR( String identifier )
320            {
321                super( identifier );
322            }
323            
324            public static StoredProcedureParameter instance()
325            {
326                return instance;
327            }
328        }
329        
330        
331        public static class ModifyDN_OLD_RDN extends StoredProcedureParameter
332        {
333            private static ModifyDN_OLD_RDN instance = new ModifyDN_OLD_RDN( "$oldRDN" );
334            
335            private ModifyDN_OLD_RDN( String identifier )
336            {
337                super( identifier );
338            }
339            
340            public static StoredProcedureParameter instance()
341            {
342                return instance;
343            }
344        }
345        
346        
347        public static class ModifyDN_OLD_SUPERIOR_DN extends StoredProcedureParameter
348        {
349            private static ModifyDN_OLD_SUPERIOR_DN instance = new ModifyDN_OLD_SUPERIOR_DN( "$oldRDN" );
350            
351            private ModifyDN_OLD_SUPERIOR_DN( String identifier )
352            {
353                super( identifier );
354            }
355            
356            public static StoredProcedureParameter instance()
357            {
358                return instance;
359            }
360        }
361        
362        
363        public static class ModifyDN_NEW_DN extends StoredProcedureParameter
364        {
365            private static ModifyDN_NEW_DN instance = new ModifyDN_NEW_DN( "$oldRDN" );
366            
367            private ModifyDN_NEW_DN( String identifier )
368            {
369                super( identifier );
370            }
371            
372            public static StoredProcedureParameter instance()
373            {
374                return instance;
375            }
376        }
377    }