01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc;
05:
06: import java.util.Arrays;
07:
08: public class WebAppComparable implements Comparable {
09: private WebApp m_webApp;
10:
11: WebAppComparable(WebApp webApp) {
12: m_webApp = webApp;
13: }
14:
15: public WebApp element() {
16: return m_webApp;
17: }
18:
19: public int compareTo(Object o) {
20: WebAppComparable other = (WebAppComparable) o;
21: WebApp otherType = other.element();
22: String otherName = otherType.getName();
23:
24: return m_webApp.getName().compareTo(otherName);
25: }
26:
27: public static WebApp[] sort(WebApp[] webApps) {
28: int count = webApps.length;
29: WebAppComparable[] tmp = new WebAppComparable[count];
30:
31: for (int i = 0; i < count; i++) {
32: tmp[i] = new WebAppComparable(webApps[i]);
33: }
34: Arrays.sort(tmp);
35: for (int i = 0; i < count; i++) {
36: webApps[i] = tmp[i].element();
37: }
38:
39: return webApps;
40: }
41: }
|