i-net Clear Reports

com.inet.report
Class PromptField

java.lang.Object
  extended by com.inet.report.Field
      extended by com.inet.report.PromptField
All Implemented Interfaces:
NodeParser, com.inet.report.ReferencedObject, com.inet.report.ReferenceHolder, java.io.Serializable

public class PromptField
extends Field
implements com.inet.report.ReferenceHolder

This class represents a prompt, that is, a field whose value(s) are asked for from the user at runtime. Using prompt fields, it is possible to change the parameterization and looks of a report by using the value(s) given by the user.
An example would be to use a prompt field in the record selection formula, in order to only show records with an ID equal to the prompted value.
It is possible to have single or multiple discrete values, single or multiple range values, or also multiple discrete and/or range values be passed to a prompt. Range values are considered as all values in between the two limits.
Here are two examples of how to use this class:

 //getting all fields, where engine references your Engine
 Fields fields = engine.getFields();
 //add a prompt of prompt value type NUMBER
 PromptField pField = fields.addPromptField("PromptName","PromptText", PromptField.NUMBER);

 ---

 //get total number of prompts
 int promptFieldsCount = fields.getPromptFieldsCount();
 //for all prompts in fields...
 for (int i=0;i< promptFieldsCount;i++){
     //...print name
     System.out.println(fields.getPromptField(i).getName());
 }
 

See Also:
Fields.addPromptField(String, String, int), Fields.getPromptFieldsCount(), Fields.getPromptField(int), Fields.removePromptField(int), FieldElement, FieldPart, Serialized Form

Field Summary
static int DISCRETE_AND_RANGE_VALUE
          Prompt field allows both, discrete and range value.
static int DISCRETE_VALUE
          Prompt field allows a discrete value.
static int RANGE_VALUE
          Prompt field allows a range value.
 
Fields inherited from class com.inet.report.Field
BINARY, BOOLEAN, CURRENCY, CURSOR, DATABASE_FIELD, DATE, DATETIME, FORMULA_FIELD, GROUP_NAME_FIELD, NUMBER, PARAMETER_FIELD, SORT_FIELD, SPECIAL_FIELD, SQL_FIELD, STRING, SUMMARY_FIELD, TIME, UNKNOWN
 
Method Summary
 void addDefaultValue(DefaultValue value)
          Adds a single default value to the end of the default value list.
 Field duplicate(java.lang.String name)
          Duplicates this field with all its settings and returns the created Field with the given name.
 boolean getAllowMultipleValues()
          Returns whether or not multiple values can be passed to this prompt or not.
 java.lang.String getDefaultPromptValuesAsString()
          Returns the default values for this prompt as formula syntax, i.e. as an array if there are multiple default prompt values.
 DefaultValue getDefaultValue(int i)
          Returns the default value at the given index.
 int getDefaultValueCount()
          Returns The number of default values set for this prompt. 0 if none are set.
 DynamicValueProvider getDefaultValueProvider()
          If a DynamicValueProvider has been set for this PromptField, this method will return this provider.
 DefaultValue[] getDefaultValues()
          Fetches the default values.
 int getDiscreteOrRangeType()
          Returns the type of values which are allowed for this prompt.
 java.lang.Object getMaxRangeValue()
          If property 'use range' is enabled this method returns the maximum value for an prompt value.
 java.lang.Object getMinRangeValue()
          If property 'use range' is enabled this method returns the minimum value for an prompt value.
 java.lang.String getPromptText()
          Returns the prompting text.
 int getPromptType()
          Returns the value type of this prompt field.
 java.lang.Object getPromptValue()
          Returns the value set for this prompt.
 java.lang.String getPromptValueAsFormula()
          Get the set value of this prompt as a formula.
 java.lang.String[] getPromptValueDescriptions()
          Returns the array of the value descriptions of the default values of this prompt field, which are shown to the user when prompting.
 TableSource[] getTableSources()
          Returns the table sources this prompt field is a parameter for.
 boolean getUseRange()
          Returns whether or not any values which are to be for this prompt must be in a range.
 java.lang.Object getValue()
          Returns the prompt value.
 int getValueType()
          Returns the value type (or return type) of the field.
 int getValuesCount()
          Returns the number of values set for this prompt.
 boolean isDescriptionOnly()
          Returns whether or not only the descriptions of the default values are to be shown when this field is prompted for.
 boolean isEditable()
          Returns whether or not values are allowed to be entered other than the default values themselves.
 boolean isParameterOfStoredProcedure()
          Returns whether this prompt field works as an input parameter for a stored procedure.
 boolean isPasswordField()
          Returns whether or not this prompt field is to be treated as a password field, that is, showing asterisks (*) for entered characters, hiding the entered value from view.
 boolean isSubreportLink()
          Returns whether this prompt is in a subreport and links to the main report.
 boolean isUsed()
          FOR INTERNAL USE ONLY
 boolean isValueSet()
          Returns whether or not setPromtValue(Object) was called and a valid value for this prompt was set.
 java.lang.String paramString()
          Returns a prettified output of this field's name and type.
 void removeDefaultValue(int index)
          Removes the default prompt value and its description at the given index from the default value list.
