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