001    package railo.runtime.type;
002    
003    import java.io.Externalizable;
004    import java.io.IOException;
005    import java.io.ObjectInput;
006    import java.io.ObjectOutput;
007    
008    import railo.commons.lang.CFTypes;
009    import railo.commons.lang.ExternalizableUtil;
010    
011    /**
012     * a single argument of a function, this is lightway function, just contain name and type (return default value for the rest)
013     */
014    public final class FunctionArgumentLight implements FunctionArgument,Externalizable {
015            
016            private Collection.Key name;
017            private short type;
018            private String strType;
019            
020    
021            
022            /**
023             * NEVER USE THIS CONSTRUCTOR, this constructor is only for deserialize this object from stream
024             */
025            public FunctionArgumentLight() {}
026    
027            
028            public FunctionArgumentLight(Collection.Key name) {
029                    this(name, "any", CFTypes.TYPE_ANY);
030            }
031    
032            public FunctionArgumentLight(Collection.Key name,short type) {
033                    this(name, CFTypes.toString(type,"any"), type);
034            }
035    
036            public FunctionArgumentLight(Collection.Key name,String strType,short type) {
037                    this.name=name;
038                    this.strType=strType;
039                    this.type=type;
040            }
041    
042            /**
043             * @return the defaultType
044             */
045            public int getDefaultType() {
046                    return DEFAULT_TYPE_NULL;
047            }
048    
049    
050            /**
051         * @see railo.runtime.type.FunctionArgument#getName()
052         */
053            public Collection.Key getName() {
054                    return name;
055            }
056    
057            /**
058         * @see railo.runtime.type.FunctionArgument#isRequired()
059         */
060            public boolean isRequired() {
061                    return false;
062            }
063    
064            /**
065         * @see railo.runtime.type.FunctionArgument#getType()
066         */
067            public short getType() {
068                    return type;
069            }
070    
071            /**
072         * @see railo.runtime.type.FunctionArgument#getTypeAsString()
073         */
074            public String getTypeAsString() {
075                    return strType;
076            }
077    
078            /**
079         * @see railo.runtime.type.FunctionArgument#getHint()
080         */
081            public String getHint() {
082                    return "";
083            }
084    
085    
086            /**
087             *
088             * @see railo.runtime.type.FunctionArgument#getDisplayName()
089             */
090            public String getDisplayName() {
091                    return "";
092            }
093    
094    
095            /**
096         * @see railo.runtime.type.FunctionArgument#getDspName()
097         * @deprecated replaced with <code>getDisplayName();</code>
098         */
099            public String getDspName() {
100                    return getDisplayName();
101            }
102            
103            /**
104             * @see railo.runtime.type.FunctionArgument#getMetaData()
105             */
106            public Struct getMetaData() {
107                    return null;
108            }
109            
110            public boolean isPassByReference() {
111                    return true;
112            }
113    
114    
115            public void readExternal(ObjectInput in) throws IOException,ClassNotFoundException {
116                    name=KeyImpl.init(ExternalizableUtil.readString(in));
117                    type=in.readShort();
118                    strType=ExternalizableUtil.readString(in);
119            }
120    
121    
122            public void writeExternal(ObjectOutput out) throws IOException {
123                    ExternalizableUtil.writeString(out, name.getString());
124                    out.writeShort(type);
125                    ExternalizableUtil.writeString(out, strType);
126            }
127    }