59 |
import java.io.ByteArrayOutputStream; |
import java.io.ByteArrayOutputStream; |
60 |
import java.io.IOException; |
import java.io.IOException; |
61 |
import java.util.ArrayList; |
import java.util.ArrayList; |
62 |
|
import java.util.Arrays; |
63 |
|
import java.util.zip.Adler32; |
64 |
|
|
65 |
/** |
/** |
66 |
* The implementaton of the Interoperable Object Reference (IOR). IOR can be |
* The implementaton of the Interoperable Object Reference (IOR). IOR can be |
718 |
// The future supported tagged profiles should be added here. |
// The future supported tagged profiles should be added here. |
719 |
throw new BAD_PARAM("Unsupported profile type " + profile.tag); |
throw new BAD_PARAM("Unsupported profile type " + profile.tag); |
720 |
} |
} |
721 |
|
|
722 |
|
/** |
723 |
|
* Checks for equality. |
724 |
|
*/ |
725 |
|
public boolean equals(Object x) |
726 |
|
{ |
727 |
|
if (x instanceof IOR) |
728 |
|
{ |
729 |
|
boolean keys; |
730 |
|
boolean hosts = true; |
731 |
|
|
732 |
|
IOR other = (IOR) x; |
733 |
|
|
734 |
|
if (Internet==null || other.Internet==null) |
735 |
|
return Internet == other.Internet; |
736 |
|
|
737 |
|
if (key != null && other.key != null) |
738 |
|
keys = Arrays.equals(key, other.key); |
739 |
|
else |
740 |
|
keys = key == other.key; |
741 |
|
|
742 |
|
if (Internet != null && Internet.host != null) |
743 |
|
if (other.Internet != null && other.Internet.host != null) |
744 |
|
hosts = other.Internet.host.equals(Internet.host); |
745 |
|
|
746 |
|
return keys & hosts && Internet.port==other.Internet.port; |
747 |
|
} |
748 |
|
else |
749 |
|
return false; |
750 |
|
} |
751 |
|
|
752 |
|
/** |
753 |
|
* Get the hashcode of this IOR. |
754 |
|
*/ |
755 |
|
public int hashCode() |
756 |
|
{ |
757 |
|
Adler32 adler = new Adler32(); |
758 |
|
if (key != null) |
759 |
|
adler.update(key); |
760 |
|
if (Internet != null) |
761 |
|
{ |
762 |
|
if (Internet.host != null) |
763 |
|
adler.update(Internet.host.getBytes()); |
764 |
|
adler.update(Internet.port); |
765 |
|
} |
766 |
|
return (int) adler.getValue(); |
767 |
|
} |
768 |
} |
} |