Example usage for javax.el Expression isLiteralText

List of usage examples for javax.el Expression isLiteralText

Introduction

In this page you can find the example usage for javax.el Expression isLiteralText.

Prototype

public abstract boolean isLiteralText();

Source Link

Usage

From source file:org.rhq.core.gui.model.PagedDataModel.java

/**
 * Convert RichFaces SortField2s to RHQ OrderingFields.
 *
 * @param sortFields the SortField2s to be converted
 *
 * @return the equivalent RHQ OrderingFields
 *//*w  w w . j a v a  2 s.co m*/
private List<OrderingField> toOrderingFields(List<SortField2> sortFields) {
    if (sortFields == null) {
        sortFields = Collections.emptyList();
    }
    List<OrderingField> orderingFields = new ArrayList<OrderingField>(sortFields.size());
    for (SortField2 sortField : sortFields) {
        Expression expression = sortField.getExpression();
        String expressionString = expression.getExpressionString();
        String field;
        if (expression.isLiteralText()) {
            field = expressionString;
        } else {
            field = expressionString.replaceAll("[#|$]\\{", "").replaceAll("\\}", "");
        }
        Ordering ordering = sortField.getOrdering();
        PageOrdering pageOrdering = (ordering == Ordering.ASCENDING) ? PageOrdering.ASC : PageOrdering.DESC;
        OrderingField orderingField = new OrderingField(field, pageOrdering);
        orderingFields.add(orderingField);
    }
    return orderingFields;
}