protected  void saveFieldXML2(java.io.PrintWriter pw, int depth)
          Saves PromptField attributes
 void setAllowMultipleValues(boolean newValue)
          Sets whether multiple values can be passed to this prompt or only a single value.
 void setDefaultValue(int index, DefaultValue defaultValue)
          Overrides a single default value at the given index.
 void setDefaultValueProvider(DynamicValueProvider provider)
          Sets the DynamicValueProvider which will dynamically create values for the default values at run-time.
 void setDefaultValues(DefaultValue[] values)
          Sets the default values for this prompt.
 void setDescriptionOnly(boolean descOnly)
          Sets whether or not only the descriptions of the default values are to be shown when this field is prompted for.
 void setDiscreteOrRangeType(int newValue)
          Sets the value of the property 'discrete or range type'.
 void setEditable(boolean isEditable)
          Sets whether or not values are allowed to be entered other than the default values themselves.
 void setMaxRangeValue(java.lang.Object max)
          Sets the maximum allowed value for any value of this prompt field.
 void setMinMaxRangeValues(java.lang.Object min, java.lang.Object max)
          Sets the minimum and maximum allowed value for any value of this prompt field.
 void setMinRangeValue(java.lang.Object min)
          Sets the minimum allowed value for any value of this prompt field.
 void setName(java.lang.String name)
          Sets the name of the prompt field.
 void setPasswordField(boolean isPasswordField)
          Sets whether or not this prompt field is to be treated as a password field, that is, showing asterisks (*) for entered characters, hiding the entered value from view.
 void setPromptText(java.lang.String promptText)
          Sets the prompting text.
 void setPromptType(int valueType)
          Sets the Prompt Type.
 void setPromptValue(java.lang.Object prompt)
          Sets the actual value for this PromptField.
 void setPromptValueAsFormula(java.lang.String formula)
          Sets the prompt value as a formula in Crystal syntax.
 void setPromptValueDescriptions(java.lang.String[] descr)
          Sets the descriptions of the default values of this prompt field.
 void setUseRange(boolean newValue)
          Sets whether the values must be in a certain value range or not.
 
Methods inherited from class com.inet.report.Field
checkNameExists, extractReference, getField, getGroup, getName, getPlaceholderName, getRefName, getType, indexOf, setField, setGroup, setValueType, trimAwayBrackets
 
Methods inherited from interface com.inet.report.parser.NodeParser
isDOMParser, parseDOM, parseElement, parseEndElement, parseText
 

Field Detail

DISCRETE_VALUE

public static final int DISCRETE_VALUE
Prompt field allows a discrete value.

See Also:
Constant Field Values

RANGE_VALUE

public static final int RANGE_VALUE
Prompt field allows a range value.

