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            @Override
051            public Collection.Key getName() {
052                    return name;
053            }
054    
055            @Override
056            public boolean isRequired() {
057                    return false;
058            }
059    
060            @Override
061            public short getType() {
062                    return type;
063            }
064    
065            @Override
066            public String getTypeAsString() {
067                    return strType;
068            }
069    
070            @Override
071            public String getHint() {
072                    return "";
073            }
074    
075    
076            @Override
077            public String getDisplayName() {
078                    return "";
079            }
080            
081            @Override
082            public Struct getMetaData() {
083                    return null;
084            }
085            
086            public boolean isPassByReference() {
087                    return true;
088            }
089    
090    
091            public void readExternal(ObjectInput in) throws IOException,ClassNotFoundException {
092                    name=KeyImpl.init(ExternalizableUtil.readString(in));
093                    type=in.readShort();
094                    strType=ExternalizableUtil.readString(in);
095            }
096    
097    
098            public void writeExternal(ObjectOutput out) throws IOException {
099                    ExternalizableUtil.writeString(out, name.getString());
100                    out.writeShort(type);
101                    ExternalizableUtil.writeString(out, strType);
102            }
103            
104            public boolean equals(Object obj){
105                    if(!(obj instanceof FunctionArgument)) return false;
106                    return FunctionArgumentImpl.equals(this,(FunctionArgument)obj);
107            }
108    }