001    package railo.transformer.library.function;
002    
003    import java.io.IOException;
004    
005    import railo.commons.lang.Md5;
006    import railo.transformer.library.tag.TagLib;
007    
008    
009    
010    /**
011     * Eine FunctionLibFunctionArg repr�sentiert ein einzelnes Argument einer Funktion.
012     */
013    public final class FunctionLibFunctionArg {
014            
015    
016            /**
017             * @return the hidden
018             */
019            public boolean isHidden() {
020                    return hidden;
021            }
022            private String strType;
023            private boolean required;
024            private FunctionLibFunction function;
025            private String name;
026            private String description="";
027            private String alias=null;
028            private String defaultValue=null;
029            private boolean hidden; 
030            private short status=TagLib.STATUS_IMPLEMENTED;
031    
032            
033            /**
034             * Gesch�tzer Konstruktor ohne Argumente.
035             */
036            public FunctionLibFunctionArg() {}
037            public FunctionLibFunctionArg(FunctionLibFunction function) {
038                    this.function=function;
039            }
040    
041            /**
042             * Gibt den Typ des Argument als String zur�ck (query, struct, string usw.)
043             * @return Typ des Argument
044             */
045            public String getTypeAsString() {
046                    return this.strType;
047            }
048    
049            /**
050             * Gibt den Typ des Argument zur�ck (query, struct, string usw.)
051             * @return Typ des Argument
052             */
053            public String getType() {
054                    return strType;
055            }
056    
057            /**
058             * @return the status (TagLib.,TagLib.STATUS_IMPLEMENTED,TagLib.STATUS_DEPRECATED,TagLib.STATUS_UNIMPLEMENTED)
059             */
060            public short getStatus() {
061                    return status;
062            }
063    
064    
065            /**
066             * @param status the status to set (TagLib.,TagLib.STATUS_IMPLEMENTED,TagLib.STATUS_DEPRECATED,TagLib.STATUS_UNIMPLEMENTED)
067             */
068            public void setStatus(short status) {
069                    this.status = status;
070            }
071    
072            /**
073             * Gibt zur�ck, ob das Argument Pflicht ist oder nicht, alias f�r isRequired.
074             * @return Ist das Argument Pflicht.
075             */
076            public boolean isRequired() {
077                    return required;
078            }
079    
080            /**
081             * Gibt zur�ck, ob das Argument Pflicht ist oder nicht.
082             * @return Ist das Argument Pflicht.
083             */
084            public boolean getRequired() {
085                    return required;
086            }
087    
088            /**
089             * Gibt die Funktion zur�ck zu der das Argument geh�rt.
090             * @return Zugeh�rige Funktion.
091             */
092            public FunctionLibFunction getFunction() {
093                    return function;
094            }
095    
096            /**
097             * Setzt die Funktion zu der das Argument geh�rt.
098             * @param function Zugeh�rige Funktion.
099             */
100            protected void setFunction(FunctionLibFunction function) {
101                    this.function = function;
102            }
103    
104            /**
105             * Setzt, den Typ des Argument (query, struct, string usw.)
106             * @param type Typ des Argument.
107             */
108            public void setType(String type) {
109                    this.strType = type;
110            }
111    
112            /**
113             * Setzt, ob das Argument Pflicht ist oder nicht.
114             * @param value Ist das Argument Pflicht.
115             */
116            public void setRequired(String value) {
117                    value=value.toLowerCase().trim();
118                    required=(value.equals("yes") || value.equals("true"));
119            }
120            public void setRequired(boolean value) {
121                    required=value;
122            }
123    
124            /**
125             * @return the name
126             */
127            public String getName() {
128                    return name;
129            }
130    
131            /**
132             * @param name the name to set
133             */
134            public void setName(String name) {
135                    this.name = name;
136            }
137    
138            public Object getDescription() {
139                    return description;
140            }
141    
142            /**
143             * @param description the description to set
144             */
145            public void setDescription(String description) {
146                    this.description = description;
147            }
148    
149    
150            /**
151             * @return the defaultValue
152             */
153            public String getDefaultValue() {
154                    return defaultValue;
155            }
156            
157    
158            /**
159             * @param defaultValue the defaultValue to set
160             */
161            public void setDefaultValue(String defaultValue) {
162                    this.defaultValue = defaultValue;
163            }
164    
165            public String getHash() {
166                    StringBuffer sb=new StringBuffer();
167                    sb.append(this.getDefaultValue());
168                    sb.append(this.getName());
169                    sb.append(this.getRequired());
170                    sb.append(this.getType());
171                    sb.append(this.getTypeAsString());
172                    sb.append(this.getAlias());
173                    
174                    try {
175                            return Md5.getDigestAsString(sb.toString());
176                    } catch (IOException e) {
177                            return "";
178                    }
179            }
180            /**
181             * @return the alias
182             */
183            public String getAlias() {
184                    return alias;
185            }
186            /**
187             * @param alias the alias to set
188             */
189            public void setAlias(String alias) {
190                    this.alias = alias;
191            }
192            public void setHidden(boolean hidden) {
193                    this.hidden=hidden;
194            }
195    }