01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14: * License for the specific language governing permissions and limitations
15: * under the License.
16: *
17: */
18:
19: /*
20: * Created on May 25, 2004
21: */
22: package org.apache.jorphan.math;
23:
24: import java.io.Serializable;
25: import java.util.Comparator;
26:
27: /**
28: * @author pete
29: *
30: */
31: public class NumberComparator implements Comparator, Serializable {
32:
33: /**
34: *
35: */
36: public NumberComparator() {
37: super ();
38: }
39:
40: /*
41: * (non-Javadoc)
42: *
43: * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
44: */
45: public int compare(Object val1, Object val2) {
46: Number[] n1 = (Number[]) val1;
47: Number[] n2 = (Number[]) val2;
48: if (n1[0].longValue() < n2[0].longValue()) {
49: return -1;
50: } else if (n1[0].longValue() == n2[0].longValue()) {
51: return 0;
52: } else {
53: return 1;
54: }
55: }
56:
57: }
|