com.businessobjects.rebean.wi
Interface SortInfo


public interface SortInfo

Warning: This interface is no longer functional from the SAP BusinessObjects 4.0 release onwards.

The SortInfo interface gives the way to customise the sort order for a DPExpression, VariableExpression or Link object's values.

A SortInfo instance holds a custom List Of Values containing the sort order Values in the expression instance.

If a customised sort has not been defined by a user, the CustomSortLov is sorted in alphanumerical order.

Note: A custom sort cannot be applied to a FormulaExpression.

Since:
11.5
See Also:
DPExpression.getSortInfo(), VariableExpression.getSortInfo(), Link.getSortInfo(), ReportDictionary, SortInfoType, CustomSortLov, CustomSortValues, FormulaExpression

Method Summary
 boolean canApplyCustomSort()
          Returns true if a custom sort can be applied to the expression instance.
 boolean canHaveUserValues()
          Returns true if user defined values can be added to the CustomSortLov.
 void deleteCustomSort()
          Delete the CustomSortLov defined in the SortInfo instance.
 CustomSortLov getCustomSortLov()
          Returns a custom ordered LOV containing the Values in the expression instance.
 int getMaxValues()
          Returns the maximum number of values that can be contained in the CustomSortLov instance.
 SortInfoType getSortInfoType()
          Returns the sort order currently applied to the expression.
 boolean isCustomSortDefined()
          Returns true if a CustomSortLov has been defined.
 void setCustomSortLov(java.lang.String[] lov)
          Replace the current CustomSortValues by an ordered list of values.
 

Method Detail

getCustomSortLov

CustomSortLov getCustomSortLov()
Returns a custom ordered LOV containing the Values in the expression instance.

If a customised sort has not been defined by a user, the CustomSortLov is sorted in alphanumerical order.

Note: The maximum number of values contained in the returned CustomSortLov is never greater than SortInfo.getMaxValues().

Returns:
A CustomSortLov instance.
Throws:
CustomSortException - when Custom sort isn't defined yet and the retrievec alphanumerical ordered lov size is greater then SortInfo.getMaxValues()
REException - if anything else is wrong.

setCustomSortLov

void setCustomSortLov(java.lang.String[] lov)
                      throws REException
Replace the current CustomSortValues by an ordered list of values.

The new sort order is applied to all SortElement objects based on the expression (DPExpression, VariableExpression, Link) in the current document. User defined values can be added to this LOV if SortInfo.canHaveUserValues() returns true.

Note: The input LOV should hold all of values contained in the default list and be in ascending order.

Example:

 // Variables used in this example are:
 //     doc   - An open DocumentInstance.
 //     rExpr - A DPExpression taken from 'doc'.
 
 SortInfo sort = rExpr.getSortInfo();
 if (sort.canApplyCustomSort())
 {
        CustomSortLov  lov = sort.getCustomSortLov();
        CustomSortValues values = lov.getAllValues();
        String[]   oldList = new String[values.getCount()];
 
        for (int i=0; i < values.getCount(); i++)
        {
                oldList[i] = values.getValue(i);
        }
        // Re-order the values in the list.
        String[]   newList = new String[values.getCount()];
 
        for (int i=0; i < values.getCount(); i++)
        {
                newList[i] = oldList[values.getCount()-i-1];
        }
 
        sort.setCustomSortLov(newList); 
        // new storage token contains the new state of 'doc'.
        String storageToken = doc.getStorageToken();
 }
 

Depending on the type of expression ( DATE, NUMERIC, ...), the values should be in the default format. Retrieve the default format using ReportEngine.getFormatNumbers(FormatNumberType type).

Parameters:
lov - A customized list of values in ascending order.
Throws:
CustomSortException - If lov.length > SortInfo.getMaxValues().
java.lang.UnsupportedOperationException - If SortInfo.canApplyCustomSort() returns false.
java.lang.IllegalArgumentException - if lov is null or lov.length == 0.
REException - Any other problems.
See Also:
ObjectType, ReportExpression.getType()

deleteCustomSort

void deleteCustomSort()
Delete the CustomSortLov defined in the SortInfo instance.

When this method has been called all instance of SortElement based on the expression will be sorted in alphanumeric order.

Throws:
java.lang.IllegalStateException - If the CustomSortLov is still in use.
REException - if anything else is wrong.

isCustomSortDefined

boolean isCustomSortDefined()
Returns true if a CustomSortLov has been defined.

Returns:
Returns true if a CustomSortLov has been defined.

getMaxValues

int getMaxValues()
Returns the maximum number of values that can be contained in the CustomSortLov instance.

Returns:
The maximum number of values that can be contained in the CustomSortLov instance.

canApplyCustomSort

boolean canApplyCustomSort()
Returns true if a custom sort can be applied to the expression instance.

Note: If this SortInfo is from a MEASURE qualified expression or if it's from a DIMENSION qualified expression belongs to a Link, it returns false.

Returns:
Returns true if a custom sort can be applied to the expression instance.
Throws:
CustomSortException - when Custom sort isn't defined yet and the retrieve alphanumerical ordered lov size is greater then SortInfo.getMaxValues()
REException - if anything else is wrong.

canHaveUserValues

boolean canHaveUserValues()
Returns true if user defined values can be added to the CustomSortLov.

Returns:
Returns true if user defined values can be added to the CustomSortLov.
See Also:
CustomSortLov, CustomSortValues

getSortInfoType

SortInfoType getSortInfoType()
Returns the sort order currently applied to the expression.

The sort can be either SortInfoType.ALPHANUMERIC or SortInfoType.CUSTOM.

Returns:
The current sort type, this can be either ALPHANUMERIC or CUSTOM.