001    package railo.runtime.util;
002    
003    import java.awt.Color;
004    import java.io.File;
005    import java.io.Serializable;
006    import java.util.Iterator;
007    import java.util.List;
008    import java.util.Locale;
009    import java.util.Map;
010    import java.util.TimeZone;
011    
012    import org.w3c.dom.Node;
013    import org.w3c.dom.NodeList;
014    
015    import railo.commons.io.res.Resource;
016    import railo.runtime.PageContext;
017    import railo.runtime.exp.PageException;
018    import railo.runtime.type.Array;
019    import railo.runtime.type.Collection;
020    import railo.runtime.type.Query;
021    import railo.runtime.type.Struct;
022    import railo.runtime.type.dt.DateTime;
023    import railo.runtime.type.dt.TimeSpan;
024    
025    
026    
027    
028    /**
029     * This class can cast object of one type to a other by CFML rules
030     */
031    public interface Cast { 
032        
033        /**
034         * cast a boolean value to a boolean value (do nothing)
035         * @param b boolean value to cast
036         * @return casted boolean value
037         */
038        public boolean toBooleanValue(boolean b);
039        
040        /**
041         * cast a double value to a boolean value (primitive value type)
042         * @param d double value to cast
043         * @return casted boolean value
044         */
045        public boolean toBooleanValue(double d);
046        
047        /**
048         * cast a double value to a boolean value (primitive value type)
049         * @param c char value to cast
050         * @return casted boolean value
051         */
052        public boolean toBooleanValue(char c);
053        
054        /**
055         * cast a Object to a boolean value (primitive value type)
056         * @param o Object to cast
057         * @return casted boolean value
058         * @throws PageException
059         */
060        public boolean toBooleanValue(Object o) throws PageException;
061    
062        /**
063         * cast a Object to a Double Object (reference Type)
064         * @param o Object to cast
065         * @return casted Double Object
066         * @throws PageException
067         */
068        public Double toDouble(Object o) throws PageException;
069    
070        /**
071         * cast a Object to a Double Object (reference Type)
072         * @param o Object to cast
073         * @param defaultValue 
074         * @return casted Double Object
075         */
076        public Double toDouble(Object o, Double defaultValue);
077    
078        /**
079         * cast a String to a Double Object (reference Type)
080         * @param str String to cast
081         * @return casted Double Object
082         * @throws PageException
083         */
084        public Double toDouble(String str) throws PageException;
085    
086        /**
087         * cast a String to a Double Object (reference Type)
088         * @param str String to cast
089         * @param defaultValue 
090         * @return casted Double Object
091         */
092        public Double toDouble(String str, Double defaultValue);
093        
094        /**
095         * cast a double value to a Double Object (reference Type)
096         * @param d double value to cast
097         * @return casted Double Object
098         */
099        public Double toDouble(double d);
100    
101        /**
102         * cast a boolean value to a Double Object (reference Type)
103         * @param b boolean value to cast
104         * @return casted Double Object
105         */
106        public Double toDouble(boolean b);
107    
108        /**
109         * cast a char value to a Double Object (reference Type)
110         * @param c char value to cast
111         * @return casted Double Object
112         */
113        public Double toDouble(char c);
114        
115        /**
116         * cast a Object to a double value (primitive value Type)
117         * @param o Object to cast
118         * @return casted double value
119         * @throws PageException
120         */
121        public double toDoubleValue(Object o) throws PageException;
122    
123        /**
124         * cast a Object to a double value (primitive value Type)
125         * @param str String to cast
126         * @return casted double value
127         * @throws PageException 
128         */
129        public double toDoubleValue(String str) throws PageException;
130        
131        /**
132         * cast a Object to a double value (primitive value Type)
133         * @param o Object to cast
134         * @param defaultValue if can't cast return this value
135         * @return casted double value
136         */
137        public double toDoubleValue(Object o,double defaultValue);
138        
139        /**
140         * cast a Object to a double value (primitive value Type), if can't return Double.NaN
141         * @param str String to cast
142         * @param defaultValue if can't cast return this value
143         * @return casted double value
144         */ 
145        public double toDoubleValue(String str,double defaultValue); 
146        
147        /**
148         * cast a double value to a double value (do nothing)
149         * @param d double value to cast
150         * @return casted double value
151         */
152        public double toDoubleValue(double d);
153        
154        /**
155         * cast a boolean value to a double value (primitive value type)
156         * @param b boolean value to cast
157         * @return casted double value
158         */
159        public double toDoubleValue(boolean b);
160        
161        /**
162         * cast a char value to a double value (primitive value type)
163         * @param c char value to cast
164         * @return casted double value
165         */
166        public double toDoubleValue(char c);
167        
168        /**
169         * cast a Object to a int value (primitive value type)
170         * @param o Object to cast
171         * @return casted int value
172         * @throws PageException
173         */
174        public int toIntValue(Object o) throws PageException;
175        
176        /**
177         * cast a Object to a int value (primitive value type)
178         * @param o Object to cast
179         * @param defaultValue 
180         * @return casted int value
181         */
182        public int toIntValue(Object o, int defaultValue);
183    
184        /**
185         * cast a String to a int value (primitive value type)
186         * @param str String to cast
187         * @return casted int value
188         * @throws PageException
189         */
190        public int toIntValue(String str) throws PageException;
191        
192        /**
193         * cast a Object to a double value (primitive value Type), if can't return Integer.MIN_VALUE
194         * @param str String to cast
195         * @param defaultValue 
196         * @return casted double value
197         */
198        public int toIntValue(String str, int defaultValue);
199        
200        /**
201         * cast a double value to a int value (primitive value type)
202         * @param d double value to cast
203         * @return casted int value
204         */
205        public int toIntValue(double d);
206        
207        /**
208         * cast a boolean value to a int value (primitive value type)
209         * @param b boolean value to cast
210         * @return casted int value
211         */
212        public int toIntValue(boolean b);
213        
214        /**
215         * cast a char value to a int value (primitive value type)
216         * @param c char value to cast
217         * @return casted int value
218         */
219        public int toIntValue(char c);
220    
221        /**
222         * cast a double to a decimal value (String:xx.xx)
223         * @param value Object to cast
224         * @return casted decimal value
225         * @throws PageException
226         */
227        public String toDecimal(Object value) throws PageException;
228    
229        /**
230         * cast a double to a decimal value (String:xx.xx)
231         * @param value Object to cast
232         * @param defaultValue 
233         * @return casted decimal value
234         */
235        public String toDecimal(Object value, String defaultValue);
236        
237        /**
238         * cast a char to a decimal value (String:xx.xx)
239         * @param c char to cast
240         * @return casted decimal value
241         */
242        public String toDecimal(char c);
243        
244        /**
245         * cast a boolean to a decimal value (String:xx.xx)
246         * @param b boolean to cast
247         * @return casted decimal value
248         */
249        public String toDecimal(boolean b);
250        
251        /**
252         * cast a double to a decimal value (String:xx.xx)
253         * @param d double to cast
254         * @return casted decimal value
255         */
256        public String toDecimal(double d);
257    
258        /**
259         * cast a boolean value to a Boolean Object(reference type)
260         * @param b boolean value to cast
261         * @return casted Boolean Object
262         */
263        public Boolean toBoolean(boolean b);
264        
265        /**
266         * cast a char value to a Boolean Object(reference type)
267         * @param c char value to cast
268         * @return casted Boolean Object
269         */
270        public Boolean toBoolean(char c);
271        
272        /**
273         * cast a double value to a Boolean Object(reference type)
274         * @param d double value to cast
275         * @return casted Boolean Object
276         */
277        public Boolean toBoolean(double d);
278    
279        /**
280         * cast a Object to a Boolean Object(reference type)
281         * @param o Object to cast
282         * @return casted Boolean Object
283         * @throws PageException
284         */
285        public Boolean toBoolean(Object o) throws PageException;
286    
287        /**
288         * cast a Object to a Boolean Object(reference type)
289         * @param str String to cast
290         * @return casted Boolean Object
291         * @throws PageException
292         */
293        public Boolean toBoolean(String str) throws PageException;
294        
295        /**
296         * cast a Object to a boolean value (primitive value type), Exception Less
297         * @param o Object to cast
298         * @param defaultValue 
299         * @return casted boolean value
300         */
301        public boolean toBooleanValue(Object o, boolean defaultValue);
302        
303        /**
304         * cast a Object to a boolean value (refrence type), Exception Less
305         * @param o Object to cast
306         * @param defaultValue default value
307         * @return casted boolean reference
308         */
309        public Boolean toBoolean(Object o,Boolean defaultValue);
310        
311        /**
312         * cast a Object to a boolean value (refrence type), Exception Less
313         * @param str String to cast
314         * @param defaultValue default value
315         * @return casted boolean reference
316         */
317        public Boolean toBoolean(String str, Boolean defaultValue);
318        
319        /**
320         * cast a boolean value to a char value
321         * @param b boolean value to cast
322         * @return casted char value
323         */
324        public char toCharValue(boolean b);
325        
326        /**
327         * cast a double value to a char value (primitive value type)
328         * @param d double value to cast
329         * @return casted char value
330         */
331        public char toCharValue(double d);
332        
333        /**
334         * cast a char value to a char value (do nothing)
335         * @param c char value to cast
336         * @return casted char value
337         */
338        public char toCharValue(char c);
339        
340        /**
341         * cast a Object to a char value (primitive value type)
342         * @param o Object to cast
343         * @return casted char value
344         * @throws PageException
345         */
346        public char toCharValue(Object o) throws PageException;
347        
348        /**
349         * cast a Object to a char value (primitive value type)
350         * @param o Object to cast
351         * @param defaultValue 
352         * @return casted char value
353         */
354        public char toCharValue(Object o, char defaultValue);
355        
356        /**
357         * cast a boolean value to a Character Object(reference type)
358         * @param b boolean value to cast
359         * @return casted Character Object
360         */
361        public Character toCharacter(boolean b);
362        
363        /**
364         * cast a char value to a Character Object(reference type)
365         * @param c char value to cast
366         * @return casted Character Object
367         */
368        public Character toCharacter(char c);
369        
370        /**
371         * cast a double value to a Character Object(reference type)
372         * @param d double value to cast
373         * @return casted Character Object
374         */
375        public Character toCharacter(double d);
376    
377        /**
378         * cast a Object to a Character Object(reference type)
379         * @param o Object to cast
380         * @param defaultValue 
381         * @return casted Character Object
382         */
383        public Character toCharacter(Object o, Character defaultValue);
384    
385        /**
386         * cast a Object to a Character Object(reference type)
387         * @param o Object to cast
388         * @return casted Character Object
389         * @throws PageException
390         */
391        public Character toCharacter(Object o) throws PageException;
392    
393        /**
394         * cast a boolean value to a byte value
395         * @param b boolean value to cast
396         * @return casted byte value
397         */
398        public byte toByteValue(boolean b);
399        
400        /**
401         * cast a double value to a byte value (primitive value type)
402         * @param d double value to cast
403         * @return casted byte value
404         */
405        public byte toByteValue(double d);
406        
407        /**
408         * cast a char value to a byte value (do nothing)
409         * @param c char value to cast
410         * @return casted byte value
411         */
412        public byte toByteValue(char c);
413        
414        /**
415         * cast a Object to a byte value (primitive value type)
416         * @param o Object to cast
417         * @return casted byte value
418         * @throws PageException
419         */
420        public byte toByteValue(Object o) throws PageException;
421        
422        /**
423         * cast a Object to a byte value (primitive value type)
424         * @param o Object to cast
425         * @param defaultValue 
426         * @return casted byte value
427         */
428        public byte toByteValue(Object o, byte defaultValue);
429        
430        /**
431         * cast a boolean value to a Byte Object(reference type)
432         * @param b boolean value to cast
433         * @return casted Byte Object
434         */
435        public Byte toByte(boolean b);
436        
437        /**
438         * cast a char value to a Byte Object(reference type)
439         * @param c char value to cast
440         * @return casted Byte Object
441         */
442        public Byte toByte(char c);
443        
444        /**
445         * cast a double value to a Byte Object(reference type)
446         * @param d double value to cast
447         * @return casted Byte Object
448         */
449        public Byte toByte(double d);
450    
451        /**
452         * cast a Object to a Byte Object(reference type)
453         * @param o Object to cast
454         * @return casted Byte Object
455         * @throws PageException
456         */
457        public Byte toByte(Object o) throws PageException;
458        
459        /**
460         * cast a Object to a Byte Object(reference type)
461         * @param o Object to cast
462         * @param defaultValue 
463         * @return casted Byte Object
464         */
465        public Byte toByte(Object o, Byte defaultValue);
466        
467        /**
468         * cast a boolean value to a long value
469         * @param b boolean value to cast
470         * @return casted long value
471         */
472        public long toLongValue(boolean b);
473        
474        /**
475         * cast a double value to a long value (primitive value type)
476         * @param d double value to cast
477         * @return casted long value
478         */
479        public long toLongValue(double d);
480        
481        /**
482         * cast a char value to a long value (do nothing)
483         * @param c char value to cast
484         * @return casted long value
485         */
486        public long toLongValue(char c);
487        
488        /**
489         * cast a Object to a long value (primitive value type)
490         * @param o Object to cast
491         * @return casted long value
492         * @throws PageException
493         */
494        public long toLongValue(Object o) throws PageException;
495        
496        /**
497         * cast a Object to a long value (primitive value type)
498         * @param o Object to cast
499         * @param defaultValue 
500         * @return casted long value
501         */
502        public long toLongValue(Object o, long defaultValue);
503        
504        /**
505         * cast a boolean value to a Long Object(reference type)
506         * @param b boolean value to cast
507         * @return casted Long Object
508         */
509        public Long toLong(boolean b);
510        
511        /**
512         * cast a char value to a Long Object(reference type)
513         * @param c char value to cast
514         * @return casted Long Object
515         */
516        public Long toLong(char c);
517        
518        /**
519         * cast a double value to a Long Object(reference type)
520         * @param d double value to cast
521         * @return casted Long Object
522         */
523        public Long toLong(double d);
524    
525        /**
526         * cast a Object to a Long Object(reference type)
527         * @param o Object to cast
528         * @return casted Long Object
529         * @throws PageException
530         */
531        public Long toLong(Object o) throws PageException;
532    
533        /**
534         * cast a Object to a Long Object(reference type)
535         * @param o Object to cast
536         * @param defaultValue 
537         * @return casted Long Object
538         */
539        public Long toLong(Object o, Long defaultValue);
540    
541        public Collection.Key toKey(Object o) throws PageException;
542        
543        public Collection.Key toKey(Object o, Collection.Key defaultValue);
544    
545        /**
546         * cast a boolean value to a short value
547         * @param b boolean value to cast
548         * @return casted short value
549         */
550        public short toShortValue(boolean b);
551        
552        /**
553         * cast a double value to a short value (primitive value type)
554         * @param d double value to cast
555         * @return casted short value
556         */
557        public short toShortValue(double d);
558        
559        /**
560         * cast a char value to a short value (do nothing)
561         * @param c char value to cast
562         * @return casted short value
563         */
564        public short toShortValue(char c);
565        
566        /**
567         * cast a Object to a short value (primitive value type)
568         * @param o Object to cast
569         * @return casted short value
570         * @throws PageException
571         */
572        public short toShortValue(Object o) throws PageException;
573        
574        /**
575         * cast a Object to a short value (primitive value type)
576         * @param o Object to cast
577         * @param defaultValue 
578         * @return casted short value
579         */
580        public short toShortValue(Object o, short defaultValue);
581        
582        /**
583         * cast a boolean value to a Short Object(reference type)
584         * @param b boolean value to cast
585         * @return casted Short Object
586         */
587        public Short toShort(boolean b);
588        
589        /**
590         * cast a char value to a Short Object(reference type)
591         * @param c char value to cast
592         * @return casted Short Object
593         */
594        public Short toShort(char c);
595        
596        /**
597         * cast a double value to a Byte Object(reference type)
598         * @param d double value to cast
599         * @return casted Byte Object
600         */
601        public Short toShort(double d);
602    
603        /**
604         * cast a Object to a Short Object(reference type)
605         * @param o Object to cast
606         * @return casted Short Object
607         * @throws PageException
608         */
609        public Short toShort(Object o) throws PageException;
610    
611        /**
612         * cast a Object to a Short Object(reference type)
613         * @param o Object to cast
614         * @param defaultValue 
615         * @return casted Short Object
616         */
617        public Short toShort(Object o, Short defaultValue);
618        
619        /**
620         * cast a String to a boolean value (primitive value type)
621         * @param str String to cast
622         * @return casted boolean value
623         * @throws PageException
624         */
625        public boolean toBooleanValue(String str) throws PageException;
626        
627        /**
628         * cast a String to a boolean value (primitive value type), return 1 for true, 0 for false and -1 if can't cast to a boolean type
629         * @param str String to cast
630         * @param defaultValue 
631         * @return casted boolean value
632         */
633        public boolean toBooleanValue(String str, boolean defaultValue);
634    
635        /**
636         * cast a Object to a String
637         * @param o Object to cast
638         * @return casted String
639         * @throws PageException
640         */
641        public String toString(Object o) throws PageException;
642        
643        /**
644         * cast a Object to a String dont throw a exception, if can't cast to a string return a empty string
645         * @param o Object to cast
646         * @param defaultValue 
647         * @return casted String
648         */
649        public String toString(Object o,String defaultValue);
650        
651        /**
652         * cast a double value to a String
653         * @param d double value to cast
654         * @return casted String
655         */
656        public String toString(double d);
657        
658        /**
659         * cast a long value to a String
660         * @param l long value to cast
661         * @return casted String
662         */
663        public String toString(long l);
664        
665        /**
666         * cast a int value to a String
667         * @param i int value to cast
668         * @return casted String
669         */
670        public String toString(int i);
671    
672        /**
673         * cast a boolean value to a String
674         * @param b boolean value to cast
675         * @return casted String
676         */
677        public String toString(boolean b);
678    
679        /**
680         * cast a Object to a Array Object
681         * @param o Object to cast
682         * @return casted Array
683         * @throws PageException
684         */
685        public List toList(Object o) throws PageException;
686    
687        /**
688         * cast a Object to a Array Object
689         * @param o Object to cast
690         * @param defaultValue 
691         * @return casted Array
692         */
693        public List toList(Object o, List defaultValue);
694    
695        /**
696         * cast a Object to a Array Object
697         * @param o Object to cast
698         * @param duplicate 
699         * @return casted Array
700         * @throws PageException
701         */
702        public List toList(Object o, boolean duplicate) throws PageException;
703        
704        /**
705         * cast a Object to a Array Object
706         * @param o Object to cast
707         * @param duplicate 
708         * @param defaultValue 
709         * @return casted Array
710         */
711        public List toList(Object o, boolean duplicate, List defaultValue);
712        
713        /**
714         * cast a Object to a Array Object
715         * @param obj Object to cast
716         * @return casted Array
717         * @throws PageException
718         */
719        public Array toArray(Object obj) throws PageException;
720        
721        /**
722         * cast a Object to a Array Object
723         * @param obj Object to cast
724         * @param defaultValue 
725         * @return casted Array
726         */
727        public Array toArray(Object obj, Array defaultValue);
728    
729        /**
730         * cast a Object to a Map Object
731         * @param o Object to cast
732         * @return casted Struct
733         * @throws PageException
734         */
735        public Map toMap(Object o) throws PageException;
736        
737        /**
738         * cast a Object to a Map Object
739         * @param o Object to cast
740         * @param defaultValue 
741         * @return casted Struct
742         */
743        public Map toMap(Object o, Map defaultValue);
744        
745        /**
746         * cast a Object to a Map Object
747         * @param o Object to cast
748         * @param duplicate 
749         * @return casted Struct
750         * @throws PageException
751         */
752        public Map toMap(Object o, boolean duplicate) throws PageException;
753        
754        /**
755         * cast a Object to a Map Object
756         * @param o Object to cast
757         * @param duplicate 
758         * @param defaultValue 
759         * @return casted Struct
760         */
761        public Map toMap(Object o, boolean duplicate, Map defaultValue);
762    
763        /**
764         * cast a Object to a Struct Object
765         * @param o Object to cast
766         * @return casted Struct
767         * @throws PageException
768         */
769        public Struct toStruct(Object o) throws PageException;
770        
771        /**
772         * cast a Object to a Struct Object
773         * @param o Object to cast
774         * @param defaultValue 
775         * @return casted Struct
776         */
777        public Struct toStruct(Object o, Struct defaultValue);
778    
779        public Struct toStruct(Object o, Struct defaultValue, boolean caseSensitive);
780    
781        /**
782         * cast a Object to a Binary
783         * @param obj Object to cast
784         * @return casted Binary
785         * @throws PageException
786         */
787        public byte[] toBinary(Object obj) throws PageException;
788        
789        /**
790         * cast a Object to a Binary
791         * @param obj Object to cast
792         * @param defaultValue 
793         * @return casted Binary
794         */
795        public byte[] toBinary(Object obj, byte[] defaultValue);
796    
797        /**
798         * cast a Object to a Base64 value
799         * @param o Object to cast
800         * @return to Base64 String
801         * @throws PageException
802         */
803        public String toBase64(Object o) throws PageException;
804        
805        /**
806         * cast a Object to a Base64 value
807         * @param o Object to cast
808         * @param defaultValue 
809         * @return to Base64 String
810         */
811        public String toBase64(Object o, String defaultValue);
812    
813        /**
814         * cast a boolean to a DateTime Object
815         * @param b boolean to cast
816         * @param tz
817         * @return casted DateTime Object
818         */
819        public DateTime toDate(boolean b, TimeZone tz);
820    
821        /**
822         * cast a char to a DateTime Object
823         * @param c char to cast
824         * @param tz
825         * @return casted DateTime Object
826         */
827        public DateTime toDate(char c, TimeZone tz);
828    
829        /**
830         * cast a double to a DateTime Object
831         * @param d double to cast
832         * @param tz
833         * @return casted DateTime Object
834         */
835        public DateTime toDate(double d, TimeZone tz);
836    
837        /**
838         * cast a Object to a DateTime Object
839         * @param o Object to cast
840         * @param tz
841         * @return casted DateTime Object
842         * @throws PageException
843         */
844        public DateTime toDate(Object o, TimeZone tz) throws PageException;
845        
846        /**
847         * cast a Object to a DateTime Object
848         * @param str String to cast
849         * @param tz
850         * @return casted DateTime Object
851         * @throws PageException
852         */
853        public DateTime toDate(String str, TimeZone tz) throws PageException;
854    
855        /**
856         * cast a Object to a DateTime Object
857         * @param o Object to cast
858         * @param alsoNumbers define if also numbers will casted to a datetime value
859         * @param tz
860         * @param defaultValue 
861         * @return casted DateTime Object
862         */
863        public DateTime toDate(Object o,boolean alsoNumbers, TimeZone tz, DateTime defaultValue);
864    
865        /**
866         * cast a Object to a DateTime Object
867         * @param str String to cast
868         * @param alsoNumbers define if also numbers will casted to a datetime value
869         * @param tz
870         * @param defaultValue 
871         * @return casted DateTime Object
872         */
873        public DateTime toDate(String str,boolean alsoNumbers, TimeZone tz, DateTime defaultValue);
874    
875        /**
876         * cast a Object to a DateTime Object
877         * @param o Object to cast
878         * @param tz
879         * @return casted DateTime Object
880         * @throws PageException
881         */
882        public DateTime toDateTime(Object o, TimeZone tz) throws PageException;
883        
884        /**
885         * cast a Object to a DateTime Object (alias for toDateTime)
886         * @param o Object to cast
887         * @param tz
888         * @return casted DateTime Object
889         * @throws PageException
890         */
891        public DateTime toDatetime(Object o, TimeZone tz) throws PageException;
892        
893        /**
894         * parse a string to a Datetime Object
895         * @param locale 
896         * @param str String representation of a locale Date
897         * @param tz
898         * @return DateTime Object
899         * @throws PageException
900         */
901        public DateTime toDate(Locale locale,String str, TimeZone tz) throws PageException;
902        
903        /**
904         * parse a string to a Datetime Object, returns null if can't convert
905         * @param locale 
906         * @param str String representation of a locale Date
907         * @param tz
908         * @param defaultValue 
909         * @return datetime object
910         */
911        public DateTime toDate(Locale locale,String str, TimeZone tz, DateTime defaultValue);
912    
913        /**
914         * cast a Object to a Query Object
915         * @param o Object to cast
916         * @return casted Query Object
917         * @throws PageException
918         */
919        public Query toQuery(Object o) throws PageException;
920        /**
921         * cast a Object to a Query Object
922         * @param o Object to cast
923         * @param defaultValue 
924         * @return casted Query Object
925         */
926        public Query toQuery(Object o, Query defaultValue);
927        
928        /**
929         * cast a Object to a Query Object
930         * @param o Object to cast
931         * @param duplicate duplicate the object or not
932         * @return casted Query Object
933         * @throws PageException
934         */
935        public Query toQuery(Object o, boolean duplicate) throws PageException;
936        
937        /**
938         * cast a Object to a Query Object
939         * @param o Object to cast
940         * @param duplicate duplicate the object or not
941         * @param defaultValue 
942         * @return casted Query Object
943         */
944        public Query toQuery(Object o, boolean duplicate, Query defaultValue);
945    
946        /**
947         * cast a Object to a UUID
948         * @param o Object to cast
949         * @return casted Query Object
950         * @throws PageException
951         */
952        public Object toUUId(Object o) throws PageException;
953        
954        /**
955         * cast a Object to a UUID
956         * @param o Object to cast
957         * @param defaultValue 
958         * @return casted Query Object
959         */
960        public Object toUUId(Object o, Object defaultValue);
961    
962        /**
963         * cast a Object to a Variable Name
964         * @param o Object to cast
965         * @return casted Variable Name
966         * @throws PageException
967         */
968        public Object toVariableName(Object o) throws PageException;
969        
970        /**
971         * cast a Object to a Variable Name
972         * @param obj Object to cast
973         * @param defaultValue 
974         * @return casted Variable Name
975         */
976        public Object toVariableName(Object obj, Object defaultValue);
977        
978        /**
979         * cast a Object to a TimeSpan Object (alias for toTimeSpan)
980         * @param o Object to cast
981         * @return casted TimeSpan Object
982         * @throws PageException
983         */
984        public TimeSpan toTimespan(Object o) throws PageException;
985        
986        /**
987         * cast a Object to a TimeSpan Object (alias for toTimeSpan)
988         * @param o Object to cast
989         * @param defaultValue 
990         * @return casted TimeSpan Object
991         */
992        public TimeSpan toTimespan(Object o, TimeSpan defaultValue);
993        
994        /**
995         * cast a Throwable Object to a PageException Object
996         * @param t Throwable to cast
997         * @return casted PageException Object
998         */
999        public PageException toPageException(Throwable t);
1000        
1001        /**
1002         * return the type name of a object (string, boolean, int aso.), type is not same like class name
1003         * @param o Object to get type from 
1004         * @return type of the object
1005        */
1006        public String toTypeName(Object o);
1007    
1008        /**
1009         * cast a value to a value defined by type argument
1010         * @param pc
1011         * @param type type of the returning Value
1012         * @param o Object to cast
1013         * @return casted Value
1014         * @throws PageException
1015         */
1016        public Object castTo(PageContext pc,String type, Object o) throws PageException;
1017        
1018        /**
1019         * cast a value to a value defined by type argument
1020         * @param pc
1021         * @param type type of the returning Value
1022         * @param o Object to cast
1023         * @param alsoPattern mean supporting also none real types like email or creditcard ...
1024         * @return casted Value
1025         * @throws PageException
1026         */
1027        public Object castTo(PageContext pc,String type, Object o,boolean alsoPattern) throws PageException;
1028    
1029        /**
1030         * cast a value to a value defined by type argument
1031         * @param pc
1032         * @param type type of the returning Value (Example: Cast.TYPE_QUERY)
1033         * @param strType type as String
1034         * @param o Object to cast
1035         * @return casted Value
1036         * @throws PageException
1037         */
1038        public Object castTo(PageContext pc, short type, String strType, Object o) throws PageException;
1039        
1040        /**
1041         * cast a value to a value defined by type argument
1042         * @param pc
1043         * @param type type of the returning Value (Example: Cast.TYPE_QUERY)
1044         * @param o Object to cast
1045         * @return casted Value
1046         * @throws PageException
1047         */
1048        public Object castTo(PageContext pc, short type, Object o) throws PageException;
1049    
1050        /**
1051         * cast a value to void (Empty String)
1052         * @param o
1053         * @return void value
1054         * @throws PageException
1055         */
1056        public Object toVoid(Object o) throws PageException;
1057        
1058        /**
1059         * cast a value to void (Empty String)
1060         * @param o
1061         * @param defaultValue 
1062         * @return void value
1063         */
1064        public Object toVoid(Object o, Object defaultValue);
1065    
1066        /**
1067         * cast a Object to a reference type (Object), in that case this method to nothing, because a Object is already a reference type
1068         * @param o Object to cast
1069         * @return casted Object
1070         */
1071        public Object toRef(Object o);
1072        
1073        /**
1074         * cast a String to a reference type (Object), in that case this method to nothing, because a String is already a reference type
1075         * @param o Object to cast
1076         * @return casted Object
1077         */
1078        public String toRef(String o);
1079        
1080        /**
1081         * cast a Collection to a reference type (Object), in that case this method to nothing, because a Collection is already a reference type
1082         * @param o Collection to cast
1083         * @return casted Object
1084         */
1085        public Collection toRef(Collection o);
1086        
1087        /**
1088         * cast a char value to his (CFML) reference type String
1089         * @param c char to cast
1090         * @return casted String
1091         */
1092        public String toRef(char c);
1093    
1094        /**
1095         * cast a boolean value to his (CFML) reference type Boolean
1096         * @param b boolean to cast
1097         * @return casted Boolean
1098         */
1099        public Boolean toRef(boolean b);
1100        
1101        /**
1102         * cast a byte value to his (CFML) reference type Boolean
1103         * @param b byte to cast
1104         * @return casted Boolean
1105         */
1106        public Byte toRef(byte b);
1107        
1108        /**
1109         * cast a short value to his (CFML) reference type Integer
1110         * @param s short to cast
1111         * @return casted Integer
1112         */
1113        public Short toRef(short s);
1114        
1115        /**
1116         * cast a int value to his (CFML) reference type Integer
1117         * @param i int to cast
1118         * @return casted Integer
1119         */
1120        public Integer toRef(int i);
1121        
1122        /**
1123         * cast a float value to his (CFML) reference type Float
1124         * @param f float to cast 
1125         * @return casted Float
1126         */
1127        public Float toRef(float f);
1128        
1129        /**
1130         * cast a long value to his (CFML) reference type Long
1131         * @param l long to cast
1132         * @return casted Long
1133         */
1134        public Long toRef(long l);
1135        
1136        /**
1137         * cast a double value to his (CFML) reference type Double
1138         * @param d doble to cast
1139         * @return casted Double
1140         */
1141        public Double toRef(double d);
1142    
1143        /**
1144         * cast a Object to a Iterator or get Iterator from Object
1145         * @param o Object to cast
1146         * @return casted Collection
1147         * @throws PageException
1148         */
1149        public Iterator toIterator(Object o) throws PageException;
1150        
1151        /**
1152         * cast a Object to a Collection
1153         * @param o Object to cast
1154         * @return casted Collection
1155         * @throws PageException
1156         */
1157        public Collection toCollection(Object o) throws PageException;
1158        
1159        /**
1160         * cast to a color object
1161         * @param o Object to cast
1162         * @throws PageException
1163         */
1164        public Color toColor(Object o) throws PageException;
1165        
1166    
1167        
1168        /**
1169         * cast a Object to a Collection, if not returns null
1170         * @param o Object to cast
1171         * @param defaultValue 
1172         * @return casted Collection
1173         */
1174        public Collection toCollection(Object o, Collection defaultValue);
1175        /**
1176         * convert a object to a Resource
1177         * @param obj
1178         * @return File
1179         * @throws PageException 
1180         */ 
1181        public Resource toResource(Object obj) throws PageException;
1182    
1183        /**
1184         * convert a object to a Resource
1185         * @param obj
1186         * @param defaultValue 
1187         * @return Resource
1188         */ 
1189        public Resource toResource(Object obj, Resource defaultValue);
1190    
1191        /**
1192         * convert a object to a File
1193         * @param obj
1194         * @return File
1195         * @throws PageException 
1196         */ 
1197        public File toFile(Object obj) throws PageException;
1198        
1199        
1200        /**
1201         * convert a object to a File
1202         * @param obj
1203         * @param defaultValue 
1204         * @return File
1205         */ 
1206        public File toFile(Object obj, File defaultValue);
1207    
1208        /**
1209         * casts a string to a Locale
1210         * @param strLocale
1211         * @return Locale ferom String
1212         * @throws PageException
1213         */
1214        public Locale toLocale(String strLocale) throws PageException;
1215        
1216        /**
1217         * casts a string to a Locale
1218         * @param strLocale
1219         * @param defaultValue 
1220         * @return Locale from String
1221         */
1222        public Locale toLocale(String strLocale, Locale defaultValue);
1223    
1224        /**
1225         * casts a Object to a Node List
1226         * @param o Object to Cast
1227         * @return NodeList from Object
1228         * @throws PageException
1229         */
1230        public NodeList toNodeList(Object o) throws PageException;
1231        
1232        /**
1233         * casts a Object to a Node List
1234         * @param o Object to Cast
1235         * @param defaultValue 
1236         * @return NodeList from Object
1237         */
1238        public NodeList toNodeList(Object o, NodeList defaultValue);
1239    
1240        /**
1241         * casts a Object to a XML Node
1242         * @param o Object to Cast
1243         * @return Node from Object
1244         * @throws PageException
1245         */
1246        public Node toNode(Object o) throws PageException;
1247        
1248        /**
1249         * casts a Object to a XML Node
1250         * @param o Object to Cast
1251         * @param defaultValue 
1252         * @return Node from Object
1253         */
1254        public Node toNode(Object o, Node defaultValue);
1255        
1256        /**
1257         * casts a boolean to a Integer
1258         * @param b
1259         * @return Integer from boolean
1260         */
1261        public Integer toInteger(boolean b);
1262    
1263        /**
1264         * casts a char to a Integer
1265         * @param c
1266         * @return Integer from char
1267         */
1268        public Integer toInteger(char c);
1269    
1270        /**
1271         * casts a double to a Integer
1272         * @param d
1273         * @return Integer from double
1274         */
1275        public Integer toInteger(double d);
1276        
1277        /**
1278         * casts a Object to a Integer
1279         * @param o Object to cast to Integer
1280         * @return Integer from Object
1281         * @throws PageException
1282         */
1283        public Integer toInteger(Object o) throws PageException;
1284        
1285        /**
1286         * casts a Object to a Integer
1287         * @param o Object to cast to Integer
1288         * @param defaultValue 
1289         * @return Integer from Object
1290         */
1291        public Integer toInteger(Object o, Integer defaultValue);
1292    
1293        /**
1294         * casts a Object to null
1295         * @param value
1296         * @return to null from Object
1297         * @throws PageException
1298         */
1299        public Object toNull(Object value) throws PageException;
1300        
1301        /**
1302         * casts a Object to null
1303         * @param value
1304         * @param defaultValue 
1305         * @return to null from Object
1306         */
1307        public Object toNull(Object value, Object defaultValue);
1308    
1309        /**
1310         * cast Object to a XML Node
1311         * @param value
1312         * @return XML Node
1313         * @throws PageException 
1314         */
1315        public Node toXML(Object value) throws PageException;
1316        
1317        /**
1318         * cast Object to a XML Node
1319         * @param value
1320         * @param defaultValue 
1321         * @return XML Node
1322         */
1323        public Node toXML(Object value, Node defaultValue);
1324        
1325    
1326        /**
1327         * cast to given type
1328         * @param type
1329         * @param o
1330         * @param alsoPattern
1331         * @throws PageException
1332         */
1333        public Object to(String type,Object o,boolean alsoPattern) throws PageException;
1334    
1335            /**
1336             * cast Object to a Serializable Object
1337             * @param obj
1338             * @throws PageException 
1339             */
1340            public Serializable toSerializable(Object obj) throws PageException;
1341    
1342            
1343            /**
1344             * cast Object to a Serializable Object
1345             * @param object
1346             * @param defaultValue
1347             * @return
1348             */
1349            public Serializable toSerializable(Object object, Serializable defaultValue);
1350    }