ConnectorItemByPort.java

00001 
00026 package org.objectweb.jonas.webapp.jonasadmin.catalina;
00027 
00028 import java.util.Comparator;
00029 
00033 public class ConnectorItemByPort implements Comparator {
00034 
00035 // --------------------------------------------------------- Public Methods
00036 
00037     public int compare(Object p_O1, Object p_O2) {
00038         ConnectorItem oConnector1 = (ConnectorItem) p_O1;
00039         ConnectorItem oConnector2 = (ConnectorItem) p_O2;
00040         int iRet = 0;
00041         try {
00042             int i1 = Integer.parseInt(oConnector1.getPort());
00043             int i2 = Integer.parseInt(oConnector2.getPort());
00044             if (i1 > i2) {
00045                 iRet = 1;
00046             }
00047             else if (i1 < i2) {
00048                 iRet = -1;
00049             }
00050             else if ((oConnector1.getAddress() != null) && (oConnector2.getAddress() != null)) {
00051                 iRet = oConnector1.getAddress().compareToIgnoreCase(oConnector2.getAddress());
00052             }
00053             else if (oConnector1.getAddress() == null) {
00054                 iRet = -1;
00055             }
00056             else {
00057                 iRet = 1;
00058             }
00059         }
00060         catch (NumberFormatException e) {
00061             // None
00062         }
00063 
00064         return iRet;
00065     }
00066 
00067     public boolean equals(Object p_Obj) {
00068         if (p_Obj instanceof ConnectorItem) {
00069             return true;
00070         }
00071         return false;
00072     }
00073 }

Generated on Tue Feb 15 15:05:26 2005 for JOnAS by  doxygen 1.3.9.1