See Also:
Constant Field Values

DISCRETE_AND_RANGE_VALUE

public static final int DISCRETE_AND_RANGE_VALUE
Prompt field allows both, discrete and range value.

See Also:
Constant Field Values
Method Detail

setName

public final void setName(java.lang.String name)
Sets the name of the prompt field. The name can not exist already, otherwise an exception will be thrown.

Specified by:
setName in class Field
Parameters:
name - Name to be assigned to this prompt field
Throws:
java.lang.IllegalArgumentException - if the name already exists

getPromptText

public final java.lang.String getPromptText()
Returns the prompting text. The prompting text is a text that will ask for the value of the prompt field and can explain the default values, etc.

Returns:
the prompting text for this default value
See Also:
setPromptText(java.lang.String)

setPromptText

public final void setPromptText(java.lang.String promptText)
Sets the prompting text. The prompting text is a text that will ask for the value of the prompt field and can explain the default values, etc.

Parameters:
promptText - the prompting text, can be null for no text
See Also:
getPromptText()

getPromptValue

public final java.lang.Object getPromptValue()
Returns the value set for this prompt. By default, this will return null, but if a value is set for the prompt (either via setPromptValue(Object) or by entering a value in the prompt dialog), this will return the value set for this PromptField.
If the prompt value is a multi-value prompt, this will return an array of values, so you can cast the returned Object to an Object[].
The returned value's class depends on the value type of the PromptField:

Returns:
The actually set value (either by API or by prompt dialog) for this prompt field.
See Also:
Field.NUMBER, Field.CURRENCY, Field.BOOLEAN, Field.DATE, Field.TIME, Field.DATETIME, Field.STRING, FormulaRange, setPromptValue(java.lang.Object), setPromptValueAsFormula(java.lang.String), getValuesCount()

setPromptValue

public final void setPromptValue(java.lang.Object prompt)
                          throws ReportException
Sets the actual value for this PromptField. Calling this will cause this PromptField to be viewed as set and therefore as not necessary to be prompted at run-time.
This method checks the plausibility of the given value, that means if 'multiple values' is enabled, it checks that the given Object is an array. If the property 'discrete and range type' is set to discrete it checks that there's no FormulaRange. If the property 'use range' is enabled it checks that all values are in the allowed range. Furthermore it checks that the value type of the PromptField fits with the object provided.

Parameters:
prompt - The given Object can either be
  • java.lang.Number or java.lang.Long etc. for value types NUMBER and CURRENCY
  • java.lang.Boolean for value type BOOLEAN
  • java.sql.Date for value type DATE
  • java.sql.Time for value type TIME
  • java.sql.Timestamp for value type DATETIME
  • java.lang.String for value type STRING
  • com.inet.report.FormulaRange for ranges
  • An array of the above objects for multiple values and multiple ranges.
Throws:
ReportException - when you have enabled a range checking for prompt values and the parameter object has value(s) which are not in this range: - You have chosen a prompt with multiple values but parameter prompt is no array.
- You have chosen a prompt with discrete values but parameter prompt is a range value.
- You have chosen a prompt with one single value but parameter prompt is an array.
- You have chosen a prompt with a single range value but parameter prompt is no range.
- You have chosen neither a prompt with discrete values or with range values but parameter object is an array with mixed of both type.
See Also:
Field.NUMBER, Field.CURRENCY, Field.BOOLEAN, Field.DATE, Field.TIME, Field.DATETIME, Field.STRING, FormulaRange, getPromptValue(), setPromptValueAsFormula(java.lang.String), getValuesCount(), setDefaultValues(DefaultValue[])

setPromptValueAsFormula

public void setPromptValueAsFormula(java.lang.String formula)
                             throws ReportException
Sets the prompt value as a formula in Crystal syntax. This formula is evaluated on the fly and its value is set.

