public class PromptField extends Field implements com.inet.report.ReferenceHolder
//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());
}
Modifier and Type | Field and Description |
---|---|
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.
|
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
Modifier and Type | Method and Description |
---|---|
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.
|
java.lang.String[] |
getStoredProceduresParameterNames()
Returns the names of the stored procedures parameters.
|
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 |
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.
|
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.
|
void |
setValueType(int newValue)
Sets the value of the property 'value type'.
|
checkNameExists, extractReference, getField, getGroup, getName, getPlaceholderName, getRefName, getType, indexOf, setField, setGroup, trimAwayBrackets
isDOMParser, parseDOM, parseElement, parseEndElement, parseText
public static final int DISCRETE_VALUE
public static final int RANGE_VALUE
public static final int DISCRETE_AND_RANGE_VALUE
public final void setName(java.lang.String name)
public final java.lang.String getPromptText()
setPromptText(java.lang.String)
public final void setPromptText(java.lang.String promptText)
promptText
- the prompting text, can be null for no textgetPromptText()
public final java.lang.Object getPromptValue()
setPromptValue(Object)
or by entering a value in the prompt dialog), this will return the value set for this PromptField.NUMBER
- java.lang.Number
CURRENCY
- java.lang.Number
BOOLEAN
- java.lang.Boolean
DATE
- java.sql.Date
TIME
- java.sql.Time
DATETIME
- java.sql.Timestamp
STRING
- java.lang.String
Range
- com.inet.report.FormulaRange
.Field.NUMBER
,
Field.CURRENCY
,
Field.BOOLEAN
,
Field.DATE
,
Field.TIME
,
Field.DATETIME
,
Field.STRING
,
FormulaRange
,
setPromptValue(java.lang.Object)
,
setPromptValueAsFormula(java.lang.String)
,
getValuesCount()
public final void setPromptValue(java.lang.Object prompt) throws ReportException
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 rangesReportException
- 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.Field.NUMBER
,
Field.CURRENCY
,
Field.BOOLEAN
,
Field.DATE
,
Field.TIME
,
Field.DATETIME
,
Field.STRING
,
FormulaRange
,
getPromptValue()
,
setPromptValueAsFormula(java.lang.String)
,
getValuesCount()
,
setDefaultValues(DefaultValue[])
public void setPromptValueAsFormula(java.lang.String formula) throws ReportException
formula
- Value to set for this prompt, as a formula in Crystal syntaxReportException
- 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.Engine.setPrompt(String, int)
,
getPromptValue()
,
setPromptValue(java.lang.Object)
,
getValuesCount()
public final int getPromptType()
NUMBER
CURRENCY
BOOLEAN
DATE
TIME
DATETIME
STRING
BINARY
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)
public final void setPromptType(int valueType)
NUMBER
CURRENCY
BOOLEAN
DATE
TIME
DATETIME
STRING
BINARY
valueType
- Value type for this prompt fieldjava.lang.IllegalArgumentException
- will thrown if the value type not equals the the field type.Field.NUMBER
,
Field.CURRENCY
,
Field.BOOLEAN
,
Field.DATE
,
Field.TIME
,
Field.DATETIME
,
Field.STRING
,
Field.BINARY
,
getPromptType()
public final void setUseRange(boolean newValue)
newValue
- True if the prompt values must be within a range of values.setMinMaxRangeValues(java.lang.Object, java.lang.Object)
,
getMaxRangeValue()
,
getMinRangeValue()
,
getUseRange()
public final boolean getUseRange()
setMinMaxRangeValues(java.lang.Object, java.lang.Object)
,
getMaxRangeValue()
,
getMinRangeValue()
,
setUseRange(boolean)
public final void setDescriptionOnly(boolean descOnly)
descOnly
- Should only the descriptions of the default values be shown when prompting for this field?public final boolean isDescriptionOnly()
public final void setEditable(boolean isEditable)
isEditable
- Should other values than the default values be accepted as valid values for this prompt field?java.lang.UnsupportedOperationException
- if isEditable is false and this is a password field, since password fields must be editable.public final boolean isEditable()
public boolean isValueSet()
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.setPromptValue(Object)
public final boolean isPasswordField()
public final void setPasswordField(boolean isPasswordField)
isPasswordField
- Is this prompt field to be treated as a password field?public void setDiscreteOrRangeType(int newValue) throws java.lang.IllegalArgumentException
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)
.newValue
- The new value of the property 'discrete or range type'.java.lang.IllegalArgumentException
- 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
DISCRETE_AND_RANGE_VALUE
,
DISCRETE_VALUE
,
setAllowMultipleValues(boolean)
,
getAllowMultipleValues()
,
getDiscreteOrRangeType()
,
setUseRange(boolean)
,
getUseRange()
public int getDiscreteOrRangeType()
DISCRETE_VALUE
,
RANGE_VALUE
,
DISCRETE_AND_RANGE_VALUE
,
setDiscreteOrRangeType(int)
,
setUseRange(boolean)
,
getUseRange()
,
setAllowMultipleValues(boolean)
,
getAllowMultipleValues()
public void setAllowMultipleValues(boolean newValue)
newValue
- true
if multiple values should be able to be entered for this prompt.java.lang.UnsupportedOperationException
- if newValue is true and this field is a password prompt fieldgetAllowMultipleValues()
,
getDiscreteOrRangeType()
,
setDiscreteOrRangeType(int)
public boolean getAllowMultipleValues()
true
if multiple values can be passed to this prompt.setAllowMultipleValues(boolean)
public int getValuesCount()
setPromptValue(java.lang.Object)
,
setPromptValueAsFormula(java.lang.String)
,
getPromptValue()
,
getAllowMultipleValues()
,
setAllowMultipleValues(boolean)
public void setMinRangeValue(java.lang.Object min) throws ReportException
setUseRange(boolean)
.min
- The minimum value that a prompt value can assume, or null if no minimum is to be setReportException
- will thrown if:java.lang.IllegalStateException
- if range is disabled, see setDiscreteOrRangeType(int)
getMinRangeValue()
,
getUseRange()
,
setUseRange(boolean)
public void setMaxRangeValue(java.lang.Object max) throws ReportException
setUseRange(boolean)
.max
- The maximum value that a prompt value can assume, or null if no maximum is to be setReportException
- will thrown if:java.lang.IllegalStateException
- if range is disabled, see setDiscreteOrRangeType(int)
getMaxRangeValue()
,
getUseRange()
,
setUseRange(boolean)
public void setMinMaxRangeValues(java.lang.Object min, java.lang.Object max) throws ReportException
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.
min
- The minimum value that a prompt value can assume, or null if no minimum is to be setmax
- The maximum value that a prompt value can assume, or null if no maximum is to be setReportException
- will be thrown if:getMinRangeValue()
,
getMaxRangeValue()
,
getUseRange()
,
setUseRange(boolean)
public java.lang.Object getMinRangeValue() throws ReportException
ReportException
- will be thrown if value type is boolean, value does not match value type or if range is disabled.getMaxRangeValue()
,
setMinMaxRangeValues(java.lang.Object, java.lang.Object)
,
getUseRange()
,
setUseRange(boolean)
public java.lang.Object getMaxRangeValue() throws ReportException
ReportException
- will be thrown if value type is boolean, value does not match value type or if range is disabled.getMinRangeValue()
,
setMinMaxRangeValues(java.lang.Object, java.lang.Object)
,
getUseRange()
,
setUseRange(boolean)
public void setPromptValueDescriptions(java.lang.String[] descr)
descr
- a String[] which contains the descriptions of the default values.java.lang.IllegalArgumentException
- if the description array's length does not match getDefaultValueCount().java.lang.NullPointerException
- if the array is nullgetDefaultValueCount()
public java.lang.String[] getPromptValueDescriptions()
public void setValueType(int newValue)
setValueType
in class Field
newValue
- The new value of the property 'value type'.Field.NUMBER
,
Field.CURRENCY
,
Field.BOOLEAN
,
Field.DATE
,
Field.TIME
,
Field.STRING
,
Field.DATETIME
,
Field.CURSOR
,
Field.BINARY
public int getValueType()
getValueType
in class Field
Field.NUMBER
,
Field.CURRENCY
,
Field.BOOLEAN
,
Field.DATE
,
Field.TIME
,
Field.STRING
,
Field.DATETIME
public java.lang.String paramString()
paramString
in class Field
public java.lang.String getPromptValueAsFormula()
getDefaultPromptValuesAsString()
.public void setDefaultValueProvider(DynamicValueProvider provider)
provider
- Provider class which supplies the necessary default values at run-time.java.lang.IllegalArgumentException
- if the given provider is a CascadingValueProvider
which causes circular dependency.getDefaultValueProvider()
public DynamicValueProvider getDefaultValueProvider()
setDefaultValueProvider(DynamicValueProvider)
public DefaultValue[] getDefaultValues()
public void setDefaultValues(DefaultValue[] values)
Note that this will have the effect of removing a DynamicValueProvider if one has been specified.
values
- default values to set, null if none are to be setjava.lang.IllegalArgumentException
- if one of the values is not the correct value type or is outside of a given allowed rangejava.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.setUseRange(boolean)
,
setMinMaxRangeValues(Object, Object)
,
DefaultValue.DefaultValue(Object, String)
public java.lang.String getDefaultPromptValuesAsString()
getDefaultValues()
instead.public void addDefaultValue(DefaultValue value)
value
- default value to add to the list of default values for this promptjava.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 valuespublic void removeDefaultValue(int index)
index
- Index of default value to remove from the listjava.lang.IndexOutOfBoundsException
- If the index is less than 0 or greater than or equal to the size of the list.addDefaultValue(DefaultValue)
,
getDefaultValueCount()
,
getDefaultValue(int)
public int getDefaultValueCount()
public void setDefaultValue(int index, DefaultValue defaultValue)
index
- index of the default value to place. This index is 0-based and must specify an already existing default valuedefaultValue
- default value to replace the specified default value with.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.getDefaultValueCount()
public java.lang.Object getValue()
//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
NUMBER
for java.lang.Number
CURRENCY
for java.lang.Number
BOOLEAN
for java.lang.Boolean
DATE
for java.sql.Date
TIME
for java.sql.Time
DATETIME
for java.sql.Timestamp
STRING
for java.lang.String
FormulaRange
for a range of values.Field.NUMBER
,
Field.CURRENCY
,
Field.BOOLEAN
,
Field.DATE
,
Field.TIME
,
Field.DATETIME
,
Field.STRING
,
FormulaRange
,
setPromptValue(java.lang.Object)
,
setPromptValueAsFormula(java.lang.String)
,
getValuesCount()
public boolean isParameterOfStoredProcedure()
public TableSource[] getTableSources()
null
will be returned.null
if this prompt field is not a parameter for a database object.public java.lang.String[] getStoredProceduresParameterNames()
null
will be returned.null
if this prompt field is not a parameter for a database object.public boolean isSubreportLink()
public DefaultValue getDefaultValue(int i)
i
- index of desired default valuejava.lang.IndexOutOfBoundsException
- if the index is less than 0 or greater than the number of default valuesgetDefaultValueCount()
public Field duplicate(java.lang.String name)
Copyright © 1999-2020 by i-net software GmbH