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.tag; 020 021import java.sql.Types; 022 023import lucee.commons.lang.StringUtil; 024import lucee.runtime.db.SQLCaster; 025import lucee.runtime.db.SQLItem; 026import lucee.runtime.exp.PageException; 027 028public class ProcParamBean implements SQLItem { 029 030 public static final int DIRECTION_IN=0; 031 public static final int DIRECTION_OUT=1; 032 public static final int DIRECTION_INOUT=3; 033 034 private int direction=DIRECTION_IN; 035 private String variable=null; 036 private Object value=null; 037 private int sqlType=Types.VARCHAR; 038 private int maxLength=0; 039 private int scale=0; 040 private boolean _null=false; 041 private int index=-1; 042 043 /** 044 * @return Returns the cfsqltype. 045 */ 046 public int getType() { 047 return sqlType; 048 } 049 /** 050 * @param cfsqltype The cfsqltype to set. 051 */ 052 public void setType(int sqlType) { 053 this.sqlType = sqlType; 054 } 055 /** 056 * @return Returns the ignoreNull. 057 */ 058 public boolean getNull() { 059 return _null; 060 } 061 /** 062 * @param ignoreNull The ignoreNull to set. 063 */ 064 public void setNull(boolean _null) { 065 this._null = _null; 066 } 067 /** 068 * @return Returns the maxLength. 069 */ 070 public int getMaxLength() { 071 return maxLength; 072 } 073 /** 074 * @param maxLength The maxLength to set. 075 */ 076 public void setMaxLength(int maxLength) { 077 this.maxLength = maxLength; 078 } 079 /** 080 * @return Returns the scale. 081 */ 082 public int getScale() { 083 return scale; 084 } 085 /** 086 * @param scale The scale to set. 087 */ 088 public void setScale(int scale) { 089 this.scale = scale; 090 } 091 /** 092 * @return Returns the type. 093 */ 094 public int getDirection() { 095 return direction; 096 } 097 /** 098 * @param type The type to set. 099 */ 100 public void setDirection(int direction) { 101 this.direction = direction; 102 } 103 /** 104 * @return Returns the value. 105 */ 106 public Object getValue() { 107 if(_null) return null; 108 return value; 109 } 110 /** 111 * @param value The value to set. 112 */ 113 public void setValue(Object value) { 114 this.value = value; 115 } 116 /** 117 * @return Returns the variable. 118 */ 119 public String getVariable() { 120 return variable; 121 } 122 /** 123 * @param variable The variable to set. 124 */ 125 public void setVariable(String variable) { 126 this.variable = variable; 127 } 128 /** 129 * @return Returns the index. 130 */ 131 public int getIndex() { 132 return index; 133 } 134 /** 135 * @param index The index to set. 136 */ 137 public void setIndex(int index) { 138 this.index = index; 139 } 140 public SQLItem clone(Object object) { 141 ProcParamBean ppb = new ProcParamBean(); 142 ppb.direction=direction; 143 ppb.variable=variable; 144 ppb.value=value; 145 ppb.sqlType=sqlType; 146 ppb.maxLength=maxLength; 147 ppb.scale=scale; 148 ppb._null=_null; 149 ppb.index=index; 150 return ppb; 151 } 152 public Object getValueForCF() throws PageException { 153 return SQLCaster.toCFTypex(this); 154 } 155 public boolean isNulls() { 156 return getValue()==null || 157 (sqlType!=Types.VARCHAR && sqlType!=Types.LONGVARCHAR && getValue() instanceof String && StringUtil.isEmpty(getValue())); 158 } 159 public boolean isValueSet() { 160 return value!=null || _null;// TODO impl 161 } 162 public void setNulls(boolean nulls) { 163 // TODO impl 164 } 165}