|
i-net Clear Reports | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.inet.report.Field
com.inet.report.PromptField
public class PromptField
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());
}
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 |
|---|
public static final int DISCRETE_VALUE
public static final int RANGE_VALUE
public static final int DISCRETE_AND_RANGE_VALUE
| Method Detail |
|---|
public final void setName(java.lang.String name)
setName in class Fieldname - Name to be assigned to this prompt field
java.lang.IllegalArgumentException - if the name already existspublic 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.NumberCURRENCY - java.lang.NumberBOOLEAN - java.lang.BooleanDATE - java.sql.DateTIME - java.sql.TimeDATETIME - java.sql.TimestampSTRING - java.lang.StringRange - 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 CURRENCYjava.lang.Boolean for value type BOOLEANjava.sql.Date for value type DATEjava.sql.Time for value type TIMEjava.sql.Timestamp for value type DATETIMEjava.lang.String for value type STRINGcom.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 syntax
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.Engine.setPrompt(String, int),
getPromptValue(),
setPromptValue(java.lang.Object),
getValuesCount()public final int getPromptType()
NUMBERCURRENCYBOOLEANDATETIMEDATETIMESTRINGBINARY
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)
NUMBERCURRENCYBOOLEANDATETIMEDATETIMESTRINGBINARY
valueType - Value type for this prompt field
java.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 ReportException
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'.
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_VALUEDISCRETE_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 set
ReportException - 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 set
ReportException - 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 set
ReportException - 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 int getValueType()
getValueType in class FieldField.NUMBER,
Field.CURRENCY,
Field.BOOLEAN,
Field.DATE,
Field.TIME,
Field.STRING,
Field.DATETIMEpublic java.lang.String paramString()
paramString in class Fieldpublic 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 set
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.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 prompt
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 valuespublic void removeDefaultValue(int index)
index - Index of default value to remove from the list
java.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.NumberCURRENCY for java.lang.NumberBOOLEAN for java.lang.BooleanDATE for java.sql.DateTIME for java.sql.TimeDATETIME for java.sql.TimestampSTRING for java.lang.StringFormulaRange 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 boolean isSubreportLink()
public boolean isUsed()
public DefaultValue getDefaultValue(int i)
i - index of desired default value
java.lang.IndexOutOfBoundsException - if the index is less than 0 or greater than the number of default valuesgetDefaultValueCount()
protected void saveFieldXML2(java.io.PrintWriter pw,
int depth)
pw - the printwriter.depth - the current depth.public Field duplicate(java.lang.String name)
duplicate in class Fieldname - the name the created field should have.
|
i-net Clear Reports | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||