001: /*
002: * Copyright 2006 Pentaho Corporation. All rights reserved.
003: * This software was developed by Pentaho Corporation and is provided under the terms
004: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005: * this file except in compliance with the license. If you need a copy of the license,
006: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
007: * BI Platform. The Initial Developer is Pentaho Corporation.
008: *
009: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
011: * the license for the specific language governing your rights and limitations.
012: *
013: * @created Apr 13, 2005
014: * @author James Dixon
015: *
016: */
017:
018: package org.pentaho.core.runtime;
019:
020: import java.util.List;
021: import java.util.Map;
022:
023: import org.pentaho.commons.connection.IPentahoResultSet;
024:
025: /**
026: * An <code>IActionParameter</code> represents one input or output in an <tt>IActionSequence</tt>. The
027: * <tt>IActionParameter</tt> is made up of a name or key, and a value.
028: */
029: public interface IActionParameter {
030:
031: /**
032: * Parameter type of <tt>String</tt>
033: */
034: public static final String TYPE_STRING = "string"; //$NON-NLS-1$
035:
036: /**
037: * Parameter type of <code>int</code>
038: */
039: public static final String TYPE_INTEGER = "integer"; //$NON-NLS-1$
040:
041: /**
042: * Parameter type of <tt>List</tt>.
043: */
044: public static final String TYPE_LIST = "list"; //$NON-NLS-1$
045:
046: /**
047: * Parameter type indicating streamable content. @see <tt>RuntimeContext#getOutputStream(java.lang.String,java.lang.String,java.lang.String)</tt>
048: */
049: public static final String TYPE_CONTENT = "content"; //$NON-NLS-1$
050:
051: /**
052: * Parameter type of <tt>Date</tt>
053: */
054: public static final String TYPE_DATE = "date"; //$NON-NLS-1$
055:
056: /**
057: * Parameter type of <tt>IPentahoResultSet</tt>
058: */
059: public static final String TYPE_RESULT_SET = "resultset"; //$NON-NLS-1$
060:
061: /**
062: * Parameter type of <tt>BigDecimal</tt>
063: */
064: public static final String TYPE_DECIMAL = "bigdecimal"; //$NON-NLS-1$
065:
066: /**
067: * Parameter type indicating any type of <tt>Object</tt>
068: */
069: public static final String TYPE_OBJECT = "object"; //$NON-NLS-1$
070:
071: /** This parameter allows prompting */
072: public static final int PROMPT_ALLOWED = 0;
073:
074: /** This parameter needs to be prompted for a value */
075: public static final int PROMPT_NEEDED = 1;
076:
077: /** This parameter does not allow prompting */
078: public static final int PROMPT_NEVER = 2;
079:
080: /** A component has already specified a prompt for this parameter */
081: public static final int PROMPT_PENDING = 3;
082:
083: /**
084: * Get the name, or the key for this ActionParameter.
085: *
086: * @return the ActionParameter name
087: */
088: public String getName();
089:
090: /**
091: * Get the value for this ActionParameter as type String.
092: *
093: * @return the ActionParameter value as a String. getType() should be
094: * referenced first to be sure the value type is TYPE_STRING.
095: */
096: public String getStringValue();
097:
098: /**
099: * Get the value for this ActionParameter as a generic Java Object.
100: *
101: * @return the ActionParameter value as an Object
102: */
103: public Object getValue();
104:
105: /**
106: * Get the value for this ActionParameter as a java.util.List.
107: *
108: * @return the ActionParameter value as a List. getType() should be
109: * referenced first to be sure the value type is TYPE_LIST.
110: */
111: public List getValueAsList();
112:
113: /**
114: * Get the value for this ActionParameter as a IPentahoResultSet
115: *
116: * @return the IPentahoResultSet getType() should be referenced first to be
117: * sure the value type is TYPE_RESULT_SET.
118: */
119: public IPentahoResultSet getValueAsResultSet();
120:
121: /**
122: * Return the value type as one of the constants available in this class.
123: *
124: * @return valid return values are TYPE_STRING, TYPE_INTEGER, TYPE_LIST,
125: * TYPE_CONTENT or TYPE_DATE
126: */
127: public String getType();
128:
129: /**
130: * Sets the value object for this ActionParameter.
131: *
132: * @param value
133: * the value Object to be set.
134: */
135: public void setValue(Object value);
136:
137: /**
138: * @return List of where the parameter may come from (request, session, etc)
139: */
140: public List getVariables();
141:
142: /**
143: * Check if this ActionParameter has a default value set.
144: *
145: * @return true if there is a default value, otherwise false
146: */
147: public boolean hasDefaultValue();
148:
149: /**
150: * Check to se if a value has been set for this parameter. Default value
151: * does not count;
152: *
153: * @return true if this parameter has a non default value
154: */
155: public boolean hasValue();
156:
157: /**
158: * Check to see if the value returned from thisActionParameter is indeed the
159: * default value instead of a value that was set.
160: *
161: * @return true if the parameter is using the default value, false otherwise
162: */
163: public boolean isDefaultValue();
164:
165: /**
166: * Check to see if the value (includes the default value) is null.
167: *
168: * @return true if the value is null, otherwise false
169: */
170: public boolean isNull();
171:
172: /**
173: * See if we need to do any cleanup here
174: *
175: */
176: public void dispose();
177:
178: /**
179: * Returns the prompt status for this parameter.
180: *
181: * @return the status.
182: * @see IActionParameter#PROMPT_ALLOWED
183: * @see IActionParameter#PROMPT_NEVER
184: * @see IActionParameter#PROMPT_NEEDED
185: * @see IActionParameter#PROMPT_PENDING
186: */
187: public int getPromptStatus();
188:
189: /**
190: * Sets the prompt status for this parameter.
191: *
192: * @param status
193: * The status to set.
194: * @return true if the set was successful or false if the current setting
195: * cannot be changed.
196: * @see IActionParameter#PROMPT_ALLOWED
197: * @see IActionParameter#PROMPT_NEVER
198: * @see IActionParameter#PROMPT_NEEDED
199: * @see IActionParameter#PROMPT_PENDING
200: */
201: public boolean setPromptStatus(int status);
202:
203: // // Selection Support
204: /*
205: * Check to see if selections are set for this Parameter
206: */
207: public boolean hasSelections();
208:
209: /**
210: * The display name to use when building a prompt.
211: * @return The display name for the prompt.
212: */
213: public String getSelectionDisplayName();
214:
215: /**
216: * When building a parameter prompt page, what is the
217: * name of the prompt
218: * @param value
219: * @return name for the value
220: */
221: public String getSelectionNameForValue(String value);
222:
223: /**
224: * @deprecated
225: * Unused in the platform
226: */
227: public Map getSelectionNameMap();
228:
229: /**
230: * @deprecated
231: * Unused in the platform
232: */
233: public List getSelectionValues();
234:
235: /**
236: * @deprecated
237: * Unused in the platform
238: */
239: public void setParamSelections(List selValues, Map selNames,
240: String displayname);
241:
242: }
|