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.op; 020 021import java.io.Serializable; 022 023import lucee.runtime.exp.PageException; 024import lucee.runtime.type.dt.DateTime; 025 026/** 027 * Interface to define a Object as Castable, for Lucee Type Casts 028 */ 029public interface Castable extends Serializable{ 030 031 /** 032 * cast the castable value to a string, other than the Method toString, this Method can throw a Exception 033 * @return String representation of the Object 034 * @throws PageException 035 */ 036 public String castToString() throws PageException; 037 038 /** 039 * cast the castable value to a string, return the default value, when the method is not castable 040 * @return String representation of the Object 041 * @throws PageException 042 */ 043 public String castToString(String defaultValue); 044 045 /** 046 * cast the castable value to a boolean value 047 * @return boolean Value representation of the Object 048 * @throws PageException 049 */ 050 public boolean castToBooleanValue() throws PageException; 051 052 /** 053 * cast the castable value to a boolean value 054 * @return boolean Value representation of the Object 055 * @throws PageException 056 */ 057 public Boolean castToBoolean(Boolean defaultValue); 058 059 /** 060 * cast the castable value to a double value 061 * @return double Value representation of the Object 062 * @throws PageException 063 */ 064 public double castToDoubleValue() throws PageException; 065 066 /** 067 * cast the castable value to a double value 068 * @return double Value representation of the Object 069 * @throws PageException 070 */ 071 public double castToDoubleValue(double defaultValue); 072 073 /** 074 * cast the castable value to a date time object 075 * @return date time representation of the Object 076 * @throws PageException 077 */ 078 public DateTime castToDateTime() throws PageException; 079 080 /** 081 * cast the castable value to a date time object 082 * @param defaultValue returned when it is not possible to cast to a dateTime object 083 * @return date time representation of the Object 084 * @throws PageException 085 */ 086 public DateTime castToDateTime(DateTime defaultValue); 087 088 089 public int compareTo(String str) throws PageException; 090 public int compareTo(boolean b) throws PageException; 091 public int compareTo(double d) throws PageException; 092 public int compareTo(DateTime dt) throws PageException; 093 094 095}