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 lucee.runtime.exp.PageException; 022import lucee.runtime.type.Collection; 023import lucee.runtime.type.Collection.Key; 024 025 026 027/** 028 * Object to test if a Object is a specific type 029 */ 030public interface Decision { 031 032 // FUTURE add function isJson and others we support in the core 033 // FUTURE add function is(String type, Object value) 034 035 /** 036 * tests if value is a simple value (Number,String,Boolean,Date,Printable) 037 * @param value value to test 038 * @return is value a simple value 039 */ 040 public boolean isSimpleValue(Object value); 041 042 /** 043 * tests if value is Numeric 044 * @param value value to test 045 * @return is value numeric 046 */ 047 public boolean isNumeric(Object value); 048 049 /** 050 * tests if String value is Numeric 051 * @param str value to test 052 * @return is value numeric 053 */ 054 public boolean isNumeric(String str); 055 056 /** tests if String value is Hex Value 057 * @param str value to test 058 * @return is value numeric 059 */ 060 public boolean isHex(String str); 061 062 /** tests if String value is UUID Value 063 * @param str value to test 064 * @return is value numeric 065 */ 066 public boolean isUUID(String str); 067 068 /** 069 * tests if value is a Boolean (Numbers are not acctepeted) 070 * @param value value to test 071 * @return is value boolean 072 */ 073 public boolean isBoolean(Object value); 074 075 /** 076 * tests if value is a Boolean 077 * @param str value to test 078 * @return is value boolean 079 */ 080 public boolean isBoolean(String str); 081 082 /** 083 * tests if value is DateTime Object 084 * @param value value to test 085 * @param alsoNumbers interpret also a number as date 086 * @return is value a DateTime Object 087 */ 088 public boolean isDate(Object value,boolean alsoNumbers); 089 090 /** 091 * tests if object is a struct 092 * @param o 093 * @return is struct or not 094 */ 095 public boolean isStruct(Object o); 096 097 /** 098 * tests if object is a array 099 * @param o 100 * @return is array or not 101 */ 102 public boolean isArray(Object o); 103 104 /** 105 * tests if object is a native java array 106 * @param o 107 * @return is a native (java) array 108 */ 109 public boolean isNativeArray(Object o); 110 111 /** 112 * tests if object is a binary 113 * @param object 114 * @return boolean 115 */ 116 public boolean isBinary(Object object); 117 118 /** 119 * tests if object is a Component 120 * @param object 121 * @return boolean 122 */ 123 public boolean isComponent(Object object); 124 125 /** 126 * tests if object is a Query 127 * @param object 128 * @return boolean 129 */ 130 public boolean isQuery(Object object); 131 132 /** 133 * tests if object is a binary 134 * @param object 135 * @return boolean 136 */ 137 public boolean isUserDefinedFunction(Object object); 138 // FUTURE add isClosure and isFunction, set function above to deprecated 139 140 141 /** 142 * tests if year is a leap year 143 * @param year year to check 144 * @return boolean 145 */ 146 public boolean isLeapYear(int year); 147 148 /** 149 * tests if object is a WDDX Object 150 * @param o Object to check 151 * @return boolean 152 */ 153 public boolean isWddx(Object o); 154 155 /** 156 * tests if object is a XML Object 157 * @param o Object to check 158 * @return boolean 159 */ 160 public boolean isXML(Object o); 161 162 /** 163 * tests if object is a XML Element Object 164 * @param o Object to check 165 * @return boolean 166 */ 167 public boolean isXMLElement(Object o); 168 169 /** 170 * tests if object is a XML Document Object 171 * @param o Object to check 172 * @return boolean 173 */ 174 public boolean isXMLDocument(Object o); 175 176 /** 177 * tests if object is a XML Root Element Object 178 * @param o Object to check 179 * @return boolean 180 */ 181 public boolean isXMLRootElement(Object o); 182 183 /** 184 * @param string 185 * @return returns if string represent a variable name 186 */ 187 public boolean isVariableName(String string); 188 189 /** 190 * @param string 191 * @return returns if string represent a variable name 192 */ 193 public boolean isSimpleVariableName(String string); 194 195 /** 196 * returns if object is a CFML object 197 * @param o Object to check 198 * @return is or not 199 */ 200 public boolean isObject(Object o); 201 202 /** 203 * 204 * @param str 205 * @return return if a String is "Empty", that means NULL or String with length 0 (whitespaces will not counted) 206 */ 207 public boolean isEmpty(String str); 208 209 /** 210 * 211 * @param str 212 * @param trim 213 * @return return if a String is "Empty", that means NULL or String with length 0 (whitespaces will not counted) 214 */ 215 public boolean isEmpty(String str, boolean trim); 216 217 218 219 public Key toKey(Object obj) throws PageException; 220 221 public Key toKey(Object obj, Collection.Key defaultValue); 222 223}