Compares this Name to another Object. @param o The Object to be compared. @return The value 0 if the argument is a name equivalent to this name; a value less than 0 if the argument is less than this name in the canonical ordering, and a value greater than 0 if the argument is greater than this name
(Object o)
| 830 | * @throws ClassCastException if the argument is not a Name. |
| 831 | */ |
| 832 | public int |
| 833 | compareTo(Object o) { |
| 834 | Name arg = (Name) o; |
| 835 | |
| 836 | if (this == arg) |
| 837 | return (0); |
| 838 | |
| 839 | int labels = labels(); |
| 840 | int alabels = arg.labels(); |
| 841 | int compares = labels > alabels ? alabels : labels; |
| 842 | |
| 843 | for (int i = 1; i <= compares; i++) { |
| 844 | int start = offset(labels - i); |
| 845 | int astart = arg.offset(alabels - i); |
| 846 | int length = name[start]; |
| 847 | int alength = arg.name[astart]; |
| 848 | for (int j = 0; j < length && j < alength; j++) { |
| 849 | int n = lowercase[(name[j + start + 1]) & 0xFF] - |
| 850 | lowercase[(arg.name[j + astart + 1]) & 0xFF]; |
| 851 | if (n != 0) |
| 852 | return (n); |
| 853 | } |
| 854 | if (length != alength) |
| 855 | return (length - alength); |
| 856 | } |
| 857 | return (labels - alabels); |
| 858 | } |
| 859 | |
| 860 | } |
no test coverage detected