Parameters:
formula - Value to set for this prompt, as a formula in Crystal syntax
Throws:
ReportException - when you have enabled a range checking for prompt values and the parameter object has value(s) which are not in this range: - you have chosen a prompt with multiple values but parameter prompt is no array.
- you have chosen a prompt with discrete values but parameter prompt is a range value.
- you have chosen a prompt with one single value but parameter prompt is an array.
- you have chosen a prompt with a single range value but parameter prompt is no range.
- you have chosen neither a prompt with discrete values or with range values but parameter object is an array with mixed of both type.
See Also:
Engine.setPrompt(String, int), getPromptValue(), setPromptValue(java.lang.Object), getValuesCount()

getPromptType

public final int getPromptType()
Returns the value type of this prompt field. This can either be:

Returns:
Value type of this prompt field.
See Also:
Field.NUMBER, Field.CURRENCY, Field.BOOLEAN, Field.DATE, Field.TIME, Field.DATETIME, Field.STRING, Fields.addPromptField(java.lang.String, java.lang.String, int), setPromptType(int)

setPromptType

public final void setPromptType(int valueType)
Sets the Prompt Type. This can be be one of the following:

Parameters:
valueType - Value type for this prompt field
Throws:
java.lang.IllegalArgumentException - will thrown if the value type not equals the the field type.
See Also:
Field.NUMBER, Field.CURRENCY, Field.BOOLEAN, Field.DATE, Field.TIME, Field.DATETIME, Field.STRING, Field.BINARY, getPromptType()

setUseRange

public final void setUseRange(boolean newValue)
Sets whether the values must be in a certain value range or not. If it is set to true, all values of the prompt will be checked if they are in the given range or not.

Parameters:
newValue - True if the prompt values must be within a range of values.
See Also:
setMinMaxRangeValues(java.lang.Object, java.lang.Object), getMaxRangeValue(), getMinRangeValue(), getUseRange()

getUseRange

public final boolean getUseRange()
Returns whether or not any values which are to be for this prompt must be in a range.

Returns:
True if the values should be in a value range.
See Also:
setMinMaxRangeValues(java.lang.Object, java.lang.Object), getMaxRangeValue(), getMinRangeValue(), setUseRange(boolean)

setDescriptionOnly

public final void setDescriptionOnly(boolean descOnly)
Sets whether or not only the descriptions of the default values are to be shown when this field is prompted for. For example, a number prompt field with the default values of 4 and 5 with the descriptions "Number Four" and "Number Five" respectively would only show as two default entries "Number Four" and "Number Five" if this setting was on. By default, this is off.

Parameters:
descOnly - Should only the descriptions of the default values be shown when prompting for this field?
Since:
7.0

isDescriptionOnly

public final boolean isDescriptionOnly()
Returns whether or not only the descriptions of the default values are to be shown when this field is prompted for. For example, a number prompt field with the default values of 4 and 5 with the descriptions "Number Four" and "Number Five" respectively would only show as two default entries "Number Four" and "Number Five" if this setting was on. By default, this is off.

Returns:
Should only the descriptions of the default values be shown when prompting for this field?
Since:
7.0

setEditable

public final void setEditable(boolean isEditable)
Sets whether or not values are allowed to be entered other than the default values themselves. For example, a number prompt field with the default values of 4 and 5 would only allow values 4 or 5, nothing else, if this setting was off. By default, this is on. Note that if this is set to false and there is only one default value, then this prompt field is viewed as hidden and will not be shown in the prompt dialog.

Parameters:
isEditable - Should other values than the default values be accepted as valid values for this prompt field?
Throws:
java.lang.UnsupportedOperationException - if isEditable is false and this is a password field, since password fields must be editable.
Since:
7.0

isEditable

public final boolean isEditable()
Returns whether or not values are allowed to be entered other than the default values themselves. For example, a number prompt field with the default values of 4 and 5 would only allow values 4 or 5, nothing else, if this setting was off. By default, this is on.

Returns:
Should other values than the default values be accepted as valid values for this prompt field?
Since:
7.0

isValueSet

