Here you can find the source of removeSortColumns(List
public static void removeSortColumns(List<String> selectColumns, List<String> sorts, List<Boolean> ascending)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; public class Main { public static final String AS = " as "; public static void removeSortColumns(List<String> selectColumns, List<String> sorts, List<Boolean> ascending) { List<String> removedSorts = new ArrayList<String>(); for (String sort : sorts) { if (!containsColumnByAlias(selectColumns, sort)) { removedSorts.add(sort);/*from www. ja v a 2 s . com*/ } } for (String sort : removedSorts) { removeSortByColumnName(sorts, ascending, sort); } } public static boolean containsColumnByAlias(List<String> columns, String alias) { for (String column : columns) { if (getColumnAlias(column).equals(alias)) { return true; } } return false; } public static boolean removeSortByColumnName(List<String> sortProperty, List<Boolean> ascending, String columnName) { if (sortProperty == null) { return false; } int index = -1; for (int i = 0, size = sortProperty.size(); i < size; i++) { String sort = sortProperty.get(i); if (sort.equals(columnName)) { index = i; break; } } if (index != -1) { sortProperty.remove(index); ascending.remove(index); } return (index == 0); } public static String getColumnAlias(String fullColumnName) { if (fullColumnName.contains(AS)) { int index = fullColumnName.indexOf(AS); return fullColumnName.substring(index + AS.length()); } else { return fullColumnName; } } }