1 25 26 package org.objectweb.jonas.webapp.jonasadmin.catalina; 27 28 import java.util.Comparator ; 29 30 33 public class ConnectorItemByPort implements Comparator { 34 35 37 public int compare(Object p_O1, Object p_O2) { 38 ConnectorItem oConnector1 = (ConnectorItem) p_O1; 39 ConnectorItem oConnector2 = (ConnectorItem) p_O2; 40 int iRet = 0; 41 try { 42 int i1 = Integer.parseInt(oConnector1.getPort()); 43 int i2 = Integer.parseInt(oConnector2.getPort()); 44 if (i1 > i2) { 45 iRet = 1; 46 } 47 else if (i1 < i2) { 48 iRet = -1; 49 } 50 else if ((oConnector1.getAddress() != null) && (oConnector2.getAddress() != null)) { 51 iRet = oConnector1.getAddress().compareToIgnoreCase(oConnector2.getAddress()); 52 } 53 else if (oConnector1.getAddress() == null) { 54 iRet = -1; 55 } 56 else { 57 iRet = 1; 58 } 59 } 60 catch (NumberFormatException e) { 61 } 63 64 return iRet; 65 } 66 67 public boolean equals(Object p_Obj) { 68 if (p_Obj instanceof ConnectorItem) { 69 return true; 70 } 71 return false; 72 } 73 } | Popular Tags |