public boolean isValueSet()
Returns whether or not setPromtValue(Object) was called and a valid value for this prompt was set. If this function returns true, this PromptField is viewed as set and therefore as not necessary to be prompted at run-time.

Returns:
Has this prompt field beens set to a valid value?
Since:
8.3
See Also:
setPromptValue(Object)

isPasswordField

public final boolean isPasswordField()
Returns whether or not this prompt field is to be treated as a password field, that is, showing asterisks (*) for entered characters, hiding the entered value from view.

Returns:
Is this prompt field to be treated as a password field?
Since:
7.0

setPasswordField

public final void setPasswordField(boolean isPasswordField)
Sets whether or not this prompt field is to be treated as a password field, that is, showing asterisks (*) for entered characters, hiding the entered value from view. Note that setting this prompt field to a password prompt field automatically causes the field to become a single, discrete, editable prompt with no default values or default value provider.

Parameters:
isPasswordField - Is this prompt field to be treated as a password field?
Since:
7.0

setDiscreteOrRangeType

public void setDiscreteOrRangeType(int newValue)
                            throws ReportException
Sets the value of the property 'discrete or range type'. This property indicates whether a single value DISCRETE_VALUE, a single range RANGE_VALUE or both ranges and single value DISCRETE_AND_RANGE_VALUE are allowed. In the last case, this prompt field must already be set to allow multiple values, with setAllowMultipleValues(boolean).

Parameters:
newValue - The new value of the property 'discrete or range type'.
Throws:
ReportException - will thrown if value is out of range.
java.lang.UnsupportedOperationException - if this is a password prompt field and a value is set which is not DISCRETE_VALUE
See Also:
DISCRETE_AND_RANGE_VALUE, DISCRETE_VALUE, setAllowMultipleValues(boolean), getAllowMultipleValues(), getDiscreteOrRangeType(), setUseRange(boolean), getUseRange()

getDiscreteOrRangeType

public int getDiscreteOrRangeType()
Returns the type of values which are allowed for this prompt.

Returns:
which type of values are allowed for this prompt field.
See Also:
DISCRETE_VALUE, RANGE_VALUE, DISCRETE_AND_RANGE_VALUE, setDiscreteOrRangeType(int), setUseRange(boolean), getUseRange(), setAllowMultipleValues(boolean), getAllowMultipleValues()

setAllowMultipleValues

public void setAllowMultipleValues(boolean newValue)
Sets whether multiple values can be passed to this prompt or only a single value.

Parameters:
newValue - true if multiple values should be able to be entered for this prompt.
Throws:
java.lang.UnsupportedOperationException - if newValue is true and this field is a password prompt field
See Also:
getAllowMultipleValues(), getDiscreteOrRangeType(), setDiscreteOrRangeType(int)

getAllowMultipleValues

public boolean getAllowMultipleValues()
Returns whether or not multiple values can be passed to this prompt or not.

Returns:
true if multiple values can be passed to this prompt.
See Also:
setAllowMultipleValues(boolean)

getValuesCount

public int getValuesCount()
Returns the number of values set for this prompt. Each range value counts as one value only. Note that this will only return a number greater than one if this is a multiple value prompt.

Returns:
Number of set values for this prompt.
See Also:
setPromptValue(java.lang.Object), setPromptValueAsFormula(java.lang.String), getPromptValue(), getAllowMultipleValues(), setAllowMultipleValues(boolean)

setMinRangeValue

public void setMinRangeValue(java.lang.Object min)
                      throws ReportException
Sets the minimum allowed value for any value of this prompt field.
Calling this method is only allowed if "use range" is activated for this PromptField. This can be activated by calling setUseRange(boolean).
Passing null as a minimum value has the effect that no minimum limit is set. This makes it possible to limit values with an open interval.
If the prompt's value type is one of Number, Currency or String then any value must be an instance of java.lang.Number.
If the prompt's value type is Boolean then no range is possible for prompt values. If the prompt's value type is Date then any value must be an instance of java.sql.Date.
If the prompt's value type is Time then any value must be an instance of java.sql.Time.
If the prompt's value type is DateTime then any value must be an instance of java.sql.Timestamp.

