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