Class MapIndirectExpression
- java.lang.Object
-
- org.pentaho.reporting.engine.classic.core.function.AbstractExpression
-
- org.pentaho.reporting.engine.classic.core.function.strings.MapIndirectExpression
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Expression
public class MapIndirectExpression extends AbstractExpression
Returns the value read from a mapped field. The field's value is used as a key to the field-mapping. The expression maps the value into a new column name and returns the value read from this column. If the mapping does not exist, then the fallback forward is used instead.- Author:
- Thomas Morgner
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MapIndirectExpression()
Default Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getFallbackForward()
Returns the name of the field that is returned if none of the predefined keys matches the lookup-value.String
getField()
Returns the name of the field from where to read the key value.String[]
getForward()
Returns all forward-definitions as string-array.String
getForward(int index)
Retrieves the forward-fieldname for the key at the given position.int
getForwardCount()
Returns the number of forward-definitions that have been defined.Expression
getInstance()
Return a completly separated copy of this function.String[]
getKey()
Returns all defined keys as string array.String
getKey(int index)
Returns a key value at the given index.int
getKeyCount()
Returns the number of keys defined in the expression.String
getNullValue()
Returns the value that is returned if the key-field evaluates tonull
.Object
getValue()
Performs the lookup by first querying the given field, and then mapping the retrived value into one of the field names.boolean
isIgnoreCase()
Returns, whether the key-lookup should be case-insensitive.void
setFallbackForward(String fallbackForward)
Defines the name of the field that is returned if none of the predefined keys matches the lookup-value.void
setField(String field)
Defines the name of the field from where to read the key value.void
setForward(int index, String value)
Defines the forward-fieldname for the key at the given position.void
setForward(String[] forwards)
Defiens all forward-definitions using the values of the string-array.void
setIgnoreCase(boolean ignoreCase)
Defines, whether the key-lookup should be case-insensitive.void
setKey(int index, String key)
Defines a key value to which the lookup-field's value is compared.void
setKey(String[] keys)
Defines all keys using the values from the string array.void
setNullValue(String nullValue)
Defines the value that is returned if the key-field evaluates tonull
.-
Methods inherited from class org.pentaho.reporting.engine.classic.core.function.AbstractExpression
clone, getDataRow, getDependencyLevel, getName, getReportConfiguration, getResourceBundleFactory, getRuntime, isActive, isDeepTraversing, isPreserve, setActive, setDependencyLevel, setName, setPreserve, setRuntime
-
-
-
-
Method Detail
-
getField
public String getField()
Returns the name of the field from where to read the key value.- Returns:
- the field name.
-
setField
public void setField(String field)
Defines the name of the field from where to read the key value.- Parameters:
field
- the field name.
-
getNullValue
public String getNullValue()
Returns the value that is returned if the key-field evaluates tonull
.- Returns:
- the null-value.
-
setNullValue
public void setNullValue(String nullValue)
Defines the value that is returned if the key-field evaluates tonull
.- Parameters:
nullValue
- the null-value.
-
getFallbackForward
public String getFallbackForward()
Returns the name of the field that is returned if none of the predefined keys matches the lookup-value.- Returns:
- the fallback forward field name.
-
setFallbackForward
public void setFallbackForward(String fallbackForward)
Defines the name of the field that is returned if none of the predefined keys matches the lookup-value.- Parameters:
fallbackForward
- the fallback forward field name.
-
setKey
public void setKey(int index, String key)
Defines a key value to which the lookup-field's value is compared. If the key is defined, a matching value must be defined too.- Parameters:
index
- the index position of the key in the list.key
- the key value.
-
getKey
public String getKey(int index)
Returns a key value at the given index.- Parameters:
index
- the index position of the key in the list.- Returns:
- the key value.
-
getKeyCount
public int getKeyCount()
Returns the number of keys defined in the expression.- Returns:
- the number of keys.
-
getKey
public String[] getKey()
Returns all defined keys as string array.- Returns:
- all defined keys.
-
setKey
public void setKey(String[] keys)
Defines all keys using the values from the string array.- Parameters:
keys
- all defined keys.
-
setForward
public void setForward(int index, String value)
Defines the forward-fieldname for the key at the given position. The forward-field is read, if the lookup value matches the key at this position. The forward-value must be a valid data-row column name.- Parameters:
index
- the index of the entry.value
- the name of the datarow-column that is read if the key is selected.
-
getForward
public String getForward(int index)
Retrieves the forward-fieldname for the key at the given position. The forward-field is read, if the lookup value matches the key at this position. The forward-value must be a valid data-row column name.- Parameters:
index
- the index of the entry.- Returns:
- the name of the datarow-column that is read if the key is selected.
-
getForwardCount
public int getForwardCount()
Returns the number of forward-definitions that have been defined. This should match the number of keys.- Returns:
- the number of forward definitions.
-
getForward
public String[] getForward()
Returns all forward-definitions as string-array.- Returns:
- all forward-definitions.
-
setForward
public void setForward(String[] forwards)
Defiens all forward-definitions using the values of the string-array. The positions in the array must match the key positions, or funny things will happen.- Parameters:
forwards
- the forward-name array.
-
isIgnoreCase
public boolean isIgnoreCase()
Returns, whether the key-lookup should be case-insensitive.- Returns:
- true, if the key comparison is case-insensitive, false otherwise.
-
setIgnoreCase
public void setIgnoreCase(boolean ignoreCase)
Defines, whether the key-lookup should be case-insensitive.- Parameters:
ignoreCase
- true, if the key comparison is case-insensitive, false otherwise.
-
getInstance
public Expression getInstance()
Return a completly separated copy of this function. The copy does no longer share any changeable objects with the original function.- Specified by:
getInstance
in interfaceExpression
- Overrides:
getInstance
in classAbstractExpression
- Returns:
- a copy of this function.
-
getValue
public Object getValue()
Performs the lookup by first querying the given field, and then mapping the retrived value into one of the field names.- Returns:
- the value of the function.
-
-