01: /*
02: * GWT-Ext Widget Library
03: * Copyright(c) 2007-2008, GWT-Ext.
04: * licensing@gwt-ext.com
05: *
06: * http://www.gwt-ext.com/license
07: */
08: package com.gwtext.client.core;
09:
10: /**
11: * Constants for Sort direction.
12: */
13: public class SortDir {
14:
15: public static SortDir ASC = new SortDir("ASC");
16: public static SortDir DESC = new SortDir("DESC");
17:
18: private String direction;
19:
20: private SortDir(String direction) {
21: this .direction = direction;
22: }
23:
24: public String getDirection() {
25: return direction;
26: }
27:
28: /**
29: * Return the sort dir value based on the passed String direction.
30: *
31: * @param direction the String direction
32: * @return the corresponding SortDir
33: */
34: public static SortDir getValue(String direction) {
35: if (ASC.getDirection().equalsIgnoreCase(direction)) {
36: return ASC;
37: } else if (DESC.getDirection().equalsIgnoreCase(direction)) {
38: return DESC;
39: } else {
40: throw new IllegalArgumentException(
41: "Unrecognized direction value " + direction);
42: }
43: }
44: }
|