001    /*
002     * Copyright 2002-2004 the original author or authors.
003     * 
004     * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005     * use this file except in compliance with the License. You may obtain a copy of
006     * the License at
007     * 
008     * http://www.apache.org/licenses/LICENSE-2.0
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012     * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013     * License for the specific language governing permissions and limitations under
014     * the License.
015     */
016    package org.springframework.richclient.table;
017    
018    /**
019     * @author Keith Donald
020     */
021    public class ColumnToSort {
022        private int level;
023    
024        private int columnIndex;
025    
026        private SortOrder sortOrder;
027    
028        public ColumnToSort(int level, int columnIndex) {
029            this.level = level;
030            this.columnIndex = columnIndex;
031            this.sortOrder = SortOrder.ASCENDING;
032        }
033    
034        public ColumnToSort(int level, int columnIndex, SortOrder sortOrder) {
035            this.level = level;
036            this.columnIndex = columnIndex;
037            this.sortOrder = sortOrder;
038        }
039    
040        public int getLevel() {
041            return level;
042        }
043    
044        public int getColumnIndex() {
045            return this.columnIndex;
046        }
047    
048        public SortOrder getSortOrder() {
049            return this.sortOrder;
050        }
051    
052        void setSortOrder(SortOrder sortOrder) {
053            this.sortOrder = sortOrder;
054        }
055    
056        public void toggleSortOrder() {
057            setSortOrder(getSortOrder().flip());
058        }
059    
060        public String toString() {
061            return new StringBuffer("[ColumnToSort level=").append(level).append(", index=").append(columnIndex).append(
062                    ", sortOrder=").append(sortOrder).append("]").toString();
063        }
064    }