| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 // Utility class used for sorting spreadsheet columns | |
| 6 class IndexedValue { | |
| 7 // Sort numbers, followed by non-blank strings, followed by blanks | |
| 8 static final int NUMBER = 0; | |
| 9 static final int STRING = 1; | |
| 10 static final int BLANK = 2; | |
| 11 | |
| 12 int _class; | |
| 13 double _dValue; | |
| 14 int _index; | |
| 15 String _sValue; | |
| 16 | |
| 17 int get index() => _index; | |
| 18 | |
| 19 IndexedValue.blank(this._index) { | |
| 20 _class = BLANK; | |
| 21 } | |
| 22 | |
| 23 IndexedValue.number(this._index, this._dValue) { | |
| 24 _class = NUMBER; | |
| 25 } | |
| 26 | |
| 27 IndexedValue.string(this._index, this._sValue) { | |
| 28 _class = (_sValue == null || _sValue.length == 0) ? BLANK : STRING; | |
| 29 } | |
| 30 | |
| 31 int compareTo(IndexedValue other) { | |
| 32 if (_class < other._class) { | |
| 33 return -1; | |
| 34 } else if (_class > other._class) { | |
| 35 return 1; | |
| 36 } | |
| 37 | |
| 38 if (_class == NUMBER) { | |
| 39 return _dValue < other._dValue ? -1 : (_dValue > other._dValue ? 1 : 0); | |
| 40 } else if (_class == STRING) { | |
| 41 return StringUtils.compare(_sValue, other._sValue); | |
| 42 } | |
| 43 // All blanks are equal | |
| 44 return 0; | |
| 45 } | |
| 46 } | |
| OLD | NEW |