Parameters:
min - The minimum value that a prompt value can assume, or null if no minimum is to be set
Throws:
ReportException - will thrown if:
- value type is unknown or boolean
- value does not match value type
- min is greater than max
java.lang.IllegalStateException - if range is disabled, see setDiscreteOrRangeType(int)
See Also:
getMinRangeValue(), getUseRange(), setUseRange(boolean)

setMaxRangeValue

public void setMaxRangeValue(java.lang.Object max)
                      throws ReportException
Sets the maximum allowed value for any value of this prompt field.
Calling this method is only allowed if "use range" is activated for this PromptField. This can be activated by calling setUseRange(boolean).
Passing null as a maximum value has the effect that no maximum limit is set. This makes it possible to limit values with an open interval.
If the prompt's value type is one of Number, Currency or String then any value must be an instance of java.lang.Number.
If the prompt's value type is Boolean then no range is possible for prompt values. If the prompt's value type is Date then any value must be an instance of java.sql.Date.
If the prompt's value type is Time then any value must be an instance of java.sql.Time.
If the prompt's value type is DateTime then any value must be an instance of java.sql.Timestamp.

Parameters:
max - The maximum value that a prompt value can assume, or null if no maximum is to be set
Throws:
ReportException - will thrown if:
- value type is unknown or boolean
- value does not match value type
- max is less than min
java.lang.IllegalStateException - if range is disabled, see setDiscreteOrRangeType(int)
See Also:
getMaxRangeValue(), getUseRange(), setUseRange(boolean)

setMinMaxRangeValues

public void setMinMaxRangeValues(java.lang.Object min,
                                 java.lang.Object max)
                          throws ReportException
Sets the minimum and maximum allowed value for any value of this prompt field.
Calling this method is only allowed if "use range" is activated for this PromptField. This can be activated by calling setUseRange(boolean). Passing null as a minimum or maximum value has the effect that no such limit is set. This makes it possible to limit values with an open interval.

Parameters:
min - The minimum value that a prompt value can assume, or null if no minimum is to be set
max - The maximum value that a prompt value can assume, or null if no maximum is to be set
Throws:
ReportException - will be thrown if:
- value type is unknown or boolean
- value does not match value type
- range is disabled
- max is less than min
See Also:
getMinRangeValue(), getMaxRangeValue(), getUseRange(), setUseRange(boolean)

getMinRangeValue

public java.lang.Object getMinRangeValue()
                                  throws ReportException
If property 'use range' is enabled this method returns the minimum value for an prompt value.

Returns:
The return value can in according to property 'value type' either be a java.lang.Number, a java.sql.Date, a java.sql.Time or a java.sql.Timestamp. Note that this can also return null if there is no minimum limit.
Throws:
ReportException - will be thrown if value type is boolean, value does not match value type or if range is disabled.
See Also:
getMaxRangeValue(), setMinMaxRangeValues(java.lang.Object, java.lang.Object), getUseRange(), setUseRange(boolean)

getMaxRangeValue

public java.lang.Object getMaxRangeValue()
                                  throws ReportException
If property 'use range' is enabled this method returns the maximum value for an prompt value.

Returns:
The return value can in according to property 'value type' either be a java.lang.Number, a java.sql.Date, a java.sql.Time or a java.sql.Timestamp. Note that null can also be returned if there is no maximum limit.
Throws:
ReportException - will be thrown if value type is boolean, value does not match value type or if range is disabled.
See Also:
getMinRangeValue(), setMinMaxRangeValues(java.lang.Object, java.lang.Object), getUseRange(), setUseRange(boolean)

setPromptValueDescriptions

public void setPromptValueDescriptions(java.lang.String[] descr)
Sets the descriptions of the default values of this prompt field.

