i-net Clear Reports

com.inet.report
Class FieldValueProvider

java.lang.Object
  extended by com.inet.report.SQLValueProvider
      extended by com.inet.report.FieldValueProvider
All Implemented Interfaces:
CascadingSource, DynamicValueProvider, NodeParser, java.io.Serializable
Direct Known Subclasses:
CascadingValueProvider

public class FieldValueProvider
extends SQLValueProvider
implements CascadingSource

The FieldValueProvider takes one or two DatabaseFields and at run time provides the values in the fields as default values. The first DatabaseField is used to fetch the values and the second is used to fetch the default values.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.inet.report.SQLValueProvider
MAX_RECORDS
 
Constructor Summary
FieldValueProvider(DatabaseField values, DatabaseField descriptions, int sortType)
          Creates a FieldValueProvider with the given DatabaseFields.
 
Method Summary
 Datasource getDatasource()
          Returns the data source the query is to be run on
 DatabaseField getDescriptions()
          Returns the DatabaseField responsible for fetching the descriptions from.
 java.lang.String getFieldRefName()
          Returns the name to be used as the SQL reference name in the WHERE part of the query used by a cascading prompt referencing this as its parent.
protected  java.lang.String getSQL(java.lang.String where)
          Returns the query to be used, using the given String as its WHERE condition
 java.lang.String getSQL()
          Returns the query which is to be used for fetching the values and optionally descriptions dynamically.
 int getSortType()
          Returns the SortField constant specifying how the values are to be sorted.
 DatabaseField getValues()
          Returns the DatabaseField responsible for fetching the values from.
 NodeParser parseElement(com.inet.report.parser.XMLTag group, java.lang.String tag, org.xml.sax.Attributes atts, java.util.Map parserMap)
          Internal method for reading report XML Parses an XML node with the given information, and returns either a sub-element which was created as a result, or null if no sub-element was created, i.e. the information was applied to the ReportComponent itself.
 void setDatasource(Datasource datasource)
          Sets the datasource to run the query on.
 void setDescriptions(DatabaseField descriptions)
          Sets the description DatabaseField.
 void setSortType(int sortType)
          Sets the sort type, specifying how the values are to be sorted.
 void setValues(DatabaseField values)
          Sets the DatabaseField for fetching the values from.
 
Methods inherited from class com.inet.report.SQLValueProvider
getDefaultValues
 
Methods inherited from interface com.inet.report.parser.NodeParser
isDOMParser, parseDOM, parseEndElement, parseText
 

Constructor Detail

FieldValueProvider

public FieldValueProvider(DatabaseField values,
                          DatabaseField descriptions,
                          int sortType)
Creates a FieldValueProvider with the given DatabaseFields.

Parameters:
values - DatabaseField to use to fetch the values. Must not be null.
descriptions - DatabaseField to use to fetch the descriptions. May be null. If not, it must be a String field and its Tablesource must be the same as the values' TableSource
sortType - The SortField constant to specify how the values are to be sorted.
Throws:
java.lang.IllegalArgumentException - if values is null, or the table sources of the two fields are not the same or the table source comes from an SQL query
See Also:
SortField.ASCENDING_ORDER, SortField.DESCENDING_ORDER, SortField.ORIGINAL_ORDER
Method Detail

getSQL

protected java.lang.String getSQL(java.lang.String where)
Returns the query to be used, using the given String as its WHERE condition

Parameters:
where - WHERE condition to use. If no WHERE condition is to be used, use an empty string.
Returns:
Query to be used for this FieldValueProvider.

getSQL

public java.lang.String getSQL()
Returns the query which is to be used for fetching the values and optionally descriptions dynamically.

Specified by:
getSQL in class SQLValueProvider
Returns:
query to be used

getSortType

public int getSortType()
Returns the SortField constant specifying how the values are to be sorted.

Returns:
sorting type for the fields
See Also:
SortField.ASCENDING_ORDER, SortField.DESCENDING_ORDER, SortField.ORIGINAL_ORDER

setSortType

public void setSortType(int sortType)
Sets the sort type, specifying how the values are to be sorted.

Parameters:
sortType - SortField constant specifying how to sort the values.
See Also:
SortField.ASCENDING_ORDER, SortField.DESCENDING_ORDER, SortField.ORIGINAL_ORDER

getDescriptions

public DatabaseField getDescriptions()
Returns the DatabaseField responsible for fetching the descriptions from. Can be null if no descriptions are to be fetched.

Returns:
DatabaseField for the descriptions

setDescriptions

public void setDescriptions(DatabaseField descriptions)
Sets the description DatabaseField. If this is null, it means there are to be no descriptions. If not null, it must come from the same Datasource and TableSource as the values DatabaseField

Parameters:
descriptions - DatabaseField for the descriptions

getValues

public DatabaseField getValues()
Returns the DatabaseField responsible for fetching the values from. Will never be null

Returns:
DatabaseField for the values.

setValues

public void setValues(DatabaseField values)
Sets the DatabaseField for fetching the values from. May not be null, and its Datasource and TableSource must be equal to those of the descriptions' field if there is one.

Parameters:
values - DatabaseField for the values
Throws:
java.lang.IllegalArgumentException - if values is null or its table source does not match the description field's table source

getDatasource

public Datasource getDatasource()
Returns the data source the query is to be run on

Specified by:
getDatasource in class SQLValueProvider
Returns:
data source to use

setDatasource

public void setDatasource(Datasource datasource)
Sets the datasource to run the query on.

Parameters:
datasource - data source to run the query on.
Throws:
java.lang.IllegalArgumentException - if datasource is null

getFieldRefName

public java.lang.String getFieldRefName()
Returns the name to be used as the SQL reference name in the WHERE part of the query used by a cascading prompt referencing this as its parent. The WHERE part of the SQL query will resemble something like "WHERE (reference name = prompt value)".

Specified by:
getFieldRefName in interface CascadingSource
Returns:
Reference name of the parent source for a cascading prompt
See Also:
CascadingValueProvider, SQLValueProvider

parseElement

public NodeParser parseElement(com.inet.report.parser.XMLTag group,
                               java.lang.String tag,
                               org.xml.sax.Attributes atts,
                               java.util.Map parserMap)
                        throws FatalParserException
Internal method for reading report XML

Parses an XML node with the given information, and returns either a sub-element which was created as a result, or null if no sub-element was created, i.e. the information was applied to the ReportComponent itself. Note that the parsing is highly tolerant, i.e. exceptions are intercepted and suppressed if at all possible.

Specified by:
parseElement in interface NodeParser
Parameters:
group - XMLTag of the current node to be parsed, or null if there is no such current group. An XMLTag is a group of nodes bundled together, usually it is a Properties node such as CommonProperties, BorderProperties, etc.
tag - The XMLTag to be parsed
atts - The set of attributes in the current XMLTag
parserMap - The map of current Parser.
Returns:
The NodeParser sub-element if one needed to be created, or null if none was created.
Throws:
FatalParserException - if an exception occurs which causes the report to not be able to be read: causes the abortion of the reading of the report.

i-net Clear Reports

Copyright © 1999-2011 by i-net software GmbH