View Javadoc

1   /*
2    * Copyright 2004-2005 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5    * use this file except in compliance with the License. You may obtain a copy of
6    * the License at
7    * 
8    * http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific Defaults.getLanguage() governing permissions and limitations under
14   * the License.
15   */
16  package net.sf.morph;
17  
18  import java.math.BigDecimal;
19  import java.math.BigInteger;
20  import java.util.Calendar;
21  import java.util.Date;
22  import java.util.Iterator;
23  import java.util.Locale;
24  
25  import net.sf.morph.lang.InvalidExpressionException;
26  import net.sf.morph.lang.LanguageException;
27  import net.sf.morph.lang.languages.SimpleLanguage;
28  import net.sf.morph.reflect.BeanReflector;
29  import net.sf.morph.reflect.ContainerReflector;
30  import net.sf.morph.reflect.DecoratedReflector;
31  import net.sf.morph.reflect.GrowableContainerReflector;
32  import net.sf.morph.reflect.IndexedContainerReflector;
33  import net.sf.morph.reflect.InstantiatingReflector;
34  import net.sf.morph.reflect.MutableIndexedContainerReflector;
35  import net.sf.morph.reflect.ReflectionException;
36  import net.sf.morph.reflect.Reflector;
37  import net.sf.morph.reflect.SizableReflector;
38  import net.sf.morph.transform.DecoratedConverter;
39  import net.sf.morph.transform.DecoratedCopier;
40  import net.sf.morph.transform.TransformationException;
41  import net.sf.morph.wrap.Bean;
42  import net.sf.morph.wrap.Container;
43  import net.sf.morph.wrap.GrowableContainer;
44  import net.sf.morph.wrap.IndexedContainer;
45  import net.sf.morph.wrap.MutableIndexedContainer;
46  import net.sf.morph.wrap.WrapperException;
47  
48  /**
49   * <p>
50   * A convenient static API for basic use of the Morph framework. This class does
51   * <em>not</em> provide any means for customizing/changing its behavior so
52   * that components can be guaranteed that calls to this static class will behave
53   * consistently regardless of the environment they are executed in. If you need
54   * customized behavior, use a
55   * {@link net.sf.morph.transform.transformers.SimpleDelegatingTransformer} or
56   * other customized Morph objects. This class is just a
57   * static facade for accessing those classes directly. They are particularly
58   * easy to configure using an Inversion of Control framework such as <a
59   * href="http://www.springframework.org">Spring</a>.
60   * 
61   * @author Matt Sgarlata
62   * @since Nov 28, 2004
63   * @see net.sf.morph.transform.copiers.DelegatingCopier
64   * @see net.sf.morph.transform.converters.DelegatingConverter
65   * @see net.sf.morph.lang.languages.SimpleLanguage
66   */
67  public abstract class Morph {
68  	
69  	private static final SizableReflector DEFAULT_SIZABLE_REFLECTOR = Defaults.createSizableReflector();
70  	private static final MutableIndexedContainerReflector DEFAULT_MUTABLE_INDEXED_CONTAINER_REFLECTOR = Defaults.createMutableIndexedContainerReflector();
71  	private static final InstantiatingReflector DEFAULT_INSTANTIATING_REFLECTOR = Defaults.createInstantiatingReflector();
72  	private static final IndexedContainerReflector DEFAULT_INDEXED_CONTAINER_REFLECTOR = Defaults.createIndexedContainerReflector();
73  	private static final GrowableContainerReflector DEFAULT_GROWABLE_CONTAINER_REFLECTOR = Defaults.createGrowableContainerReflector();
74  	private static final ContainerReflector DEFAULT_CONTAINER_REFLECTOR = Defaults.createContainerReflector();
75  	private static final BeanReflector DEFAULT_BEAN_REFLECTOR = Defaults.createBeanReflector();
76  	private static final DecoratedReflector DEFAULT_REFLECTOR = Defaults.createReflector();
77  	private static final DecoratedCopier DEFAULT_COPIER = Defaults.createCopier();
78  	private static final SimpleLanguage DEFAULT_LANGUAGE = Defaults.createLanguage();
79  	private static final DecoratedConverter DEFAULT_PRETTY_TEXT_CONVERTER = Defaults.createPrettyTextConverter();
80  	private static final DecoratedConverter DEFAULT_CONVERTER = Defaults.createConverter();
81  	
82  	/**
83  	 * This class cannot be instantiated.
84  	 */
85  	private Morph() { }
86  	
87  	/**
88  	 * Converts the given <code>source</code> into an object of class
89  	 * <code>destinationClass</code>. The returned object may be a reference
90  	 * to <code>source</code> itself. This isn't an issue for immutable
91  	 * classes (String, Long, etc) but is an issue for Collection and Array
92  	 * types.
93  	 * 
94  	 * @param destinationClass
95  	 *            the destination class to convert
96  	 * @param source
97  	 *            the source object to convert
98  	 * @return the result of the conversion
99  	 * @throws TransformationException
100 	 *             if <code>destinationClass</code> is <code>null</code>,
101 	 *             an error occurred while performing the conversion
102 	 */
103 	public static Object convert(Class destinationClass, Object source)
104 		throws TransformationException {
105 		return DEFAULT_CONVERTER.convert(destinationClass, source);
106 	}
107 	
108 	/**
109 	 * Converts the given <code>source</code> into an object of class
110 	 * <code>destinationClass</code>. The returned object may be a reference
111 	 * to <code>source</code> itself. This isn't an issue for immutable
112 	 * classes (String, Long, etc) but is an issue for Collection and Array
113 	 * types.
114 	 * 
115 	 * @param destinationClass
116 	 *            the destination class to convert
117 	 * @param source
118 	 *            the source object to convert
119 	 * @param locale
120 	 *            the locale in which the conversion should take place, or
121 	 *            <code>null</code> if the locale is not applicable
122 	 * @return the result of the conversion
123 	 * @throws TransformationException
124 	 *             if <code>destinationClass</code> is <code>null</code>,
125 	 *             an error occurred while performing the conversion
126 	 */
127 	public static Object convert(Class destinationClass, Object source, Locale locale)
128 		throws TransformationException {
129 		return DEFAULT_CONVERTER.convert(destinationClass, source, locale);
130 	}
131 	
132 	/**
133 	 * Converts the given <code>source</code> into a String that displays
134 	 * the information contained in the object in a format good for debugging.
135 	 * This is a great implementation of the <code>toString</code> method for
136 	 * an object.  FIXME actually, calling this method from the toString method
137 	 * of an object is likely to cause a StackOverflowException
138 	 * 
139 	 * @param source
140 	 *            the source object to convert
141 	 * @return the result of the conversion
142 	 * @throws TransformationException
143 	 *             if <code>destinationClass</code> is <code>null</code>,
144 	 *             an error occurred while performing the conversion
145 	 */
146 	public static String convertToPrettyString(Object source)
147 		throws TransformationException {
148 		return (String) DEFAULT_PRETTY_TEXT_CONVERTER.convert(String.class, source);
149 	}
150 	
151 	/**
152 	 * Converts the given <code>source</code> into a <code>BigDecimal</code>.
153 	 * 
154 	 * @param source
155 	 *            the source object to convert
156 	 * @return the result of the conversion
157 	 * @throws TransformationException
158 	 *             if <code>destinationClass</code> is <code>null</code>,
159 	 *             an error occurred while performing the conversion
160 	 */
161 	public static BigDecimal convertToBigDecimal(Object source) throws TransformationException {
162 		return (BigDecimal) convert(BigDecimal.class, source);
163 	}
164 	
165 	/**
166 	 * Converts the given <code>source</code> into a <code>BigDecimal</code>.
167 	 * 
168 	 * @param source
169 	 *            the source object to convert
170 	 * @param locale
171 	 *            the locale in which the conversion is to be performed
172 	 * @return the result of the conversion
173 	 * @throws TransformationException
174 	 *             if <code>destinationClass</code> is <code>null</code>,
175 	 *             an error occurred while performing the conversion
176 	 */
177 	public static BigDecimal convertToBigDecimal(Object source, Locale locale) throws TransformationException {
178 		return (BigDecimal) convert(BigDecimal.class, source, locale);
179 	}
180 	
181 	/**
182 	 * Converts the given <code>source</code> into a <code>BigInteger</code>.
183 	 * 
184 	 * @param source
185 	 *            the source object to convert
186 	 * @return the result of the conversion
187 	 * @throws TransformationException
188 	 *             if <code>destinationClass</code> is <code>null</code>,
189 	 *             an error occurred while performing the conversion
190 	 */
191 	public static BigInteger convertToBigInteger(Object source) throws TransformationException {
192 		return (BigInteger) convert(BigInteger.class, source);
193 	}
194 	
195 	/**
196 	 * Converts the given <code>source</code> into a <code>BigInteger</code>.
197 	 * 
198 	 * @param source
199 	 *            the source object to convert
200 	 * @param locale
201 	 *            the locale in which the conversion is to be performed
202 	 * @return the result of the conversion
203 	 * @throws TransformationException
204 	 *             if <code>destinationClass</code> is <code>null</code>,
205 	 *             an error occurred while performing the conversion
206 	 */
207 	public static BigInteger convertToBigInteger(Object source, Locale locale) throws TransformationException {
208 		return (BigInteger) convert(BigInteger.class, source, locale);
209 	}
210 	
211 	/**
212 	 * Converts the given <code>source</code> into a <code>boolean</code>.
213 	 * 
214 	 * @param source
215 	 *            the source object to convert
216 	 * @return the result of the conversion
217 	 * @throws TransformationException
218 	 *             if <code>destinationClass</code> is <code>null</code>,
219 	 *             an error occurred while performing the conversion
220 	 */
221 	public static boolean convertToBoolean(Object source) throws TransformationException {
222 		return ((Boolean) convert(boolean.class, source)).booleanValue();
223 	}
224 	
225 //	/**
226 //	 * Converts the given <code>source</code> into a <code>boolean</code>.
227 //	 * 
228 //	 * @param source
229 //	 *            the source object to convert
230 //	 * @param locale
231 //	 *            the locale in which the conversion is to be performed
232 //	 * @return the result of the conversion
233 //	 * @throws TransformationException
234 //	 *             if <code>destinationClass</code> is <code>null</code>,
235 //	 *             an error occurred while performing the conversion
236 //	 */
237 //	public static boolean convertToBoolean(Object source, Locale locale) throws TransformationException {
238 //		return ((Boolean) convert(boolean.class, source, locale)).booleanValue();
239 //	}
240 	
241 	/**
242 	 * Converts the given <code>source</code> into a <code>Boolean</code>.
243 	 * 
244 	 * @param source
245 	 *            the source object to convert
246 	 * @return the result of the conversion
247 	 * @throws TransformationException
248 	 *             if <code>destinationClass</code> is <code>null</code>,
249 	 *             an error occurred while performing the conversion
250 	 */
251 	public static Boolean convertToBooleanObject(Object source) throws TransformationException {
252 		return (Boolean) convert(Boolean.class, source);
253 	}
254 	
255 //	/**
256 //	 * Converts the given <code>source</code> into a <code>Boolean</code>.
257 //	 * 
258 //	 * @param source
259 //	 *            the source object to convert
260 //	 * @param locale
261 //	 *            the locale in which the conversion is to be performed
262 //	 * @return the result of the conversion
263 //	 * @throws TransformationException
264 //	 *             if <code>destinationClass</code> is <code>null</code>,
265 //	 *             an error occurred while performing the conversion
266 //	 */
267 //	public static Boolean convertToBooleanObject(Object source, Locale locale) throws TransformationException {
268 //		return (Boolean) convert(Boolean.class, source, locale);
269 //	}
270 	
271 	/**
272 	 * Converts the given <code>source</code> into a <code>byte</code>.
273 	 * 
274 	 * @param source
275 	 *            the source object to convert
276 	 * @return the result of the conversion
277 	 * @throws TransformationException
278 	 *             if <code>destinationClass</code> is <code>null</code>,
279 	 *             an error occurred while performing the conversion
280 	 */
281 	public static byte convertToByte(Object source) throws TransformationException {
282 		return ((Byte) convert(byte.class, source)).byteValue();
283 	}
284 	
285 	/**
286 	 * Converts the given <code>source</code> into a <code>byte</code>.
287 	 * 
288 	 * @param source
289 	 *            the source object to convert
290 	 * @param locale
291 	 *            the locale in which the conversion is to be performed
292 	 * @return the result of the conversion
293 	 * @throws TransformationException
294 	 *             if <code>destinationClass</code> is <code>null</code>,
295 	 *             an error occurred while performing the conversion
296 	 */
297 	public static byte convertToByte(Object source, Locale locale) throws TransformationException {
298 		return ((Byte) convert(byte.class, source, locale)).byteValue();
299 	}
300 	
301 	/**
302 	 * Converts the given <code>source</code> into a <code>Byte</code>.
303 	 * 
304 	 * @param source
305 	 *            the source object to convert
306 	 * @return the result of the conversion
307 	 * @throws TransformationException
308 	 *             if <code>destinationClass</code> is <code>null</code>,
309 	 *             an error occurred while performing the conversion
310 	 */
311 	public static Byte convertToByteObject(Object source) throws TransformationException {
312 		return (Byte) convert(Byte.class, source);
313 	}
314 	
315 	/**
316 	 * Converts the given <code>source</code> into a <code>Byte</code>.
317 	 * 
318 	 * @param source
319 	 *            the source object to convert
320 	 * @param locale
321 	 *            the locale in which the conversion is to be performed
322 	 * @return the result of the conversion
323 	 * @throws TransformationException
324 	 *             if <code>destinationClass</code> is <code>null</code>,
325 	 *             an error occurred while performing the conversion
326 	 */
327 	public static Byte convertToByteObject(Object source, Locale locale) throws TransformationException {
328 		return (Byte) convert(Byte.class, source, locale);
329 	}
330 	
331 	/**
332 	 * Converts the given <code>source</code> into a <code>Calendar</code>.
333 	 * 
334 	 * @param source
335 	 *            the source object to convert
336 	 * @return the result of the conversion
337 	 * @throws TransformationException
338 	 *             if <code>destinationClass</code> is <code>null</code>,
339 	 *             an error occurred while performing the conversion
340 	 */
341 	public static Calendar convertToCalendar(Object source) throws TransformationException {
342 		return (Calendar) convert(Calendar.class, source);
343 	}
344 	
345 	/**
346 	 * Converts the given <code>source</code> into a <code>Calendar</code>.
347 	 * 
348 	 * @param source
349 	 *            the source object to convert
350 	 * @param locale
351 	 *            the locale in which the conversion is to be performed
352 	 * @return the result of the conversion
353 	 * @throws TransformationException
354 	 *             if <code>destinationClass</code> is <code>null</code>,
355 	 *             an error occurred while performing the conversion
356 	 */
357 	public static Calendar convertToCalendar(Object source, Locale locale) throws TransformationException {
358 		return (Calendar) convert(Calendar.class, source, locale);
359 	}
360 	
361 	/**
362 	 * Converts the given <code>source</code> into a <code>Date</code>.
363 	 * 
364 	 * @param source
365 	 *            the source object to convert
366 	 * @return the result of the conversion
367 	 * @throws TransformationException
368 	 *             if <code>destinationClass</code> is <code>null</code>,
369 	 *             an error occurred while performing the conversion
370 	 */
371 	public static Date convertToDate(Object source) throws TransformationException {
372 		return (Date) convert(Date.class, source);
373 	}
374 	
375 	/**
376 	 * Converts the given <code>source</code> into a <code>Date</code>.
377 	 * 
378 	 * @param source
379 	 *            the source object to convert
380 	 * @param locale
381 	 *            the locale in which the conversion is to be performed
382 	 * @return the result of the conversion
383 	 * @throws TransformationException
384 	 *             if <code>destinationClass</code> is <code>null</code>,
385 	 *             an error occurred while performing the conversion
386 	 */
387 	public static Date convertToDate(Object source, Locale locale) throws TransformationException {
388 		return (Date) convert(Date.class, source, locale);
389 	}
390 	
391 	/**
392 	 * Converts the given <code>source</code> into a <code>double</code>.
393 	 * 
394 	 * @param source
395 	 *            the source object to convert
396 	 * @return the result of the conversion
397 	 * @throws TransformationException
398 	 *             if <code>destinationClass</code> is <code>null</code>,
399 	 *             an error occurred while performing the conversion
400 	 */
401 	public static double convertToDouble(Object source) throws TransformationException {
402 		return ((Double) convert(double.class, source)).doubleValue();
403 	}
404 	
405 	/**
406 	 * Converts the given <code>source</code> into a <code>double</code>.
407 	 * 
408 	 * @param source
409 	 *            the source object to convert
410 	 * @param locale
411 	 *            the locale in which the conversion is to be performed
412 	 * @return the result of the conversion
413 	 * @throws TransformationException
414 	 *             if <code>destinationClass</code> is <code>null</code>,
415 	 *             an error occurred while performing the conversion
416 	 */
417 	public static double convertToDouble(Object source, Locale locale) throws TransformationException {
418 		return ((Double) convert(double.class, source, locale)).doubleValue();
419 	}
420 	
421 	/**
422 	 * Converts the given <code>source</code> into a <code>Double</code>.
423 	 * 
424 	 * @param source
425 	 *            the source object to convert
426 	 * @return the result of the conversion
427 	 * @throws TransformationException
428 	 *             if <code>destinationClass</code> is <code>null</code>,
429 	 *             an error occurred while performing the conversion
430 	 */
431 	public static Double convertToDoubleObject(Object source) throws TransformationException {
432 		return (Double) convert(Double.class, source);
433 	}
434 	
435 	/**
436 	 * Converts the given <code>source</code> into a <code>Double</code>.
437 	 * 
438 	 * @param source
439 	 *            the source object to convert
440 	 * @param locale
441 	 *            the locale in which the conversion is to be performed
442 	 * @return the result of the conversion
443 	 * @throws TransformationException
444 	 *             if <code>destinationClass</code> is <code>null</code>,
445 	 *             an error occurred while performing the conversion
446 	 */
447 	public static Double convertToDoubleObject(Object source, Locale locale) throws TransformationException {
448 		return (Double) convert(Double.class, source, locale);
449 	}
450 	
451 	/**
452 	 * Converts the given <code>source</code> into a <code>float</code>.
453 	 * 
454 	 * @param source
455 	 *            the source object to convert
456 	 * @return the result of the conversion
457 	 * @throws TransformationException
458 	 *             if <code>destinationClass</code> is <code>null</code>,
459 	 *             an error occurred while performing the conversion
460 	 */
461 	public static float convertToFloat(Object source) throws TransformationException {
462 		return ((Float) convert(float.class, source)).floatValue();
463 	}
464 	
465 	/**
466 	 * Converts the given <code>source</code> into a <code>float</code>.
467 	 * 
468 	 * @param source
469 	 *            the source object to convert
470 	 * @param locale
471 	 *            the locale in which the conversion is to be performed
472 	 * @return the result of the conversion
473 	 * @throws TransformationException
474 	 *             if <code>destinationClass</code> is <code>null</code>,
475 	 *             an error occurred while performing the conversion
476 	 */
477 	public static float convertToFloat(Object source, Locale locale) throws TransformationException {
478 		return ((Float) convert(float.class, source, locale)).floatValue();
479 	}
480 	
481 	/**
482 	 * Converts the given <code>source</code> into a <code>Float</code>.
483 	 * 
484 	 * @param source
485 	 *            the source object to convert
486 	 * @return the result of the conversion
487 	 * @throws TransformationException
488 	 *             if <code>destinationClass</code> is <code>null</code>,
489 	 *             an error occurred while performing the conversion
490 	 */
491 	public static Float convertToFloatObject(Object source) throws TransformationException {
492 		return (Float) convert(Float.class, source);
493 	}
494 	
495 	/**
496 	 * Converts the given <code>source</code> into a <code>Float</code>.
497 	 * 
498 	 * @param source
499 	 *            the source object to convert
500 	 * @param locale
501 	 *            the locale in which the conversion is to be performed
502 	 * @return the result of the conversion
503 	 * @throws TransformationException
504 	 *             if <code>destinationClass</code> is <code>null</code>,
505 	 *             an error occurred while performing the conversion
506 	 */
507 	public static Float convertToFloatObject(Object source, Locale locale) throws TransformationException {
508 		return (Float) convert(Float.class, source, locale);
509 	}
510 	
511 	/**
512 	 * Converts the given <code>source</code> into a <code>int</code>.
513 	 * 
514 	 * @param source
515 	 *            the source object to convert
516 	 * @return the result of the conversion
517 	 * @throws TransformationException
518 	 *             if <code>destinationClass</code> is <code>null</code>,
519 	 *             an error occurred while performing the conversion
520 	 */
521 	public static int convertToInt(Object source) throws TransformationException {
522 		return ((Integer) convert(int.class, source)).intValue();
523 	}
524 	
525 	/**
526 	 * Converts the given <code>source</code> into a <code>int</code>.
527 	 * 
528 	 * @param source
529 	 *            the source object to convert
530 	 * @param locale
531 	 *            the locale in which the conversion is to be performed
532 	 * @return the result of the conversion
533 	 * @throws TransformationException
534 	 *             if <code>destinationClass</code> is <code>null</code>,
535 	 *             an error occurred while performing the conversion
536 	 */
537 	public static int convertToInt(Object source, Locale locale) throws TransformationException {
538 		return ((Integer) convert(int.class, source, locale)).intValue();
539 	}
540 	
541 	/**
542 	 * Converts the given <code>source</code> into a <code>Integer</code>.
543 	 * 
544 	 * @param source
545 	 *            the source object to convert
546 	 * @return the result of the conversion
547 	 * @throws TransformationException
548 	 *             if <code>destinationClass</code> is <code>null</code>,
549 	 *             an error occurred while performing the conversion
550 	 */
551 	public static Integer convertToIntegerObject(Object source) throws TransformationException {
552 		return (Integer) convert(Integer.class, source);
553 	}
554 	
555 	/**
556 	 * Converts the given <code>source</code> into a <code>Integer</code>.
557 	 * 
558 	 * @param source
559 	 *            the source object to convert
560 	 * @param locale
561 	 *            the locale in which the conversion is to be performed
562 	 * @return the result of the conversion
563 	 * @throws TransformationException
564 	 *             if <code>destinationClass</code> is <code>null</code>,
565 	 *             an error occurred while performing the conversion
566 	 */
567 	public static Integer convertToIntegerObject(Object source, Locale locale) throws TransformationException {
568 		return (Integer) convert(Integer.class, source, locale);
569 	}
570 	
571 	/**
572 	 * Converts the given <code>source</code> into a <code>long</code>.
573 	 * 
574 	 * @param source
575 	 *            the source object to convert
576 	 * @return the result of the conversion
577 	 * @throws TransformationException
578 	 *             if <code>destinationClass</code> is <code>null</code>,
579 	 *             an error occurred while performing the conversion
580 	 */
581 	public static long convertToLong(Object source) throws TransformationException {
582 		return ((Long) convert(long.class, source)).longValue();
583 	}
584 	
585 	/**
586 	 * Converts the given <code>source</code> into a <code>long</code>.
587 	 * 
588 	 * @param source
589 	 *            the source object to convert
590 	 * @param locale
591 	 *            the locale in which the conversion is to be performed
592 	 * @return the result of the conversion
593 	 * @throws TransformationException
594 	 *             if <code>destinationClass</code> is <code>null</code>,
595 	 *             an error occurred while performing the conversion
596 	 */
597 	public static long convertToLong(Object source, Locale locale) throws TransformationException {
598 		return ((Long) convert(long.class, source, locale)).longValue();
599 	}
600 	
601 	/**
602 	 * Converts the given <code>source</code> into a <code>Long</code>.
603 	 * 
604 	 * @param source
605 	 *            the source object to convert
606 	 * @return the result of the conversion
607 	 * @throws TransformationException
608 	 *             if <code>destinationClass</code> is <code>null</code>,
609 	 *             an error occurred while performing the conversion
610 	 */
611 	public static Long convertToLongObject(Object source) throws TransformationException {
612 		return (Long) convert(Long.class, source);
613 	}
614 	
615 	/**
616 	 * Converts the given <code>source</code> into a <code>Long</code>.
617 	 * 
618 	 * @param source
619 	 *            the source object to convert
620 	 * @param locale
621 	 *            the locale in which the conversion is to be performed
622 	 * @return the result of the conversion
623 	 * @throws TransformationException
624 	 *             if <code>destinationClass</code> is <code>null</code>,
625 	 *             an error occurred while performing the conversion
626 	 */
627 	public static Long convertToLongObject(Object source, Locale locale) throws TransformationException {
628 		return (Long) convert(Long.class, source, locale);
629 	}
630 	
631 	/**
632 	 * Converts the given <code>source</code> into a <code>String</code>.
633 	 * 
634 	 * @param source
635 	 *            the source object to convert
636 	 * @return the result of the conversion
637 	 * @throws TransformationException
638 	 *             if <code>destinationClass</code> is <code>null</code>,
639 	 *             an error occurred while performing the conversion
640 	 */
641 	public static String convertToString(Object source) throws TransformationException {
642 		return (String) convert(String.class, source);
643 	}
644 	
645 	/**
646 	 * Converts the given <code>source</code> into a <code>String</code>.
647 	 * 
648 	 * @param source
649 	 *            the source object to convert
650 	 * @param locale
651 	 *            the locale in which the conversion should take place
652 	 * @return the result of the conversion
653 	 * @throws TransformationException
654 	 *             if <code>destinationClass</code> is <code>null</code>,
655 	 *             an error occurred while performing the conversion
656 	 */
657 	public static String convertToString(Object source, Locale locale) throws TransformationException {
658 		return (String) convert(String.class, source, locale);
659 	}
660 	
661 	/**
662 	 * Retrieve the property indicated by <code>expression</code> from
663 	 * <code>target</code>.
664 	 * 
665 	 * @param target
666 	 *            the object from which information will be retrieved
667 	 * @param expression
668 	 *            an expression specifying which information to retrieve
669 	 * @return the information indicated by <code>expression</code> from
670 	 *         <code>target</code>
671 	 * @throws LanguageException
672 	 *             if <code>target</code> is <code>null</code> or <br>
673 	 *             an error occurrs while evaluating an otherwise valid
674 	 *             expression
675 	 * @throws InvalidExpressionException
676 	 *             if <code>expression</code> is empty or not a valid
677 	 *             expression
678 	 */
679 	public static Object get(Object target, String expression)
680 		throws LanguageException {
681 		return DEFAULT_LANGUAGE.get(target, expression);
682 	}
683 	
684 	/**
685 	 * Retrieve the information indicated by <code>expression</code> from
686 	 * <code>target</code> as the type indicated by
687 	 * <code>destinationClass</code>.
688 	 * 
689 	 * @param target
690 	 *            the object from which information will be retrieved
691 	 * @param expression
692 	 *            an expression specifying which information to retrieve
693 	 * @param destinationClass
694 	 *            indicates the type that should be returned by this method
695 	 * @return the information indicated by <code>expression</code> from
696 	 *         <code>target</code>
697 	 * @throws TransformationException
698 	 *             if an error occurs while converting the requested information
699 	 *             to the type indicated by <code>destinationClass</code>
700 	 * @throws LanguageException
701 	 *             if <code>target</code> is <code>null</code> or <br>
702 	 *             an error occurrs while evaluating an otherwise valid
703 	 *             expression
704 	 * @throws InvalidExpressionException
705 	 *             if <code>expression</code> is empty or not a valid
706 	 *             expression
707 	 */
708 	public static Object get(Object target, String expression, Class destinationClass)
709 		throws LanguageException, TransformationException {
710 		return DEFAULT_LANGUAGE.get(target, expression, destinationClass);
711 	}
712 	
713 	/**
714 	 * Retrieve the information indicated by <code>expression</code> from
715 	 * <code>target</code> as the type indicated by
716 	 * <code>destinationClass</code>.
717 	 * 
718 	 * @param target
719 	 *            the object from which information will be retrieved
720 	 * @param expression
721 	 *            an expression specifying which information to retrieve
722 	 * @param destinationClass
723 	 *            indicates the type that should be returned by this method
724 	 * @param locale
725 	 *            indicates the locale in which the conversion to type
726 	 *            <code>destinationClass</code> should be performed, if
727 	 *            applicable
728 	 * @return the information indicated by <code>expression</code> from
729 	 *         <code>target</code>
730 	 * @throws TransformationException
731 	 *             if an error occurs while converting the requested information
732 	 *             to the type indicated by <code>destinationClass</code>
733 	 * @throws LanguageException
734 	 *             if <code>target</code> is <code>null</code> or <br>
735 	 *             an error occurrs while evaluating an otherwise valid
736 	 *             expression
737 	 * @throws InvalidExpressionException
738 	 *             if <code>expression</code> is empty or not a valid
739 	 *             expression
740 	 */
741 	public static Object get(Object target, String expression, Class destinationClass,
742 		Locale locale) throws LanguageException, TransformationException {
743 		return DEFAULT_LANGUAGE.get(target, expression, destinationClass, locale);
744 	}
745 	
746 	/**
747 	 * Retrieve the information indicated by <code>expression</code> from
748 	 * <code>target</code> as the type indicated by
749 	 * <code>destinationClass</code>.
750 	 * 
751 	 * @param target
752 	 *            the object from which information will be retrieved
753 	 * @param expression
754 	 *            an expression specifying which information to retrieve
755 	 * @param locale
756 	 *            indicates the locale in which the conversion to type
757 	 *            <code>destinationClass</code> should be performed, if
758 	 *            applicable
759 	 * @param destinationClass
760 	 *            indicates the type that should be returned by this method
761 	 * @return the information indicated by <code>expression</code> from
762 	 *         <code>target</code>
763 	 * @throws TransformationException
764 	 *             if an error occurs while converting the requested information
765 	 *             to the type indicated by <code>destinationClass</code>
766 	 * @throws LanguageException
767 	 *             if <code>target</code> is <code>null</code> or <br>
768 	 *             an error occurrs while evaluating an otherwise valid
769 	 *             expression
770 	 * @throws InvalidExpressionException
771 	 *             if <code>expression</code> is empty or not a valid
772 	 *             expression
773 	 */
774 	public static Object get(Object target, String expression, Locale locale,
775 		Class destinationClass) throws LanguageException, TransformationException {
776 		return DEFAULT_LANGUAGE.get(target, expression, locale, destinationClass);
777 	}
778 	
779 	/**
780 	 * Sets the information indicated by <code>expression</code> on
781 	 * <code>target</code>.  <code>value</code> will be automatically
782 	 * converted to a type appropriate for the given <code>expression</code>.
783 	 * 
784 	 * @param target
785 	 *            the object that will be modified
786 	 * @param expression
787 	 *            an expression specifying which information will be modified
788 	 * @param value
789 	 *            the information to be changed
790 	 * @throws TransformationException
791 	 *             if an error occurs while converting <code>value</code> to
792 	 *             the appropriate type
793 	 * @throws LanguageException
794 	 *             if <code>target</code> is <code>null</code> or <br>
795 	 *             an error occurrs while evaluating an otherwise valid
796 	 *             expression
797 	 * @throws InvalidExpressionException
798 	 *             if <code>expression</code> is empty or not a valid
799 	 *             expression
800 	 */
801 	public static void set(Object target, String expression, Object value)
802 		throws LanguageException, TransformationException {
803 		DEFAULT_LANGUAGE.set(target, expression, value);
804 	}
805 	
806 	/**
807 	 * Sets the information indicated by <code>expression</code> on
808 	 * <code>target</code>.  <code>value</code> will be automatically
809 	 * converted to a type appropriate for the given <code>expression</code>.
810 	 * 
811 	 * @param target
812 	 *            the object that will be modified
813 	 * @param expression
814 	 *            an expression specifying which information will be modified
815 	 * @param value
816 	 *            the information to be changed
817 	 * @param locale
818 	 *            indicates the locale in which the conversion to type
819 	 *            <code>destinationClass</code> should be performed, if
820 	 *            applicable
821 	 * @throws TransformationException
822 	 *             if an error occurs while converting <code>value</code> to
823 	 *             the appropriate type
824 	 * @throws LanguageException
825 	 *             if <code>target</code> is <code>null</code> or <br>
826 	 *             an error occurrs while evaluating an otherwise valid
827 	 *             expression
828 	 * @throws InvalidExpressionException
829 	 *             if <code>expression</code> is empty or not a valid
830 	 *             expression
831 	 */
832 	public static void set(Object target, String expression, Object value,
833 		Locale locale) throws LanguageException, TransformationException {
834 		DEFAULT_LANGUAGE.set(target, expression, value, locale);
835 	}
836 	
837 	/**
838 	 * <p>
839 	 * Copies information from the given source to the given destination.
840 	 * </p>
841 	 * 
842 	 * @param destination
843 	 *            the object to which information is written
844 	 * @param source
845 	 *            the object from which information is read
846 	 * @throws TransformationException
847 	 *             if <code>source</code> or <code>destination</code> are
848 	 *             null
849 	 */
850 	
851 	public static void copy(Object destination, Object source) throws TransformationException {
852 		DEFAULT_COPIER.copy(destination, source);
853 	}
854 
855 	/**
856 	 * <p>
857 	 * Copies information from the given source to the given destination.
858 	 * </p>
859 	 * 
860 	 * @param destination
861 	 *            the object to which information is written
862 	 * @param source
863 	 *            the object from which information is read
864 	 * @param locale
865 	 *            the locale of the current user, which may be null if the
866 	 *            locale is unknown or not applicable
867 	 * @throws TransformationException
868 	 *             if <code>source</code> or <code>destination</code> are
869 	 *             null
870 	 */
871 	public static void copy(Object destination, Object source, Locale locale)
872 		throws TransformationException {
873 		DEFAULT_COPIER.copy(destination, source, locale);
874 	}
875 
876 	/**
877 	 * Returns the given object wrapped as a Bean.
878 	 * 
879 	 * @param object
880 	 *            the object to be wrapped
881 	 * @return the wrapped object
882 	 * @throws WrapperException
883 	 *             if the wrapper could not be retrieved
884 	 */
885 	public static Bean getBean(Object object) throws WrapperException {
886 		return (Bean) DEFAULT_REFLECTOR.getWrapper(object);
887 	}
888 	
889 	/**
890 	 * Returns the given object wrapped as a Container.
891 	 * 
892 	 * @param object
893 	 *            the object to be wrapped
894 	 * @return the wrapped object
895 	 * @throws WrapperException
896 	 *             if the wrapper could not be retrieved
897 	 */
898 	public static Container getContainer(Object object) throws WrapperException {
899 		return (Container) DEFAULT_REFLECTOR.getWrapper(object);
900 	}
901 	
902 	/**
903 	 * Returns the given object wrapped as a GrowableContainer.
904 	 * 
905 	 * @param object
906 	 *            the object to be wrapped
907 	 * @return the wrapped object
908 	 * @throws WrapperException
909 	 *             if the wrapper could not be retrieved
910 	 */
911 	public static GrowableContainer getGrowableContainer(Object object) throws WrapperException {
912 		return (GrowableContainer) DEFAULT_REFLECTOR.getWrapper(object);
913 	}
914 	
915 	/**
916 	 * Returns the given object wrapped as an IndexedContainer.
917 	 * 
918 	 * @param object
919 	 *            the object to be wrapped
920 	 * @return the wrapped object
921 	 * @throws WrapperException
922 	 *             if the wrapper could not be retrieved
923 	 */
924 	public static IndexedContainer getIndexedContainer(Object object) throws WrapperException {
925 		return (IndexedContainer) DEFAULT_REFLECTOR.getWrapper(object);
926 	}
927 	
928 	/**
929 	 * Returns the given object wrapped as a MutableIndexedContainer.
930 	 * 
931 	 * @param object
932 	 *            the object to be wrapped
933 	 * @return the wrapped object
934 	 * @throws WrapperException
935 	 *             if the wrapper could not be retrieved
936 	 */
937 	public static MutableIndexedContainer getMutableIndexedContainer(Object object) throws WrapperException {
938 		return (MutableIndexedContainer) DEFAULT_REFLECTOR.getWrapper(object);
939 	}
940 
941 	/**
942 	 * Retrieve the information indicated by <code>expression</code> from
943 	 * <code>target</code> as a <code>BigDecimal</code>.
944 	 * 
945 	 * @param target
946 	 *            the object from which information will be retrieved
947 	 * @param expression
948 	 *            an expression specifying which information to retrieve
949 	 * @return the information indicated by <code>expression</code> from
950 	 *         <code>target</code> as a <code>BigDecimal</code>
951 	 * @throws TransformationException
952 	 *             if an error occurs while converting the requested information
953 	 *             to a <code>BigDecimal</code>
954 	 * @throws LanguageException
955 	 *             if <code>target</code> is <code>null</code> or <br>
956 	 *             an error occurrs while evaluating an otherwise valid
957 	 *             expression
958 	 * @throws InvalidExpressionException
959 	 *             if <code>expression</code> is empty or not a valid
960 	 *             expression
961 	 */
962     public static BigDecimal getBigDecimal(Object target, String expression) {
963     	return (BigDecimal) Morph.get(target, expression, BigDecimal.class);
964     }
965 
966 	/**
967 	 * Retrieve the information indicated by <code>expression</code> from
968 	 * <code>target</code> as a <code>BigInteger</code>.
969 	 * 
970 	 * @param target
971 	 *            the object from which information will be retrieved
972 	 * @param expression
973 	 *            an expression specifying which information to retrieve
974 	 * @return the information indicated by <code>expression</code> from
975 	 *         <code>target</code> as a <code>BigInteger</code>
976 	 * @throws TransformationException
977 	 *             if an error occurs while converting the requested information
978 	 *             to a <code>BigInteger</code>
979 	 * @throws LanguageException
980 	 *             if <code>target</code> is <code>null</code> or <br>
981 	 *             an error occurrs while evaluating an otherwise valid
982 	 *             expression
983 	 * @throws InvalidExpressionException
984 	 *             if <code>expression</code> is empty or not a valid
985 	 *             expression
986 	 */
987     public static BigInteger getBigInteger(Object target, String expression) {
988     	return (BigInteger) Morph.get(target, expression, BigInteger.class);
989     }
990 
991 	/**
992 	 * Retrieve the information indicated by <code>expression</code> from
993 	 * <code>target</code> as a <code>boolean</code>.
994 	 * 
995 	 * @param target
996 	 *            the object from which information will be retrieved
997 	 * @param expression
998 	 *            an expression specifying which information to retrieve
999 	 * @return the information indicated by <code>expression</code> from
1000 	 *         <code>target</code> as a <code>boolean</code>
1001 	 * @throws TransformationException
1002 	 *             if an error occurs while converting the requested information
1003 	 *             to a <code>boolean</code>
1004 	 * @throws LanguageException
1005 	 *             if <code>target</code> is <code>null</code> or <br>
1006 	 *             an error occurrs while evaluating an otherwise valid
1007 	 *             expression
1008 	 * @throws InvalidExpressionException
1009 	 *             if <code>expression</code> is empty or not a valid
1010 	 *             expression
1011 	 */
1012     public static boolean getBoolean(Object target, String expression) {
1013     	return ((Boolean) Morph.get(target, expression, boolean.class)).booleanValue();
1014     }
1015 
1016 	/**
1017 	 * Retrieve the information indicated by <code>expression</code> from
1018 	 * <code>target</code> as a <code>Boolean</code> object.
1019 	 * 
1020 	 * @param target
1021 	 *            the object from which information will be retrieved
1022 	 * @param expression
1023 	 *            an expression specifying which information to retrieve
1024 	 * @return the information indicated by <code>expression</code> from
1025 	 *         <code>target</code> as a <code>Boolean</code> object
1026 	 * @throws TransformationException
1027 	 *             if an error occurs while converting the requested information
1028 	 *             to a <code>Boolean</code> object
1029 	 * @throws LanguageException
1030 	 *             if <code>target</code> is <code>null</code> or <br>
1031 	 *             an error occurrs while evaluating an otherwise valid
1032 	 *             expression
1033 	 * @throws InvalidExpressionException
1034 	 *             if <code>expression</code> is empty or not a valid
1035 	 *             expression
1036 	 */
1037     public static Boolean getBooleanObject(Object target, String expression) {
1038     	return (Boolean) Morph.get(target, expression, Boolean.class);
1039     }
1040 
1041 	/**
1042 	 * Sets the information indicated by <code>expression</code> on
1043 	 * <code>target</code>.  <code>value</code> will be automatically
1044 	 * converted to a type appropriate for the given <code>expression</code>.
1045 	 * 
1046 	 * @param target
1047 	 *            the object that will be modified
1048 	 * @param expression
1049 	 *            an expression specifying which information will be modified
1050 	 * @param value
1051 	 *            the information to be changed
1052 	 * @throws TransformationException
1053 	 *             if an error occurs while converting <code>value</code> to
1054 	 *             the appropriate type
1055 	 * @throws LanguageException
1056 	 *             if <code>target</code> is <code>null</code> or <br>
1057 	 *             an error occurrs while evaluating an otherwise valid
1058 	 *             expression
1059 	 * @throws InvalidExpressionException
1060 	 *             if <code>expression</code> is empty or not a valid
1061 	 *             expression
1062 	 */
1063     public static void set(Object target, String expression, boolean value) {
1064     	set(target, expression, new Boolean(value));
1065     }    
1066 
1067 	/**
1068 	 * Retrieve the information indicated by <code>expression</code> from
1069 	 * <code>target</code> as a <code>byte</code>.
1070 	 * 
1071 	 * @param target
1072 	 *            the object from which information will be retrieved
1073 	 * @param expression
1074 	 *            an expression specifying which information to retrieve
1075 	 * @return the information indicated by <code>expression</code> from
1076 	 *         <code>target</code> as a <code>byte</code>
1077 	 * @throws TransformationException
1078 	 *             if an error occurs while converting the requested information
1079 	 *             to a <code>byte</code>
1080 	 * @throws LanguageException
1081 	 *             if <code>target</code> is <code>null</code> or <br>
1082 	 *             an error occurrs while evaluating an otherwise valid
1083 	 *             expression
1084 	 * @throws InvalidExpressionException
1085 	 *             if <code>expression</code> is empty or not a valid
1086 	 *             expression
1087 	 */
1088     public static byte getByte(Object target, String expression) {
1089     	return ((Byte) Morph.get(target, expression, byte.class)).byteValue();
1090     }
1091 
1092 	/**
1093 	 * Retrieve the information indicated by <code>expression</code> from
1094 	 * <code>target</code> as a <code>Byte</code> object.
1095 	 * 
1096 	 * @param target
1097 	 *            the object from which information will be retrieved
1098 	 * @param expression
1099 	 *            an expression specifying which information to retrieve
1100 	 * @return the information indicated by <code>expression</code> from
1101 	 *         <code>target</code> as a <code>Byte</code> object
1102 	 * @throws TransformationException
1103 	 *             if an error occurs while converting the requested information
1104 	 *             to a <code>Byte</code> object
1105 	 * @throws LanguageException
1106 	 *             if <code>target</code> is <code>null</code> or <br>
1107 	 *             an error occurrs while evaluating an otherwise valid
1108 	 *             expression
1109 	 * @throws InvalidExpressionException
1110 	 *             if <code>expression</code> is empty or not a valid
1111 	 *             expression
1112 	 */
1113 	public static Byte getByteObject(Object target, String expression) {
1114     	return (Byte) Morph.get(target, expression, Byte.class);
1115     }
1116 
1117 	/**
1118 	 * Sets the information indicated by <code>expression</code> on
1119 	 * <code>target</code>.  <code>value</code> will be automatically
1120 	 * converted to a type appropriate for the given <code>expression</code>.
1121 	 * 
1122 	 * @param target
1123 	 *            the object that will be modified
1124 	 * @param expression
1125 	 *            an expression specifying which information will be modified
1126 	 * @param value
1127 	 *            the information to be changed
1128 	 * @throws TransformationException
1129 	 *             if an error occurs while converting <code>value</code> to
1130 	 *             the appropriate type
1131 	 * @throws LanguageException
1132 	 *             if <code>target</code> is <code>null</code> or <br>
1133 	 *             an error occurrs while evaluating an otherwise valid
1134 	 *             expression
1135 	 * @throws InvalidExpressionException
1136 	 *             if <code>expression</code> is empty or not a valid
1137 	 *             expression
1138 	 */
1139     public static void set(Object target, String expression, byte value) {
1140     	set(target, expression, new Byte(value));
1141     }
1142 
1143 	/**
1144 	 * Retrieve the information indicated by <code>expression</code> from
1145 	 * <code>target</code> as a <code>double</code>.
1146 	 * 
1147 	 * @param target
1148 	 *            the object from which information will be retrieved
1149 	 * @param expression
1150 	 *            an expression specifying which information to retrieve
1151 	 * @return the information indicated by <code>expression</code> from
1152 	 *         <code>target</code> as a <code>double</code>
1153 	 * @throws TransformationException
1154 	 *             if an error occurs while converting the requested information
1155 	 *             to a <code>double</code>
1156 	 * @throws LanguageException
1157 	 *             if <code>target</code> is <code>null</code> or <br>
1158 	 *             an error occurrs while evaluating an otherwise valid
1159 	 *             expression
1160 	 * @throws InvalidExpressionException
1161 	 *             if <code>expression</code> is empty or not a valid
1162 	 *             expression
1163 	 */
1164     public static double getDouble(Object target, String expression) {
1165     	return ((Double) Morph.get(target, expression, double.class)).doubleValue();
1166     }
1167 
1168 	/**
1169 	 * Retrieve the information indicated by <code>expression</code> from
1170 	 * <code>target</code> as a <code>Double</code> object.
1171 	 * 
1172 	 * @param target
1173 	 *            the object from which information will be retrieved
1174 	 * @param expression
1175 	 *            an expression specifying which information to retrieve
1176 	 * @return the information indicated by <code>expression</code> from
1177 	 *         <code>target</code> as a <code>Double</code> object
1178 	 * @throws TransformationException
1179 	 *             if an error occurs while converting the requested information
1180 	 *             to a <code>Double</code> object
1181 	 * @throws LanguageException
1182 	 *             if <code>target</code> is <code>null</code> or <br>
1183 	 *             an error occurrs while evaluating an otherwise valid
1184 	 *             expression
1185 	 * @throws InvalidExpressionException
1186 	 *             if <code>expression</code> is empty or not a valid
1187 	 *             expression
1188 	 */
1189     public static Double getDoubleObject(Object target, String expression) {
1190     	return (Double) Morph.get(target, expression, Double.class);
1191     }
1192 
1193 	/**
1194 	 * Sets the information indicated by <code>expression</code> on
1195 	 * <code>target</code>.  <code>value</code> will be automatically
1196 	 * converted to a type appropriate for the given <code>expression</code>.
1197 	 * 
1198 	 * @param target
1199 	 *            the object that will be modified
1200 	 * @param expression
1201 	 *            an expression specifying which information will be modified
1202 	 * @param value
1203 	 *            the information to be changed
1204 	 * @throws TransformationException
1205 	 *             if an error occurs while converting <code>value</code> to
1206 	 *             the appropriate type
1207 	 * @throws LanguageException
1208 	 *             if <code>target</code> is <code>null</code> or <br>
1209 	 *             an error occurrs while evaluating an otherwise valid
1210 	 *             expression
1211 	 * @throws InvalidExpressionException
1212 	 *             if <code>expression</code> is empty or not a valid
1213 	 *             expression
1214 	 */
1215     public static void set(Object target, String expression, double value) {
1216     	set(target, expression, new Double(value));
1217     }
1218 
1219 	/**
1220 	 * Retrieve the information indicated by <code>expression</code> from
1221 	 * <code>target</code> as a <code>float</code>.
1222 	 * 
1223 	 * @param target
1224 	 *            the object from which information will be retrieved
1225 	 * @param expression
1226 	 *            an expression specifying which information to retrieve
1227 	 * @return the information indicated by <code>expression</code> from
1228 	 *         <code>target</code> as a <code>float</code>
1229 	 * @throws TransformationException
1230 	 *             if an error occurs while converting the requested information
1231 	 *             to a <code>float</code>
1232 	 * @throws LanguageException
1233 	 *             if <code>target</code> is <code>null</code> or <br>
1234 	 *             an error occurrs while evaluating an otherwise valid
1235 	 *             expression
1236 	 * @throws InvalidExpressionException
1237 	 *             if <code>expression</code> is empty or not a valid
1238 	 *             expression
1239 	 */
1240     public static float getFloat(Object target, String expression) {
1241     	return ((Float) Morph.get(target, expression, float.class)).floatValue();
1242     }
1243 
1244 	/**
1245 	 * Retrieve the information indicated by <code>expression</code> from
1246 	 * <code>target</code> as a <code>Float</code> object.
1247 	 * 
1248 	 * @param target
1249 	 *            the object from which information will be retrieved
1250 	 * @param expression
1251 	 *            an expression specifying which information to retrieve
1252 	 * @return the information indicated by <code>expression</code> from
1253 	 *         <code>target</code> as a <code>Float</code> object
1254 	 * @throws TransformationException
1255 	 *             if an error occurs while converting the requested information
1256 	 *             to a <code>Float</code> object
1257 	 * @throws LanguageException
1258 	 *             if <code>target</code> is <code>null</code> or <br>
1259 	 *             an error occurrs while evaluating an otherwise valid
1260 	 *             expression
1261 	 * @throws InvalidExpressionException
1262 	 *             if <code>expression</code> is empty or not a valid
1263 	 *             expression
1264 	 */
1265     public static Float getFloatObject(Object target, String expression) {
1266     	return (Float) Morph.get(target, expression, Float.class);
1267     }
1268 
1269 	/**
1270 	 * Sets the information indicated by <code>expression</code> on
1271 	 * <code>target</code>.  <code>value</code> will be automatically
1272 	 * converted to a type appropriate for the given <code>expression</code>.
1273 	 * 
1274 	 * @param target
1275 	 *            the object that will be modified
1276 	 * @param expression
1277 	 *            an expression specifying which information will be modified
1278 	 * @param value
1279 	 *            the information to be changed
1280 	 * @throws TransformationException
1281 	 *             if an error occurs while converting <code>value</code> to
1282 	 *             the appropriate type
1283 	 * @throws LanguageException
1284 	 *             if <code>target</code> is <code>null</code> or <br>
1285 	 *             an error occurrs while evaluating an otherwise valid
1286 	 *             expression
1287 	 * @throws InvalidExpressionException
1288 	 *             if <code>expression</code> is empty or not a valid
1289 	 *             expression
1290 	 */
1291     public static void set(Object target, String expression, float value) {
1292     	set(target, expression, new Float(value));
1293     }
1294     
1295 	/**
1296 	 * Retrieve the information indicated by <code>expression</code> from
1297 	 * <code>target</code> as a <code>int</code>.
1298 	 * 
1299 	 * @param target
1300 	 *            the object from which information will be retrieved
1301 	 * @param expression
1302 	 *            an expression specifying which information to retrieve
1303 	 * @return the information indicated by <code>expression</code> from
1304 	 *         <code>target</code> as a <code>int</code>
1305 	 * @throws TransformationException
1306 	 *             if an error occurs while converting the requested information
1307 	 *             to a <code>int</code>
1308 	 * @throws LanguageException
1309 	 *             if <code>target</code> is <code>null</code> or <br>
1310 	 *             an error occurrs while evaluating an otherwise valid
1311 	 *             expression
1312 	 * @throws InvalidExpressionException
1313 	 *             if <code>expression</code> is empty or not a valid
1314 	 *             expression
1315 	 */
1316     public static int getInt(Object target, String expression) {
1317     	return ((Integer) Morph.get(target, expression, int.class)).intValue();
1318     }
1319 
1320 	/**
1321 	 * Retrieve the information indicated by <code>expression</code> from
1322 	 * <code>target</code> as a <code>Integer</code> object.
1323 	 * 
1324 	 * @param target
1325 	 *            the object from which information will be retrieved
1326 	 * @param expression
1327 	 *            an expression specifying which information to retrieve
1328 	 * @return the information indicated by <code>expression</code> from
1329 	 *         <code>target</code> as a <code>Integer</code> object
1330 	 * @throws TransformationException
1331 	 *             if an error occurs while converting the requested information
1332 	 *             to a <code>Integer</code> object
1333 	 * @throws LanguageException
1334 	 *             if <code>target</code> is <code>null</code> or <br>
1335 	 *             an error occurrs while evaluating an otherwise valid
1336 	 *             expression
1337 	 * @throws InvalidExpressionException
1338 	 *             if <code>expression</code> is empty or not a valid
1339 	 *             expression
1340 	 */
1341     public static Integer getIntegerObject(Object target, String expression) {
1342     	return (Integer) Morph.get(target, expression, Integer.class);
1343     }
1344 
1345 	/**
1346 	 * Sets the information indicated by <code>expression</code> on
1347 	 * <code>target</code>.  <code>value</code> will be automatically
1348 	 * converted to a type appropriate for the given <code>expression</code>.
1349 	 * 
1350 	 * @param target
1351 	 *            the object that will be modified
1352 	 * @param expression
1353 	 *            an expression specifying which information will be modified
1354 	 * @param value
1355 	 *            the information to be changed
1356 	 * @throws TransformationException
1357 	 *             if an error occurs while converting <code>value</code> to
1358 	 *             the appropriate type
1359 	 * @throws LanguageException
1360 	 *             if <code>target</code> is <code>null</code> or <br>
1361 	 *             an error occurrs while evaluating an otherwise valid
1362 	 *             expression
1363 	 * @throws InvalidExpressionException
1364 	 *             if <code>expression</code> is empty or not a valid
1365 	 *             expression
1366 	 */
1367     public static void set(Object target, String expression, int value) {
1368     	set(target, expression, new Integer(value));
1369     }
1370 
1371 	/**
1372 	 * Retrieve the information indicated by <code>expression</code> from
1373 	 * <code>target</code> as a <code>long</code>.
1374 	 * 
1375 	 * @param target
1376 	 *            the object from which information will be retrieved
1377 	 * @param expression
1378 	 *            an expression specifying which information to retrieve
1379 	 * @return the information indicated by <code>expression</code> from
1380 	 *         <code>target</code> as a <code>long</code>
1381 	 * @throws TransformationException
1382 	 *             if an error occurs while converting the requested information
1383 	 *             to a <code>long</code>
1384 	 * @throws LanguageException
1385 	 *             if <code>target</code> is <code>null</code> or <br>
1386 	 *             an error occurrs while evaluating an otherwise valid
1387 	 *             expression
1388 	 * @throws InvalidExpressionException
1389 	 *             if <code>expression</code> is empty or not a valid
1390 	 *             expression
1391 	 */
1392     public static long getLong(Object target, String expression) {
1393     	return ((Long) Morph.get(target, expression, long.class)).longValue();
1394     }
1395 
1396 	/**
1397 	 * Retrieve the information indicated by <code>expression</code> from
1398 	 * <code>target</code> as a <code>Long</code> object.
1399 	 * 
1400 	 * @param target
1401 	 *            the object from which information will be retrieved
1402 	 * @param expression
1403 	 *            an expression specifying which information to retrieve
1404 	 * @return the information indicated by <code>expression</code> from
1405 	 *         <code>target</code> as a <code>Long</code> object
1406 	 * @throws TransformationException
1407 	 *             if an error occurs while converting the requested information
1408 	 *             to a <code>Long</code> object
1409 	 * @throws LanguageException
1410 	 *             if <code>target</code> is <code>null</code> or <br>
1411 	 *             an error occurrs while evaluating an otherwise valid
1412 	 *             expression
1413 	 * @throws InvalidExpressionException
1414 	 *             if <code>expression</code> is empty or not a valid
1415 	 *             expression
1416 	 */
1417     public static Long getLongObject(Object target, String expression) {
1418     	return (Long) Morph.get(target, expression, Long.class);
1419     }
1420 
1421 	/**
1422 	 * Sets the information indicated by <code>expression</code> on
1423 	 * <code>target</code>.  <code>value</code> will be automatically
1424 	 * converted to a type appropriate for the given <code>expression</code>.
1425 	 * 
1426 	 * @param target
1427 	 *            the object that will be modified
1428 	 * @param expression
1429 	 *            an expression specifying which information will be modified
1430 	 * @param value
1431 	 *            the information to be changed
1432 	 * @throws TransformationException
1433 	 *             if an error occurs while converting <code>value</code> to
1434 	 *             the appropriate type
1435 	 * @throws LanguageException
1436 	 *             if <code>target</code> is <code>null</code> or <br>
1437 	 *             an error occurrs while evaluating an otherwise valid
1438 	 *             expression
1439 	 * @throws InvalidExpressionException
1440 	 *             if <code>expression</code> is empty or not a valid
1441 	 *             expression
1442 	 */
1443     public static void set(Object target, String expression, long value) {
1444     	set(target, expression, new Long(value));
1445     }
1446     
1447 	/**
1448 	 * Retrieve the information indicated by <code>expression</code> from
1449 	 * <code>target</code> as a <code>Date</code>.
1450 	 * 
1451 	 * @param target
1452 	 *            the object from which information will be retrieved
1453 	 * @param expression
1454 	 *            an expression specifying which information to retrieve
1455 	 * @return the information indicated by <code>expression</code> from
1456 	 *         <code>target</code> as a <code>Date</code>
1457 	 * @throws TransformationException
1458 	 *             if an error occurs while converting the requested information
1459 	 *             to a <code>Date</code>
1460 	 * @throws LanguageException
1461 	 *             if <code>target</code> is <code>null</code> or <br>
1462 	 *             an error occurrs while evaluating an otherwise valid
1463 	 *             expression
1464 	 * @throws InvalidExpressionException
1465 	 *             if <code>expression</code> is empty or not a valid
1466 	 *             expression
1467 	 */
1468     public static Date getDate(Object target, String expression) {
1469     	return (Date) Morph.get(target, expression, Date.class);
1470     }
1471 
1472 	/**
1473 	 * Retrieve the information indicated by <code>expression</code> from
1474 	 * <code>target</code> as a <code>String</code>.
1475 	 * 
1476 	 * @param target
1477 	 *            the object from which information will be retrieved
1478 	 * @param expression
1479 	 *            an expression specifying which information to retrieve
1480 	 * @return the information indicated by <code>expression</code> from
1481 	 *         <code>target</code> as a <code>String</code>
1482 	 * @throws TransformationException
1483 	 *             if an error occurs while converting the requested information
1484 	 *             to a <code>String</code>
1485 	 * @throws LanguageException
1486 	 *             if <code>target</code> is <code>null</code> or <br>
1487 	 *             an error occurrs while evaluating an otherwise valid
1488 	 *             expression
1489 	 * @throws InvalidExpressionException
1490 	 *             if <code>expression</code> is empty or not a valid
1491 	 *             expression
1492 	 */
1493     public static String getString(Object target, String expression) {
1494     	return (String) Morph.get(target, expression, String.class);
1495     }
1496 
1497 	/**
1498 	 * Retrieve the information indicated by <code>expression</code> from
1499 	 * <code>target</code> as a <code>String</code>.
1500 	 * 
1501 	 * @param target
1502 	 *            the object from which information will be retrieved
1503 	 * @param expression
1504 	 *            an expression specifying which information to retrieve
1505 	 * @param locale
1506 	 *            the locale in which the conversion should take place, or
1507 	 *            <code>null</code> if the locale is not applicable
1508 	 * @return the information indicated by <code>expression</code> from
1509 	 *         <code>target</code> as a <code>String</code>
1510 	 * @throws TransformationException
1511 	 *             if an error occurs while converting the requested information
1512 	 *             to a <code>String</code>
1513 	 * @throws LanguageException
1514 	 *             if <code>target</code> is <code>null</code> or <br>
1515 	 *             an error occurrs while evaluating an otherwise valid
1516 	 *             expression
1517 	 * @throws InvalidExpressionException
1518 	 *             if <code>expression</code> is empty or not a valid
1519 	 *             expression
1520 	 */
1521 	public static String getString(Object target, String expression, Locale locale) {
1522     	return (String) Morph.get(target, expression, String.class, locale);
1523     }
1524 
1525 	/**
1526 	 * Retrieve the information indicated by <code>expression</code> from
1527 	 * <code>target</code> as a <code>Calendar</code>.
1528 	 * 
1529 	 * @param target
1530 	 *            the object from which information will be retrieved
1531 	 * @param expression
1532 	 *            an expression specifying which information to retrieve
1533 	 * @return the information indicated by <code>expression</code> from
1534 	 *         <code>target</code> as a <code>Calendar</code>
1535 	 * @throws TransformationException
1536 	 *             if an error occurs while converting the requested information
1537 	 *             to a <code>Calendar</code>
1538 	 * @throws LanguageException
1539 	 *             if <code>target</code> is <code>null</code> or <br>
1540 	 *             an error occurrs while evaluating an otherwise valid
1541 	 *             expression
1542 	 * @throws InvalidExpressionException
1543 	 *             if <code>expression</code> is empty or not a valid
1544 	 *             expression
1545 	 */
1546     public static Calendar getCalendar(Object target, String expression) {
1547     	return (Calendar) Morph.get(target, expression, Calendar.class);
1548     }
1549     
1550     /**
1551 	 * Gets the names of the properties which are currently defined for the
1552 	 * given bean. Note that some beans (e.g. - Maps) allow the creation of new
1553 	 * properties, which means isWriteable may return true for property names
1554 	 * that are not included in the return value of this method.
1555 	 * 
1556 	 * @param bean
1557 	 *            the bean for which we would like a list of properties
1558 	 * @return the names of the properties which are currently defined for the
1559 	 *         given bean. Note that some beans (e.g. - Maps) allow the creation
1560 	 *         of new properties, which means isWriteable may return true for
1561 	 *         property names that are not included in the return value of this
1562 	 *         method.
1563 	 * @throws ReflectionException
1564 	 *             if bean is <code>null</code>
1565 	 */
1566 	public static String[] getPropertyNames(Object bean) throws ReflectionException {
1567 		return DEFAULT_BEAN_REFLECTOR.getPropertyNames(bean);
1568 	}
1569 
1570 	/**
1571 	 * Specifies the least restrictive type that may be assigned to the given
1572 	 * property. In the case of a weakly typed bean, the correct value to return
1573 	 * is simply <code>Object.class</code>, which indicates that any type can
1574 	 * be assigned to the given property.
1575 	 * 
1576 	 * @param bean
1577 	 *            the bean
1578 	 * @param propertyName
1579 	 *            the name of the property
1580 	 * @return the least restrictive type that may be assigned to the given
1581 	 *         property. In the case of a weakly typed bean, the correct value
1582 	 *         to return is simply <code>Object.class</code>, which indicates
1583 	 *         that any type can be assigned to the given property
1584 	 * @throws ReflectionException
1585 	 *             if <code>bean</code> or <code>propertyName</code> are
1586 	 *             <code>null</code> or <br>
1587 	 *             if the type could not be retrieved for some reason
1588 	 */
1589 	public static Class getType(Object bean, String propertyName)
1590 		throws ReflectionException {
1591 		return DEFAULT_BEAN_REFLECTOR.getType(bean, propertyName);
1592 	}
1593 
1594 	/**
1595 	 * Specifies the least restrictive type that may be assigned to the given
1596 	 * property. In the case of a weakly typed bean, the correct value to return
1597 	 * is simply <code>Object.class</code>, which indicates that any type can
1598 	 * be assigned to the given property.
1599 	 * 
1600 	 * @param beanType
1601 	 *            the type of the bean
1602 	 * @param propertyName
1603 	 *            the name of the property
1604 	 * @return the least restrictive type that may be assigned to the given
1605 	 *         property. In the case of a weakly typed bean, the correct value
1606 	 *         to return is simply <code>Object.class</code>, which indicates
1607 	 *         that any type can be assigned to the given property
1608 	 * @throws ReflectionException
1609 	 *             if <code>beanType</code> or <code>propertyName</code> are
1610 	 *             <code>null</code> or <br>
1611 	 *             if the type could not be retrieved for some reason
1612 	 */
1613 	public static Class getType(Class beanType, String propertyName)
1614 		throws ReflectionException {
1615 		Object bean = DEFAULT_INSTANTIATING_REFLECTOR.newInstance(beanType, null);
1616 		return DEFAULT_BEAN_REFLECTOR.getType(bean, propertyName);
1617 	}
1618 
1619 	/**
1620 	 * Specifies whether the given property is readable. A reflector can always
1621 	 * determine if a property is readable by attempting to read the property
1622 	 * value, so this method can be counted on to truly indicate whether or not
1623 	 * the given property is readable.
1624 	 * 
1625 	 * @param bean
1626 	 *            the bean
1627 	 * @param propertyName
1628 	 *            the name of the property
1629 	 * @return <code>true</code> if the property is readable, or <br>
1630 	 *         <code>false</code>, otherwise
1631 	 * @throws ReflectionException
1632 	 *             if <code>bean</code> or <code>propertyName</code> are
1633 	 *             <code>null</code> or <br>
1634 	 *             if the readability of the property cannot be determined
1635 	 */
1636 	public static boolean isReadable(Object bean, String propertyName)
1637 		throws ReflectionException {
1638 		return DEFAULT_BEAN_REFLECTOR.isReadable(bean, propertyName);
1639 	}
1640 
1641 	/**
1642 	 * Specifies whether the given property is writeable. If the reflector
1643 	 * cannot determine whether the given property is writeable, it may simply
1644 	 * return <code>true</code>. This method only guarantees that if
1645 	 * <code>isWriteable</code> returns false, the method is not writeable.
1646 	 * The method may or may not be writeable if this method returns
1647 	 * <code>true</code>.
1648 	 * 
1649 	 * @param bean
1650 	 *            the bean
1651 	 * @param propertyName
1652 	 *            the name of the property
1653 	 * @return <code>false</code> if the property is not writeable or <br>
1654 	 *         <code>true</code> if the property is writeable or if this
1655 	 *         reflector cannot determine for sure whether or not the property
1656 	 *         is writeable
1657 	 * @throws ReflectionException
1658 	 *             if <code>bean</code> or <code>propertyName</code> are
1659 	 *             <code>null</code> or <br>
1660 	 *             if the writeability of the property cannot be determined
1661 	 */
1662 	public static boolean isWriteable(Object bean, String propertyName)
1663 		throws ReflectionException {
1664 		return DEFAULT_BEAN_REFLECTOR.isWriteable(bean, propertyName);
1665 	}
1666 
1667 	/**
1668 	 * Returns the type of the elements that are contained in objects of the
1669 	 * given class. For example, if <code>indexedClass</code> represents an
1670 	 * array of <code>int</code>s,<code>Integer.TYPE</code> should be
1671 	 * returned. This method should only be called if
1672 	 * {@link Reflector#isReflectable(Class)}returns <code>true</code>.
1673 	 * 
1674 	 * @param clazz
1675 	 *            the container's type
1676 	 * @return the type of the elements that are container by the given object
1677 	 * @throws ReflectionException
1678 	 *             if <code>container</code> is null or <br>
1679 	 *             the type of the elements that are container could not be
1680 	 *             determined
1681 	 */
1682 	public static Class getContainedType(Class clazz) throws ReflectionException {
1683 		return DEFAULT_CONTAINER_REFLECTOR.getContainedType(clazz);
1684 	}
1685 
1686 	/**
1687 	 * Exposes an iterator over the contents of the container. Note that in many
1688 	 * cases, an Iterator may only be used once and is then considered invalid.
1689 	 * If you need to loop through the contents of the iterator multiple times,
1690 	 * you will have to copy the contents of the iterator to some other
1691 	 * structure, such as a java.util.List.
1692 	 * 
1693 	 * @param container
1694 	 *            the container to iterate over
1695 	 * @return an Iterator over the elements in the container
1696 	 * @throws ReflectionException
1697 	 *             if <code>container</code> is <code>null</code> or <br>
1698 	 *             the Iterator could not be created for some reason
1699 	 */
1700 	public static Iterator getIterator(Object container) throws ReflectionException {
1701 		return DEFAULT_CONTAINER_REFLECTOR.getIterator(container);
1702 	}
1703 	
1704 	/**
1705 	 * Adds a new <code>value</code> to the end of a <code>container</code>.
1706 	 * 
1707 	 * @param container
1708 	 *            the container to which the value is to be added
1709 	 * @param value
1710 	 *            the value to be added
1711 	 * @return <code>true</code> if the container changed as a result of the
1712 	 *         call or <br>
1713 	 *         <code>false</code>, otherwise
1714 	 * @throws ReflectionException
1715 	 *             if an error occurrs
1716 	 */
1717 	public static boolean add(Object container, Object value) throws ReflectionException {
1718 		return DEFAULT_GROWABLE_CONTAINER_REFLECTOR.add(container, value);
1719 	}
1720 	
1721 	/**
1722 	 * Gets the element at the specified index. Valid indexes range between 0
1723 	 * and one less than the container object's size, inclusive.
1724 	 * 
1725 	 * @param container
1726 	 *            the container object
1727 	 * @param index
1728 	 *            a number indiciating which element should be retrieved
1729 	 * @return the object at the specified index
1730 	 * @throws ReflectionException
1731 	 *             if <code>container</code> is null or <br>
1732 	 *             <code>index</code> is not a valid index for the given
1733 	 *             container object or <br>
1734 	 *             the object at the specified index could not be retrieved for
1735 	 *             some reason
1736 	 */
1737 	public static Object get(Object container, int index) throws ReflectionException {
1738 		return DEFAULT_INDEXED_CONTAINER_REFLECTOR.get(container, index);
1739 	}
1740 
1741 	/**
1742 	 * Creates a new instance of the given type.
1743 	 * 
1744 	 * @param clazz
1745 	 *            the type for which we would like a new instance to be created
1746 	 * @throws ReflectionException
1747 	 *             if an error occurrs
1748 	 */
1749 	public static Object newInstance(Class clazz) throws ReflectionException {
1750 		return DEFAULT_INSTANTIATING_REFLECTOR.newInstance(clazz, null);
1751 	}
1752 	
1753 	/**
1754 	 * Sets the element at the specified index. Valid indexes range between 0
1755 	 * and one less than the container object's size, inclusive.
1756 	 * 
1757 	 * @param container
1758 	 *            the container object
1759 	 * @param index
1760 	 *            a number indiciating which element should be set
1761 	 * @param propertyValue
1762 	 *            the value to be set
1763 	 * @return the element previously at the specified position
1764 	 * @throws ReflectionException
1765 	 *             if <code>container</code> is null or <br>
1766 	 *             <code>index</code> is not a valid index for the given
1767 	 *             container object or <br>
1768 	 *             the object at the specified index could not be set for some
1769 	 *             reason
1770 	 */
1771 	public static Object set(Object container, int index, Object propertyValue)
1772 		throws ReflectionException {
1773 		return DEFAULT_MUTABLE_INDEXED_CONTAINER_REFLECTOR.set(container, index, propertyValue);
1774 	}
1775 	
1776 	/**
1777 	 * Returns the number of elements contained in a given object.  If the
1778 	 * object is a bean, the number of properties is returned.  If the object
1779 	 * is a container, the number of elements in the container is returned. 
1780 	 * 
1781 	 * @param object
1782 	 *            the object
1783 	 * @return the number of elements contained in the given object
1784 	 * @throws ReflectionException
1785 	 *             if <code>object</code> is <code>null</code> or the
1786 	 *             number of elements in the object could not be determined
1787 	 */
1788 	public static int getSize(Object object) throws ReflectionException {
1789 		return DEFAULT_SIZABLE_REFLECTOR.getSize(object);
1790 	}
1791 	
1792 }