Example usage for javax.el Expression getExpressionString

List of usage examples for javax.el Expression getExpressionString

Introduction

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

Prototype

public abstract String getExpressionString();

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 ww.ja va 2s.  c o  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;
}