View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17   
18  package org.apache.commons.beanutils.locale;
19  
20  
21  import org.apache.commons.beanutils.BeanUtils;
22  
23  import java.lang.reflect.InvocationTargetException;
24  import java.util.Locale;
25  
26  
27  
28  /***
29   * <p>Utility methods for populating JavaBeans properties
30   * via reflection in a locale-dependent manner.</p>
31   *
32   * <p>The implementations for these methods are provided by <code>LocaleBeanUtilsBean</code>.
33   * For more details see {@link LocaleBeanUtilsBean}.</p>
34   *
35   * @author Craig R. McClanahan
36   * @author Ralph Schaer
37   * @author Chris Audley
38   * @author Rey Francois
39   * @author Gregor Rayman
40   * @author Yauheny Mikulski
41   */
42  
43  public class LocaleBeanUtils extends BeanUtils {
44  
45  
46      // ----------------------------------------------------- Instance Variables
47  
48      /***
49       * <p>Gets the locale used when no locale is passed.</p>
50       *
51       * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
52       *
53       * @return the default locale
54       * @see LocaleBeanUtilsBean#getDefaultLocale()
55       */
56      public static Locale getDefaultLocale() {
57  
58          return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getDefaultLocale();
59      }
60  
61  
62      /***
63       * <p>Sets the locale used when no locale is passed.</p>
64       *
65       * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
66       *
67       * @param locale the default locale
68       * @see LocaleBeanUtilsBean#setDefaultLocale(Locale)
69       */
70      public static void setDefaultLocale(Locale locale) {
71  
72          LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().setDefaultLocale(locale);
73      }
74  
75      /***
76       * <p>Gets whether the pattern is localized or not.</p>
77       *
78       * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
79       *
80       * @return <code>true</code> if pattern is localized,
81       * otherwise <code>false</code>
82       * @see LocaleBeanUtilsBean#getApplyLocalized()
83       */
84      public static boolean getApplyLocalized() {
85  
86          return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getApplyLocalized();
87      }
88  
89      /***
90       * <p>Sets whether the pattern is localized or not.</p>
91       *
92       * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
93       *
94       * @param newApplyLocalized <code>true</code> if pattern is localized,
95       * otherwise <code>false</code>
96       * @see LocaleBeanUtilsBean#setApplyLocalized(boolean)
97       */
98      public static void setApplyLocalized(boolean newApplyLocalized) {
99  
100         LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().setApplyLocalized(newApplyLocalized);
101     }
102 
103 
104     // --------------------------------------------------------- Public Methods
105 
106     /***
107      * <p>Return the value of the specified locale-sensitive indexed property
108      * of the specified bean, as a String.</p>
109      *
110      * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
111      *
112      * @param bean Bean whose property is to be extracted
113      * @param name <code>propertyname[index]</code> of the property value
114      *  to be extracted
115      * @param pattern The conversion pattern
116      * @return The indexed property's value, converted to a String
117      *
118      * @exception IllegalAccessException if the caller does not have
119      *  access to the property accessor method
120      * @exception InvocationTargetException if the property accessor method
121      *  throws an exception
122      * @exception NoSuchMethodException if an accessor method for this
123      *  propety cannot be found
124      *
125      * @see LocaleBeanUtilsBean#getIndexedProperty(Object, String, String)
126      */
127     public static String getIndexedProperty(Object bean, String name, String pattern)
128             throws IllegalAccessException, InvocationTargetException,
129             NoSuchMethodException {
130 
131         return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getIndexedProperty(bean, name, pattern);
132     }
133 
134     /***
135      * Return the value of the specified locale-sensitive indexed property
136      * of the specified bean, as a String using the default conversion pattern of
137      * the corresponding {@link LocaleConverter}.
138      *
139      * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
140      *
141      * @param bean Bean whose property is to be extracted
142      * @param name <code>propertyname[index]</code> of the property value
143      *  to be extracted
144      * @return The indexed property's value, converted to a String
145      *
146      * @exception IllegalAccessException if the caller does not have
147      *  access to the property accessor method
148      * @exception InvocationTargetException if the property accessor method
149      *  throws an exception
150      * @exception NoSuchMethodException if an accessor method for this
151      *  propety cannot be found
152      *
153      * @see LocaleBeanUtilsBean#getIndexedProperty(Object, String)
154      */
155     public static String getIndexedProperty(Object bean, String name)
156             throws IllegalAccessException, InvocationTargetException,
157             NoSuchMethodException {
158 
159         return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getIndexedProperty(bean, name);
160     }
161 
162     /***
163      * <p>Return the value of the specified locale-sensetive indexed property
164      * of the specified bean, as a String using the specified conversion pattern.</p>
165      *
166      * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
167      *
168      * @param bean Bean whose property is to be extracted
169      * @param name Simple property name of the property value to be extracted
170      * @param index Index of the property value to be extracted
171      * @param pattern The conversion pattern
172      * @return The indexed property's value, converted to a String
173      *
174      * @exception IllegalAccessException if the caller does not have
175      *  access to the property accessor method
176      * @exception InvocationTargetException if the property accessor method
177      *  throws an exception
178      * @exception NoSuchMethodException if an accessor method for this
179      *  propety cannot be found
180      *
181      * @see LocaleBeanUtilsBean#getIndexedProperty(Object, String, int, String)
182      */
183     public static String getIndexedProperty(Object bean,
184                                             String name, int index, String pattern)
185             throws IllegalAccessException, InvocationTargetException,
186             NoSuchMethodException {
187 
188         return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getIndexedProperty(bean, name, index, pattern);
189     }
190 
191     /***
192      * <p>Return the value of the specified locale-sensetive indexed property
193      * of the specified bean, as a String using the default conversion pattern of
194      * the corresponding {@link LocaleConverter}.</p>
195      *
196      * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
197      *
198      * @param bean Bean whose property is to be extracted
199      * @param name Simple property name of the property value to be extracted
200      * @param index Index of the property value to be extracted
201      * @return The indexed property's value, converted to a String
202      *
203      * @exception IllegalAccessException if the caller does not have
204      *  access to the property accessor method
205      * @exception InvocationTargetException if the property accessor method
206      *  throws an exception
207      * @exception NoSuchMethodException if an accessor method for this
208      *  propety cannot be found
209      *
210      * @see LocaleBeanUtilsBean#getIndexedProperty(Object, String, int)
211      */
212     public static String getIndexedProperty(Object bean,
213                                             String name, int index)
214             throws IllegalAccessException, InvocationTargetException,
215             NoSuchMethodException {
216         return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getIndexedProperty(bean, name, index);
217     }
218 
219     /***
220      * <p>Return the value of the specified simple locale-sensitive property
221      * of the specified bean, converted to a String using the specified
222      * conversion pattern.</p>
223      *
224      * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
225      *
226      * @param bean Bean whose property is to be extracted
227      * @param name Name of the property to be extracted
228      * @param pattern The conversion pattern
229      * @return The property's value, converted to a String
230      *
231      * @exception IllegalAccessException if the caller does not have
232      *  access to the property accessor method
233      * @exception InvocationTargetException if the property accessor method
234      *  throws an exception
235      * @exception NoSuchMethodException if an accessor method for this
236      *  propety cannot be found
237      *
238      * @see LocaleBeanUtilsBean#getSimpleProperty(Object, String, String)
239      */
240     public static String getSimpleProperty(Object bean, String name, String pattern)
241             throws IllegalAccessException, InvocationTargetException,
242             NoSuchMethodException {
243 
244         return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getSimpleProperty(bean, name, pattern);
245     }
246 
247     /***
248      * <p>Return the value of the specified simple locale-sensitive property
249      * of the specified bean, converted to a String using the default
250      * conversion pattern of the corresponding {@link LocaleConverter}.</p>
251      *
252      * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
253      *
254      * @param bean Bean whose property is to be extracted
255      * @param name Name of the property to be extracted
256      * @return The property's value, converted to a String
257      *
258      * @exception IllegalAccessException if the caller does not have
259      *  access to the property accessor method
260      * @exception InvocationTargetException if the property accessor method
261      *  throws an exception
262      * @exception NoSuchMethodException if an accessor method for this
263      *  propety cannot be found
264      *
265      * @see LocaleBeanUtilsBean#getSimpleProperty(Object, String)
266      */
267     public static String getSimpleProperty(Object bean, String name)
268             throws IllegalAccessException, InvocationTargetException,
269             NoSuchMethodException {
270 
271         return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getSimpleProperty(bean, name);
272     }
273 
274     /***
275      * <p>Return the value of the specified mapped locale-sensitive property
276      * of the specified bean, as a String using the specified conversion pattern.</p>
277      *
278      * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
279      *
280      * @param bean Bean whose property is to be extracted
281      * @param name Simple property name of the property value to be extracted
282      * @param key Lookup key of the property value to be extracted
283      * @param pattern The conversion pattern
284      * @return The mapped property's value, converted to a String
285      *
286      * @exception IllegalAccessException if the caller does not have
287      *  access to the property accessor method
288      * @exception InvocationTargetException if the property accessor method
289      *  throws an exception
290      * @exception NoSuchMethodException if an accessor method for this
291      *  propety cannot be found
292      *
293      * @see LocaleBeanUtilsBean#getMappedProperty(Object, String, String, String)
294      */
295     public static String getMappedProperty(Object bean,
296                                            String name, String key, String pattern)
297             throws IllegalAccessException, InvocationTargetException,
298             NoSuchMethodException {
299 
300         return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getMappedProperty(bean, name, key, pattern);
301     }
302 
303     /***
304      * <p>Return the value of the specified mapped locale-sensitive property
305      * of the specified bean, as a String
306      * The key is specified as a method parameter and must *not* be included
307      * in the property name expression.</p>
308      *
309      * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
310      *
311      * @param bean Bean whose property is to be extracted
312      * @param name Simple property name of the property value to be extracted
313      * @param key Lookup key of the property value to be extracted
314      * @return The mapped property's value, converted to a String
315      *
316      * @exception IllegalAccessException if the caller does not have
317      *  access to the property accessor method
318      * @exception InvocationTargetException if the property accessor method
319      *  throws an exception
320      * @exception NoSuchMethodException if an accessor method for this
321      *  propety cannot be found
322      *
323      * @see LocaleBeanUtilsBean#getMappedProperty(Object, String, String)
324      */
325     public static String getMappedProperty(Object bean,
326                                            String name, String key)
327             throws IllegalAccessException, InvocationTargetException,
328             NoSuchMethodException {
329 
330         return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getMappedProperty(bean, name, key);
331     }
332 
333 
334     /***
335      * <p>Return the value of the specified locale-sensitive mapped property
336      * of the specified bean, as a String using the specified pattern.</p>
337      *
338      * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
339      *
340      * @param bean Bean whose property is to be extracted
341      * @param name <code>propertyname(index)</code> of the property value
342      *  to be extracted
343      * @param pattern The conversion pattern
344      * @return The mapped property's value, converted to a String
345      *
346      * @exception IllegalAccessException if the caller does not have
347      *  access to the property accessor method
348      * @exception InvocationTargetException if the property accessor method
349      *  throws an exception
350      * @exception NoSuchMethodException if an accessor method for this
351      *  propety cannot be found
352      *
353      * @see LocaleBeanUtilsBean#getMappedPropertyLocale(Object, String, String)
354      */
355     public static String getMappedPropertyLocale(Object bean, String name, String pattern)
356             throws IllegalAccessException, InvocationTargetException,
357             NoSuchMethodException {
358 
359         return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getMappedPropertyLocale(bean, name, pattern);
360     }
361 
362 
363     /***
364      * <p>Return the value of the specified locale-sensitive mapped property
365      * of the specified bean, as a String using the default
366      * conversion pattern of the corresponding {@link LocaleConverter}.</p>
367      *
368      * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
369      *
370      * @param bean Bean whose property is to be extracted
371      * @param name <code>propertyname(index)</code> of the property value
372      *  to be extracted
373      * @return The mapped property's value, converted to a String
374      *
375      * @exception IllegalAccessException if the caller does not have
376      *  access to the property accessor method
377      * @exception InvocationTargetException if the property accessor method
378      *  throws an exception
379      * @exception NoSuchMethodException if an accessor method for this
380      *  propety cannot be found
381      *
382      * @see LocaleBeanUtilsBean#getMappedProperty(Object, String)
383      */
384     public static String getMappedProperty(Object bean, String name)
385             throws IllegalAccessException, InvocationTargetException,
386             NoSuchMethodException {
387 
388         return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getMappedProperty(bean, name);
389     }
390 
391     /***
392      * <p>Return the value of the (possibly nested) locale-sensitive property
393      * of the specified name, for the specified bean,
394      * as a String using the specified pattern.</p>
395      *
396      * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
397      *
398      * @param bean Bean whose property is to be extracted
399      * @param name Possibly nested name of the property to be extracted
400      * @param pattern The conversion pattern
401      * @return The nested property's value, converted to a String
402      *
403      * @exception IllegalAccessException if the caller does not have
404      *  access to the property accessor method
405      * @exception InvocationTargetException if the property accessor method
406      *  throws an exception
407      * @exception NoSuchMethodException if an accessor method for this
408      *  propety cannot be found
409      *
410      * @see LocaleBeanUtilsBean#getNestedProperty(Object, String, String)
411      */
412     public static String getNestedProperty(Object bean, String name, String pattern)
413             throws IllegalAccessException, InvocationTargetException,
414             NoSuchMethodException {
415 
416         return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getNestedProperty(bean, name, pattern);
417     }
418 
419     /***
420      * <p>Return the value of the (possibly nested) locale-sensitive property
421      * of the specified name.</p>
422      *
423      * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
424      *
425      * @param bean Bean whose property is to be extracted
426      * @param name Possibly nested name of the property to be extracted
427      * @return The nested property's value, converted to a String
428      *
429      * @exception IllegalAccessException if the caller does not have
430      *  access to the property accessor method
431      * @exception InvocationTargetException if the property accessor method
432      *  throws an exception
433      * @exception NoSuchMethodException if an accessor method for this
434      *  propety cannot be found
435      *
436      * @see LocaleBeanUtilsBean#getNestedProperty(Object, String)
437      */
438     public static String getNestedProperty(Object bean, String name)
439             throws IllegalAccessException, InvocationTargetException,
440             NoSuchMethodException {
441 
442         return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getNestedProperty(bean, name);
443     }
444 
445     /***
446      * <p>Return the value of the specified locale-sensitive property
447      * of the specified bean.</p>
448      *
449      * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
450      *
451      * @param bean Bean whose property is to be extracted
452      * @param name Possibly indexed and/or nested name of the property
453      *  to be extracted
454      * @param pattern The conversion pattern
455      * @return The nested property's value, converted to a String
456      *
457      * @exception IllegalAccessException if the caller does not have
458      *  access to the property accessor method
459      * @exception InvocationTargetException if the property accessor method
460      *  throws an exception
461      * @exception NoSuchMethodException if an accessor method for this
462      *  propety cannot be found
463      *
464      * @see LocaleBeanUtilsBean#getProperty(Object, String, String)
465      */
466     public static String getProperty(Object bean, String name, String pattern)
467             throws IllegalAccessException, InvocationTargetException,
468             NoSuchMethodException {
469 
470         return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getProperty(bean, name, pattern);
471     }
472 
473     /***
474      * <p>Return the value of the specified locale-sensitive property
475      * of the specified bean.</p>
476      *
477      * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
478      *
479      * @param bean Bean whose property is to be extracted
480      * @param name Possibly indexed and/or nested name of the property
481      *  to be extracted
482      * @return The property's value, converted to a String
483      *
484      * @exception IllegalAccessException if the caller does not have
485      *  access to the property accessor method
486      * @exception InvocationTargetException if the property accessor method
487      *  throws an exception
488      * @exception NoSuchMethodException if an accessor method for this
489      *  propety cannot be found
490      *
491      * @see LocaleBeanUtilsBean#getProperty(Object, String)
492      */
493     public static String getProperty(Object bean, String name)
494             throws IllegalAccessException, InvocationTargetException,
495             NoSuchMethodException {
496 
497         return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getProperty(bean, name);
498     }
499 
500     /***
501      * <p>Set the specified locale-sensitive property value, performing type
502      * conversions as required to conform to the type of the destination property
503      * using the default conversion pattern of the corresponding {@link LocaleConverter}.</p>
504      *
505      * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
506      *
507      * @param bean Bean on which setting is to be performed
508      * @param name Property name (can be nested/indexed/mapped/combo)
509      * @param value Value to be set
510      *
511      * @exception IllegalAccessException if the caller does not have
512      *  access to the property accessor method
513      * @exception InvocationTargetException if the property accessor method
514      *  throws an exception
515      *
516      * @see LocaleBeanUtilsBean#setProperty(Object, String, Object)
517      */
518     public static void setProperty(Object bean, String name, Object value)
519             throws IllegalAccessException, InvocationTargetException {
520 
521         LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().setProperty(bean, name, value);
522     }
523 
524     /***
525      * <p>Set the specified locale-sensitive property value, performing type
526      * conversions as required to conform to the type of the destination
527      * property using the specified conversion pattern.</p>
528      *
529      * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
530      *
531      * @param bean Bean on which setting is to be performed
532      * @param name Property name (can be nested/indexed/mapped/combo)
533      * @param value Value to be set
534      * @param pattern The conversion pattern
535      *
536      * @exception IllegalAccessException if the caller does not have
537      *  access to the property accessor method
538      * @exception InvocationTargetException if the property accessor method
539      *  throws an exception
540      *
541      * @see LocaleBeanUtilsBean#setProperty(Object, String, Object, String)
542      */
543     public static void setProperty(Object bean, String name, Object value, String pattern)
544             throws IllegalAccessException, InvocationTargetException {
545 
546         LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().setProperty(bean, name, value, pattern);
547      }
548 
549     /***
550      * <p>Calculate the property type.</p>
551      *
552      * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
553      *
554      * @param target The bean
555      * @param name The property name
556      * @param propName The Simple name of target property
557      * @return The property's type
558      *
559      * @exception IllegalAccessException if the caller does not have
560      *  access to the property accessor method
561      * @exception InvocationTargetException if the property accessor method
562      *  throws an exception
563      *
564      * @see LocaleBeanUtilsBean#definePropertyType(Object, String, String)
565      */
566     protected static Class definePropertyType(Object target, String name, String propName)
567             throws IllegalAccessException, InvocationTargetException {
568 
569         return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().definePropertyType(target, name, propName);
570     }
571 
572     /***
573      * <p>Convert the specified value to the required type using the
574      * specified conversion pattern.</p>
575      *
576      * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
577      *
578      * @param type The Java type of target property
579      * @param index The indexed subscript value (if any)
580      * @param value The value to be converted
581      * @param pattern The conversion pattern
582      * @return The converted value
583      * @see LocaleBeanUtilsBean#convert(Class, int, Object, String)
584      */
585     protected static Object convert(Class type, int index, Object value, String pattern) {
586 
587         return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().convert(type, index, value, pattern);
588     }
589 
590     /***
591      * <p>Convert the specified value to the required type.</p>
592      *
593      * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
594      *
595      * @param type The Java type of target property
596      * @param index The indexed subscript value (if any)
597      * @param value The value to be converted
598      * @return The converted value
599      * @see LocaleBeanUtilsBean#convert(Class, int, Object)
600      */
601     protected static Object convert(Class type, int index, Object value) {
602 
603         return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().convert(type, index, value);
604     }
605 
606     /***
607      * <p>Invoke the setter method.</p>
608      *
609      * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
610      *
611      * @param target The bean
612      * @param propName The Simple name of target property
613      * @param key The Mapped key value (if any)
614      * @param index The indexed subscript value (if any)
615      * @param newValue The value to be set
616      *
617      * @exception IllegalAccessException if the caller does not have
618      *  access to the property accessor method
619      * @exception InvocationTargetException if the property accessor method
620      *  throws an exception
621      *
622      * @see LocaleBeanUtilsBean#invokeSetter(Object, String, String, int, Object)
623      */
624     protected static void invokeSetter(Object target, String propName, String key, int index, Object newValue)
625             throws IllegalAccessException, InvocationTargetException {
626 
627        LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().invokeSetter(target, propName, key, index, newValue);
628     }
629 
630     /***
631      * Resolve any nested expression to get the actual target bean.
632      *
633      * @deprecated moved into <code>LocaleBeanUtilsBean</code>
634      * @param bean The bean
635      * @param name The property name
636      * @return The property's descriptor
637      *
638      * @exception IllegalAccessException if the caller does not have
639      *  access to the property accessor method
640      * @exception InvocationTargetException if the property accessor method
641      *  throws an exception
642      */
643     protected static Descriptor calculate(Object bean, String name)
644             throws IllegalAccessException, InvocationTargetException {
645 
646         org.apache.commons.beanutils.locale.LocaleBeanUtilsBean.Descriptor descriptor
647             = LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().calculate(bean, name);
648         return new Descriptor(
649                 descriptor.getTarget(),
650                 descriptor.getName(),
651                 descriptor.getPropName(),
652                 descriptor.getKey(),
653                 descriptor.getIndex());
654     }
655 
656     /*** @deprecated moved into <code>LocaleBeanUtils</code> */
657     protected static class Descriptor {
658 
659         private int index = -1;    // Indexed subscript value (if any)
660         private String name;
661         private String propName;   // Simple name of target property
662         private String key;        // Mapped key value (if any)
663         private Object target;
664 
665         /***
666          * Construct a descriptor instance for the target bean and property.
667          *
668          * @param target The target bean
669          * @param name The property name (includes indexed/mapped expr)
670          * @param propName The property name
671          * @param key The mapped property key (if any)
672          * @param index The indexed property index (if any)
673          */
674         public Descriptor(Object target, String name, String propName, String key, int index) {
675 
676             setTarget(target);
677             setName(name);
678             setPropName(propName);
679             setKey(key);
680             setIndex(index);
681         }
682 
683         /***
684          * Return the target bean.
685          *
686          * @return The descriptors target bean
687          */
688         public Object getTarget() {
689             return target;
690         }
691 
692         /***
693          * Set the target bean.
694          *
695          * @param target The target bean
696          */
697         public void setTarget(Object target) {
698             this.target = target;
699         }
700 
701         /***
702          * Return the mapped property key.
703          *
704          * @return the mapped property key (if any)
705          */
706         public String getKey() {
707             return key;
708         }
709 
710         /***
711          * Set the mapped property key.
712          *
713          * @param key The mapped property key (if any)
714          */
715         public void setKey(String key) {
716             this.key = key;
717         }
718 
719         /***
720          * Return indexed property index.
721          *
722          * @return indexed property index (if any)
723          */
724         public int getIndex() {
725             return index;
726         }
727 
728         /***
729          * Set the indexed property index.
730          *
731          * @param index The indexed property index (if any)
732          */
733         public void setIndex(int index) {
734             this.index = index;
735         }
736 
737         /***
738          * Return property name (includes indexed/mapped expr).
739          *
740          * @return The property name (includes indexed/mapped expr)
741          */
742         public String getName() {
743             return name;
744         }
745 
746         /***
747          * Set the property name (includes indexed/mapped expr).
748          *
749          * @param name The property name (includes indexed/mapped expr)
750          */
751         public void setName(String name) {
752             this.name = name;
753         }
754 
755         /***
756          * Return the property name.
757          *
758          * @return The property name
759          */
760         public String getPropName() {
761             return propName;
762         }
763 
764         /***
765          * Set the property name.
766          *
767          * @param propName The property name
768          */
769         public void setPropName(String propName) {
770             this.propName = propName;
771         }
772     }
773 }
774 
775