Parameters:
descr - a String[] which contains the descriptions of the default values.
Throws:
java.lang.IllegalArgumentException - if the description array's length does not match getDefaultValueCount().
java.lang.NullPointerException - if the array is null
See Also:
getDefaultValueCount()

getPromptValueDescriptions

public java.lang.String[] getPromptValueDescriptions()
Returns the array of the value descriptions of the default values of this prompt field, which are shown to the user when prompting.

Returns:
a String[] which contains the descriptions
Since:
7.0

getValueType

public int getValueType()
Returns the value type (or return type) of the field.
NOTE:If DefaultAttribute is used within the formula it has to be set before calling this method. A null-value will cause an exception here. If you don't know the exact value of the DefaultAttribute you may use a dummy-value for getValueType. The reason is that getValueType only regards the type of object not their value.

Overrides:
getValueType in class Field
Returns:
The value of the property 'value type'.
See Also:
Field.NUMBER, Field.CURRENCY, Field.BOOLEAN, Field.DATE, Field.TIME, Field.STRING, Field.DATETIME

paramString

public java.lang.String paramString()
Returns a prettified output of this field's name and type.

Overrides:
paramString in class Field
Returns:
Prettified output of this field's name and type.

getPromptValueAsFormula

public java.lang.String getPromptValueAsFormula()
Get the set value of this prompt as a formula. In order to instead get the default value(s) of this prompt as a formula string, use getDefaultPromptValuesAsString().

Returns:
the formula string of the set values for this prompt.

setDefaultValueProvider

public void setDefaultValueProvider(DynamicValueProvider provider)
Sets the DynamicValueProvider which will dynamically create values for the default values at run-time. Setting null will cause this setting to be removed.

Parameters:
provider - Provider class which supplies the necessary default values at run-time.
Throws:
java.lang.IllegalArgumentException - if the given provider is a CascadingValueProvider which causes circular dependency.
Since:
7.6
See Also:
getDefaultValueProvider()

getDefaultValueProvider

public DynamicValueProvider getDefaultValueProvider()
If a DynamicValueProvider has been set for this PromptField, this method will return this provider.

Returns:
DynamicValueProvider which will dynamically provide default values for this prompt at run-time, or null if no such provider has been set.
Since:
7.6
See Also:
setDefaultValueProvider(DynamicValueProvider)

getDefaultValues

public DefaultValue[] getDefaultValues()
Fetches the default values. If a dynamic provider has been set, this will cause the provider to generate the default values.

Returns:
default values for this prompt (can be null if none are set)
Since:
7.6

setDefaultValues

public void setDefaultValues(DefaultValue[] values)
Sets the default values for this prompt. All values must have the correct type and also must be within the range if one has been set, otherwise an IllegalArgumentException will be thrown.

Note that this will have the effect of removing a DynamicValueProvider if one has been specified.

Parameters:
values - default values to set, null if none are to be set
Throws:
java.lang.IllegalArgumentException - if one of the values is not the correct value type or is outside of a given allowed range
java.lang.UnsupportedOperationException - if this is a password prompt field and one or more default values is to be set, since password prompt fields can not have default values.
Since:
7.6
See Also:
setUseRange(boolean), setMinMaxRangeValues(Object, Object), DefaultValue.DefaultValue(Object, String)

getDefaultPromptValuesAsString

public java.lang.String getDefaultPromptValuesAsString()
Returns the default values for this prompt as formula syntax, i.e. as an array if there are multiple default prompt values. It is recommended to use getDefaultValues() instead.

Returns:
Default values as a single formula string.

addDefaultValue

public void addDefaultValue(DefaultValue value)
Adds a single default value to the end of the default value list. Note that calling this will remove any DefaultValueProvider you may have set.

Parameters:
value - default value to add to the list of default values for this prompt
Throws:
java.lang.IllegalArgumentException - if the default value could not be set because of the value was outside a set range.
java.lang.UnsupportedOperationException - if this is a password prompt field, since password prompt fields can not have default values
Since:
7.6

