Added Pref option to configure for which extensions the internal parser should be...
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / util / StringArrayComparator.java
1 package com.quantum.util;
2
3 import java.util.Comparator;
4
5
6 /**
7  * @author BC
8  */
9 public class StringArrayComparator implements Comparator {
10
11         public int compare(Object arg0, Object arg1) {
12                 return compare((String[]) arg0, (String[]) arg1);
13         }
14
15         public int compare(String[] arg0, String[] arg1) {
16                 if (arg0 == null && arg1 == null) {
17                         return 0;
18                 } else if (arg0 == null) {
19                         return -1;
20                 } else if (arg1 == null) {
21                         return 1;
22                 } else if (arg0.length != arg1.length) {
23                         return arg0.length - arg1.length;
24                 } else {
25                         int result = 0;
26                         for (int i = 0, length = arg0 == null ? 0 : arg0.length; 
27                                         result == 0 && i < length; i++) {
28                                 result = compare(arg0[i], arg1[i]);
29                         } 
30                         return result;
31                 }
32         }
33
34         private int compare(String arg0, String arg1) {
35                 if (arg0 == null && arg1 == null) {
36                         return 0;
37                 } else if (arg0 == null) {
38                         return -1;
39                 } else if (arg1 == null) {
40                         return 1;
41                 } else {
42                         return arg0.compareTo(arg1);
43                 }
44         }
45 }