src/share/classes/java/net/SocketPermission.java

Print this page




 984     private boolean compareHostnames(SocketPermission that) {
 985         // we see if the original names/IPs passed in were equal.
 986 
 987         String thisHost = hostname;
 988         String thatHost = that.hostname;
 989 
 990         if (thisHost == null) {
 991             return false;
 992         } else if (this.wildcard) {
 993             final int cnameLength = this.cname.length();
 994             return thatHost.regionMatches(true,
 995                                           (thatHost.length() - cnameLength),
 996                                           this.cname, 0, cnameLength);
 997         } else {
 998             return thisHost.equalsIgnoreCase(thatHost);
 999         }
1000     }
1001 
1002     /**
1003      * Checks two SocketPermission objects for equality.
1004      * <P>
1005      * @param obj the object to test for equality with this object.
1006      *
1007      * @return true if <i>obj</i> is a SocketPermission, and has the
1008      *  same hostname, port range, and actions as this
1009      *  SocketPermission object. However, port range will be ignored
1010      *  in the comparison if <i>obj</i> only contains the action, 'resolve'.
1011      */
1012     public boolean equals(Object obj) {
1013         if (obj == this)
1014             return true;
1015 
1016         if (! (obj instanceof SocketPermission))
1017             return false;
1018 
1019         SocketPermission that = (SocketPermission) obj;
1020 
1021         //this is (overly?) complex!!!
1022 
1023         // check the mask first
1024         if (this.mask != that.mask) return false;




 984     private boolean compareHostnames(SocketPermission that) {
 985         // we see if the original names/IPs passed in were equal.
 986 
 987         String thisHost = hostname;
 988         String thatHost = that.hostname;
 989 
 990         if (thisHost == null) {
 991             return false;
 992         } else if (this.wildcard) {
 993             final int cnameLength = this.cname.length();
 994             return thatHost.regionMatches(true,
 995                                           (thatHost.length() - cnameLength),
 996                                           this.cname, 0, cnameLength);
 997         } else {
 998             return thisHost.equalsIgnoreCase(thatHost);
 999         }
1000     }
1001 
1002     /**
1003      * Checks two SocketPermission objects for equality.
1004      *
1005      * @param obj the object to test for equality with this object.
1006      *
1007      * @return true if <i>obj</i> is a SocketPermission, and has the
1008      *  same hostname, port range, and actions as this
1009      *  SocketPermission object. However, port range will be ignored
1010      *  in the comparison if <i>obj</i> only contains the action, 'resolve'.
1011      */
1012     public boolean equals(Object obj) {
1013         if (obj == this)
1014             return true;
1015 
1016         if (! (obj instanceof SocketPermission))
1017             return false;
1018 
1019         SocketPermission that = (SocketPermission) obj;
1020 
1021         //this is (overly?) complex!!!
1022 
1023         // check the mask first
1024         if (this.mask != that.mask) return false;