removeDefaultValue

public void removeDefaultValue(int index)
Removes the default prompt value and its description at the given index from the default value list. Shifts any subsequent default values to the left. If no default values are left, the default value list will be null.

Parameters:
index - Index of default value to remove from the list
Throws:
java.lang.IndexOutOfBoundsException - If the index is less than 0 or greater than or equal to the size of the list.
Since:
7.0
See Also:
addDefaultValue(DefaultValue), getDefaultValueCount(), getDefaultValue(int)

getDefaultValueCount

public int getDefaultValueCount()
Returns The number of default values set for this prompt. 0 if none are set.

Returns:
The number of default values set for this prompt. 0 if none are set.
Since:
7.0

setDefaultValue

public void setDefaultValue(int index,
                            DefaultValue defaultValue)
Overrides a single default value at the given index.

Parameters:
index - index of the default value to place. This index is 0-based and must specify an already existing default value
defaultValue - default value to replace the specified default value with.
Throws:
java.lang.IllegalArgumentException - if the value was outside a set range.
java.lang.IndexOutOfBoundsException - if the index is less than 0 or greater or equal to the number of default values.
Since:
7.6
See Also:
getDefaultValueCount()

getValue

public java.lang.Object getValue()
Returns the prompt value. If the prompt value is multi-value prompt, you can cast it to an Object[]. For example
 //get prompt value, where f is the referenz to a PromptField - instance
 Object val = f.getPromptValue();
 if (val instanceof Object[]) {
     //get single value and print it to stdout. val0 can be,
     //i.e. a NUMBER etc. or a FormulaRange that holds two NUMBERs if prompt value type is NUMBER
     Object val0 = ((Object[])val)[0];
     System.out.println(val0);
 }
 
The returned Object or in matter of case each field of the returned Object-array can either be

Returns:
The actually set value for this prompt.
Since:
7.0
See Also:
Field.NUMBER, Field.CURRENCY, Field.BOOLEAN, Field.DATE, Field.TIME, Field.DATETIME, Field.STRING, FormulaRange, setPromptValue(java.lang.Object), setPromptValueAsFormula(java.lang.String), getValuesCount()

isParameterOfStoredProcedure

public boolean isParameterOfStoredProcedure()
Returns whether this prompt field works as an input parameter for a stored procedure.

Returns:
True, if it is a input parameter of a stored procedure otherwise false.

getTableSources

public TableSource[] getTableSources()
Returns the table sources this prompt field is a parameter for. This can be either stored procedures or views with parameters. If the prompt is not a parameter for a database object null will be returned.

Returns:
The TableSources this prompt field is a parameter for or null if this prompt field is not a parameter for a database object.
Since:
6.5

isSubreportLink

public boolean isSubreportLink()
Returns whether this prompt is in a subreport and links to the main report.

Returns:
Whether this prompt is in a subreport and links to the main report.
Since:
6.5

isUsed

public boolean isUsed()
FOR INTERNAL USE ONLY


getDefaultValue

public DefaultValue getDefaultValue(int i)
Returns the default value at the given index.

Parameters:
i - index of desired default value
Returns:
default value specified by the index
Throws:
java.lang.IndexOutOfBoundsException - if the index is less than 0 or greater than the number of default values
Since:
7.6
See Also:
getDefaultValueCount()

saveFieldXML2

protected void saveFieldXML2(java.io.PrintWriter pw,
                             int depth)
Saves PromptField attributes

Parameters:
pw - the printwriter.
depth - the current depth.
Since:
8.1

duplicate

public Field duplicate(java.lang.String name)
Duplicates this field with all its settings and returns the created Field with the given name. Note that the new formula field will not initially be referenced by any other report objects. If you duplicate a property formula, you will have to set the new formula as a separate property formula.

Overrides:
duplicate in class Field
Parameters:
name - the name the created field should have.
Returns:
the duplicated field.

i-net Clear Reports

Copyright © 1999-2011 by i-net software GmbH