IOR.java 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  1. /* IOR.java --
  2. Copyright (C) 2005 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package gnu.CORBA;
  32. import gnu.CORBA.CDR.BufferredCdrInput;
  33. import gnu.CORBA.CDR.BufferedCdrOutput;
  34. import gnu.CORBA.CDR.AbstractCdrInput;
  35. import gnu.CORBA.CDR.AbstractCdrOutput;
  36. import gnu.CORBA.GIOP.CharSets_OSF;
  37. import gnu.CORBA.GIOP.CodeSetServiceContext;
  38. import gnu.java.lang.CPStringBuilder;
  39. import org.omg.CORBA.BAD_PARAM;
  40. import org.omg.CORBA.CompletionStatus;
  41. import org.omg.CORBA.MARSHAL;
  42. import org.omg.CORBA.ULongSeqHelper;
  43. import org.omg.IOP.TAG_INTERNET_IOP;
  44. import org.omg.IOP.TAG_MULTIPLE_COMPONENTS;
  45. import org.omg.IOP.TaggedComponent;
  46. import org.omg.IOP.TaggedComponentHelper;
  47. import org.omg.IOP.TaggedProfile;
  48. import org.omg.IOP.TaggedProfileHelper;
  49. import java.io.ByteArrayOutputStream;
  50. import java.io.IOException;
  51. import java.util.ArrayList;
  52. import java.util.Arrays;
  53. import java.util.zip.Adler32;
  54. /**
  55. * The implementaton of the Interoperable Object Reference (IOR). IOR can be
  56. * compared with the Internet address for a web page, it provides means to
  57. * locate the CORBA service on the web. IOR contains the host address, port
  58. * number, the object identifier (key) inside the server, the communication
  59. * protocol version, supported charsets and so on.
  60. *
  61. * Ths class provides method for encoding and decoding the IOR information
  62. * from/to the stringified references, usually returned by
  63. * {@link org.omg.CORBA.ORB#String object_to_string()}.
  64. *
  65. * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
  66. *
  67. * @see org.mog.CORBA.Object.object_to_string(Object forObject)
  68. * @see string_to_object(String IOR)
  69. */
  70. public class IOR
  71. {
  72. /**
  73. * The code sets tagged component, normally part of the Internet profile. This
  74. * compone consists of the two componenets itself.
  75. */
  76. public static class CodeSets_profile
  77. {
  78. public CodeSets_profile()
  79. {
  80. int[] supported = CharSets_OSF.getSupportedCharSets();
  81. narrow.native_set = CharSets_OSF.NATIVE_CHARACTER;
  82. narrow.conversion = supported;
  83. wide.native_set = CharSets_OSF.NATIVE_WIDE_CHARACTER;
  84. wide.conversion = supported;
  85. }
  86. /**
  87. * The code set component.
  88. */
  89. public static class CodeSet_component
  90. {
  91. /**
  92. * The conversion code sets.
  93. */
  94. public int[] conversion;
  95. /**
  96. * The native code set.
  97. */
  98. public int native_set;
  99. /**
  100. * Read from the CDR stream.
  101. */
  102. public void read(org.omg.CORBA.portable.InputStream in)
  103. {
  104. native_set = in.read_ulong();
  105. conversion = ULongSeqHelper.read(in);
  106. }
  107. /**
  108. * Get a string representation.
  109. */
  110. public String toString()
  111. {
  112. CPStringBuilder b = new CPStringBuilder();
  113. b.append("native " + name(native_set));
  114. if (conversion != null && conversion.length > 0)
  115. {
  116. b.append(" conversion ");
  117. for (int i = 0; i < conversion.length; i++)
  118. {
  119. b.append(name(conversion[i]));
  120. b.append(' ');
  121. }
  122. }
  123. b.append(' ');
  124. return b.toString();
  125. }
  126. /**
  127. * Get a better formatted multiline string representation.
  128. */
  129. public String toStringFormatted()
  130. {
  131. CPStringBuilder b = new CPStringBuilder();
  132. b.append("\n Native set " + name(native_set));
  133. if (conversion != null && conversion.length > 0)
  134. {
  135. b.append("\n Other supported sets:\n ");
  136. for (int i = 0; i < conversion.length; i++)
  137. {
  138. b.append(name(conversion[i]));
  139. b.append(' ');
  140. }
  141. }
  142. b.append("\n");
  143. return b.toString();
  144. }
  145. /**
  146. * Write into CDR stream.
  147. */
  148. public void write(org.omg.CORBA.portable.OutputStream out)
  149. {
  150. out.write_long(native_set);
  151. ULongSeqHelper.write(out, conversion);
  152. }
  153. private String name(int set)
  154. {
  155. return "0x" + Integer.toHexString(set) + " ("
  156. + CharSets_OSF.getName(set) + ") ";
  157. }
  158. }
  159. /**
  160. * The agreed tag for the Codesets profile.
  161. */
  162. public static final int TAG_CODE_SETS = 1;
  163. /**
  164. * Information about narrow character encoding (TCS-C).
  165. */
  166. public CodeSet_component narrow = new CodeSet_component();
  167. /**
  168. * About wide character encoding (TCS-W).
  169. */
  170. public CodeSet_component wide = new CodeSet_component();
  171. /**
  172. * The negotiated coding result for this IOR. Saves time, requred for
  173. * negotiation computations.
  174. */
  175. public CodeSetServiceContext negotiated;
  176. /**
  177. * Read the code set profile information from the given input stream.
  178. *
  179. * @param profile a stream to read from.
  180. */
  181. public void read(AbstractCdrInput profile)
  182. {
  183. BufferredCdrInput encapsulation = profile.read_encapsulation();
  184. narrow.read(encapsulation);
  185. wide.read(encapsulation);
  186. }
  187. /**
  188. * Returns a string representation.
  189. */
  190. public String toString()
  191. {
  192. return "Narrow char: " + narrow + ", Wide char: " + wide;
  193. }
  194. /**
  195. * Write the code set profile information into the given input stream.
  196. *
  197. * @param profile a stream to write into.
  198. */
  199. public void write(AbstractCdrOutput profile)
  200. {
  201. AbstractCdrOutput encapsulation = profile.createEncapsulation();
  202. narrow.write(encapsulation);
  203. wide.write(encapsulation);
  204. try
  205. {
  206. encapsulation.close();
  207. }
  208. catch (IOException ex)
  209. {
  210. throw new InternalError();
  211. }
  212. }
  213. }
  214. /**
  215. * The internet profile.
  216. */
  217. public class Internet_profile
  218. {
  219. /**
  220. * The agreed tag for the Internet profile.
  221. */
  222. public static final int TAG_INTERNET_IOP = 0;
  223. /**
  224. * The host.
  225. */
  226. public String host;
  227. /**
  228. * The IIOP version (initialised to 1.2 by default).
  229. */
  230. public Version version = new Version(1, 2);
  231. /**
  232. * The port.
  233. */
  234. public int port;
  235. /**
  236. * The code sets component in the internet profile of this IOR. This is not
  237. * a separate profile.
  238. */
  239. public CodeSets_profile CodeSets = new CodeSets_profile();
  240. /**
  241. * Reserved for all components of this profile, this array holds the
  242. * components other than code set components.
  243. */
  244. ArrayList components = new ArrayList();
  245. /**
  246. * Return the human readable representation.
  247. */
  248. public String toString()
  249. {
  250. CPStringBuilder b = new CPStringBuilder();
  251. b.append(host);
  252. b.append(":");
  253. b.append(port);
  254. b.append(" (v");
  255. b.append(version);
  256. b.append(")");
  257. if (components.size() > 0)
  258. b.append(" " + components.size() + " extra components.");
  259. return b.toString();
  260. }
  261. /**
  262. * Write the internet profile (except the heading tag.
  263. */
  264. public void write(AbstractCdrOutput out)
  265. {
  266. try
  267. {
  268. // Need to write the Internet profile into the separate
  269. // stream as we must know the size in advance.
  270. AbstractCdrOutput b = out.createEncapsulation();
  271. version.write(b);
  272. b.write_string(host);
  273. b.write_ushort((short) (port & 0xFFFF));
  274. // Write the object key.
  275. b.write_long(key.length);
  276. b.write(key);
  277. // Number of the tagged components.
  278. b.write_long(1 + components.size());
  279. b.write_long(CodeSets_profile.TAG_CODE_SETS);
  280. CodeSets.write(b);
  281. TaggedComponent t;
  282. for (int i = 0; i < components.size(); i++)
  283. {
  284. t = (TaggedComponent) components.get(i);
  285. TaggedComponentHelper.write(b, t);
  286. }
  287. b.close();
  288. }
  289. catch (Exception e)
  290. {
  291. MARSHAL m = new MARSHAL("Unable to write Internet profile.");
  292. m.minor = Minor.IOR;
  293. m.initCause(e);
  294. throw m;
  295. }
  296. }
  297. }
  298. /**
  299. * The standard minor code, indicating that the string to object converstio
  300. * has failed due non specific reasons.
  301. */
  302. public static final int FAILED = 10;
  303. /**
  304. * The internet profile of this IOR.
  305. */
  306. public Internet_profile Internet = new Internet_profile();
  307. /**
  308. * The object repository Id.
  309. */
  310. public String Id;
  311. /**
  312. * The object key.
  313. */
  314. public byte[] key;
  315. /**
  316. * All tagged profiles of this IOR, except the separately defined Internet
  317. * profile.
  318. */
  319. ArrayList profiles = new ArrayList();
  320. /**
  321. * True if the profile was encoded using the Big Endian or the encoding is not
  322. * known.
  323. *
  324. * false if it was encoded using the Little Endian.
  325. */
  326. public boolean Big_Endian = true;
  327. /**
  328. * Create an empty instance, initialising the code sets to default values.
  329. */
  330. public IOR()
  331. {
  332. }
  333. /**
  334. * Parse the provided stringifed reference.
  335. *
  336. * @param stringified_reference in the form of IOR:nnnnnn.....
  337. *
  338. * @return the parsed IOR
  339. *
  340. * @throws BAD_PARAM, minor code 10, if the IOR cannot be parsed.
  341. *
  342. * TODO corballoc and other alternative formats.
  343. */
  344. public static IOR parse(String stringified_reference)
  345. throws BAD_PARAM
  346. {
  347. try
  348. {
  349. if (!stringified_reference.startsWith("IOR:"))
  350. throw new BAD_PARAM("The string refernce must start with IOR:",
  351. FAILED, CompletionStatus.COMPLETED_NO);
  352. IOR r = new IOR();
  353. ByteArrayOutputStream buf = new ByteArrayOutputStream();
  354. String x = stringified_reference;
  355. x = x.substring(x.indexOf(":") + 1);
  356. char cx;
  357. for (int i = 0; i < x.length(); i = i + 2)
  358. {
  359. cx = (char) Integer.parseInt(x.substring(i, i + 2), 16);
  360. buf.write(cx);
  361. }
  362. BufferredCdrInput cdr = new BufferredCdrInput(buf.toByteArray());
  363. r._read(cdr);
  364. return r;
  365. }
  366. catch (Exception ex)
  367. {
  368. ex.printStackTrace();
  369. throw new BAD_PARAM(ex + " while parsing " + stringified_reference,
  370. FAILED, CompletionStatus.COMPLETED_NO);
  371. }
  372. }
  373. /**
  374. * Read the IOR from the provided input stream.
  375. *
  376. * @param c a stream to read from.
  377. * @throws IOException if the stream throws it.
  378. */
  379. public void _read(AbstractCdrInput c)
  380. throws IOException, BAD_PARAM
  381. {
  382. int endian;
  383. endian = c.read_long();
  384. if (endian != 0)
  385. {
  386. Big_Endian = false;
  387. c.setBigEndian(false);
  388. }
  389. _read_no_endian(c);
  390. }
  391. /**
  392. * Read the IOR from the provided input stream, not reading the endian data at
  393. * the beginning of the stream. The IOR is thansferred in this form in
  394. * {@link write_Object(org.omg.CORBA.Object)}.
  395. *
  396. * If the stream contains a null value, the Id and Internet fields become
  397. * equal to null. Otherwise Id contains some string (possibly empty).
  398. *
  399. * Id is checked for null in AbstractCdrInput that then returns null instead of
  400. * object.
  401. *
  402. * @param c a stream to read from.
  403. * @throws IOException if the stream throws it.
  404. */
  405. public void _read_no_endian(AbstractCdrInput c)
  406. throws IOException, BAD_PARAM
  407. {
  408. Id = c.read_string();
  409. int n_profiles = c.read_long();
  410. if (n_profiles == 0)
  411. {
  412. Id = null;
  413. Internet = null;
  414. return;
  415. }
  416. for (int i = 0; i < n_profiles; i++)
  417. {
  418. int tag = c.read_long();
  419. BufferredCdrInput profile = c.read_encapsulation();
  420. if (tag == Internet_profile.TAG_INTERNET_IOP)
  421. {
  422. Internet = new Internet_profile();
  423. Internet.version = Version.read_version(profile);
  424. Internet.host = profile.read_string();
  425. Internet.port = profile.gnu_read_ushort();
  426. key = profile.read_sequence();
  427. // Read tagged components.
  428. int n_components = 0;
  429. try
  430. {
  431. if (Internet.version.since_inclusive(1, 1))
  432. n_components = profile.read_long();
  433. for (int t = 0; t < n_components; t++)
  434. {
  435. int ctag = profile.read_long();
  436. if (ctag == CodeSets_profile.TAG_CODE_SETS)
  437. {
  438. Internet.CodeSets.read(profile);
  439. }
  440. else
  441. {
  442. // Construct a generic component for codesets
  443. // profile.
  444. TaggedComponent pc = new TaggedComponent();
  445. pc.tag = ctag;
  446. pc.component_data = profile.read_sequence();
  447. Internet.components.add(pc);
  448. }
  449. }
  450. }
  451. catch (Unexpected ex)
  452. {
  453. ex.printStackTrace();
  454. }
  455. }
  456. else
  457. {
  458. // Construct a generic profile.
  459. TaggedProfile p = new TaggedProfile();
  460. p.tag = tag;
  461. p.profile_data = profile.buffer.getBuffer();
  462. profiles.add(p);
  463. }
  464. }
  465. }
  466. /**
  467. * Write this IOR record to the provided CDR stream. This procedure writes the
  468. * zero (Big Endian) marker first.
  469. */
  470. public void _write(AbstractCdrOutput out)
  471. {
  472. // Always use Big Endian.
  473. out.write(0);
  474. _write_no_endian(out);
  475. }
  476. /**
  477. * Write a null value to the CDR output stream.
  478. *
  479. * The null value is written as defined in OMG specification (zero length
  480. * string, followed by an empty set of profiles).
  481. */
  482. public static void write_null(AbstractCdrOutput out)
  483. {
  484. // Empty Id string.
  485. out.write_string("");
  486. // Empty set of profiles.
  487. out.write_long(0);
  488. }
  489. /**
  490. * Write this IOR record to the provided CDR stream. The procedure writed data
  491. * in Big Endian, but does NOT add any endian marker to the beginning.
  492. */
  493. public void _write_no_endian(AbstractCdrOutput out)
  494. {
  495. // Write repository id.
  496. out.write_string(Id);
  497. out.write_long(1 + profiles.size());
  498. // Write the Internet profile.
  499. out.write_long(Internet_profile.TAG_INTERNET_IOP);
  500. Internet.write(out);
  501. // Write other profiles.
  502. TaggedProfile tp;
  503. for (int i = 0; i < profiles.size(); i++)
  504. {
  505. tp = (TaggedProfile) profiles.get(i);
  506. TaggedProfileHelper.write(out, tp);
  507. }
  508. }
  509. /**
  510. * Returns a human readable string representation of this IOR object.
  511. */
  512. public String toString()
  513. {
  514. CPStringBuilder b = new CPStringBuilder();
  515. b.append(Id);
  516. b.append(" at ");
  517. b.append(Internet);
  518. if (!Big_Endian)
  519. b.append(" (Little endian) ");
  520. b.append(" Key ");
  521. for (int i = 0; i < key.length; i++)
  522. {
  523. b.append(Integer.toHexString(key[i] & 0xFF));
  524. }
  525. b.append(" ");
  526. b.append(Internet.CodeSets);
  527. return b.toString();
  528. }
  529. /**
  530. * Returns a multiline formatted human readable string representation of
  531. * this IOR object.
  532. */
  533. public String toStringFormatted()
  534. {
  535. CPStringBuilder b = new CPStringBuilder();
  536. b.append("\nObject Id:\n ");
  537. b.append(Id);
  538. b.append("\nObject is accessible at:\n ");
  539. b.append(Internet);
  540. if (Big_Endian)
  541. b.append("\n Big endian encoding");
  542. else
  543. b.append("\n Little endian encoding.");
  544. b.append("\nObject Key\n ");
  545. for (int i = 0; i < key.length; i++)
  546. {
  547. b.append(Integer.toHexString(key[i] & 0xFF));
  548. }
  549. b.append("\nSupported code sets:");
  550. b.append("\n Wide:");
  551. b.append(Internet.CodeSets.wide.toStringFormatted());
  552. b.append(" Narrow:");
  553. b.append(Internet.CodeSets.wide.toStringFormatted());
  554. return b.toString();
  555. }
  556. /**
  557. * Returs a stringified reference.
  558. *
  559. * @return a newly constructed stringified reference.
  560. */
  561. public String toStringifiedReference()
  562. {
  563. BufferedCdrOutput out = new BufferedCdrOutput();
  564. _write(out);
  565. CPStringBuilder b = new CPStringBuilder("IOR:");
  566. byte[] binary = out.buffer.toByteArray();
  567. String s;
  568. for (int i = 0; i < binary.length; i++)
  569. {
  570. s = Integer.toHexString(binary[i] & 0xFF);
  571. if (s.length() == 1)
  572. b.append('0');
  573. b.append(s);
  574. }
  575. return b.toString();
  576. }
  577. /**
  578. * Adds a service-specific component to the IOR profile. The specified
  579. * component will be included in all profiles, present in the IOR.
  580. *
  581. * @param tagged_component a tagged component being added.
  582. */
  583. public void add_ior_component(TaggedComponent tagged_component)
  584. {
  585. // Add to the Internet profile.
  586. Internet.components.add(tagged_component);
  587. // Add to others.
  588. for (int i = 0; i < profiles.size(); i++)
  589. {
  590. TaggedProfile profile = (TaggedProfile) profiles.get(i);
  591. addComponentTo(profile, tagged_component);
  592. }
  593. }
  594. /**
  595. * Adds a service-specific component to the IOR profile.
  596. *
  597. * @param tagged_component a tagged component being added.
  598. *
  599. * @param profile_id the IOR profile to that the component must be added. The
  600. * 0 value ({@link org.omg.IOP.TAG_INTERNET_IOP#value}) adds to the Internet
  601. * profile where host and port are stored by default.
  602. */
  603. public void add_ior_component_to_profile(TaggedComponent tagged_component,
  604. int profile_id)
  605. {
  606. if (profile_id == TAG_INTERNET_IOP.value)
  607. // Add to the Internet profile
  608. Internet.components.add(tagged_component);
  609. else
  610. {
  611. // Add to others.
  612. for (int i = 0; i < profiles.size(); i++)
  613. {
  614. TaggedProfile profile = (TaggedProfile) profiles.get(i);
  615. if (profile.tag == profile_id)
  616. addComponentTo(profile, tagged_component);
  617. }
  618. }
  619. }
  620. /**
  621. * Add given component to the given profile that is NOT an Internet profile.
  622. *
  623. * @param profile the profile, where the component should be added.
  624. * @param component the component to add.
  625. */
  626. private static void addComponentTo(TaggedProfile profile,
  627. TaggedComponent component)
  628. {
  629. if (profile.tag == TAG_MULTIPLE_COMPONENTS.value)
  630. {
  631. TaggedComponent[] present;
  632. if (profile.profile_data.length > 0)
  633. {
  634. BufferredCdrInput in = new BufferredCdrInput(profile.profile_data);
  635. present = new TaggedComponent[in.read_long()];
  636. for (int i = 0; i < present.length; i++)
  637. {
  638. present[i] = TaggedComponentHelper.read(in);
  639. }
  640. }
  641. else
  642. present = new TaggedComponent[0];
  643. BufferedCdrOutput out = new BufferedCdrOutput(profile.profile_data.length
  644. + component.component_data.length
  645. + 8);
  646. // Write new amount of components.
  647. out.write_long(present.length + 1);
  648. // Write other components.
  649. for (int i = 0; i < present.length; i++)
  650. TaggedComponentHelper.write(out, present[i]);
  651. // Write the passed component.
  652. TaggedComponentHelper.write(out, component);
  653. try
  654. {
  655. out.close();
  656. }
  657. catch (IOException e)
  658. {
  659. throw new Unexpected(e);
  660. }
  661. profile.profile_data = out.buffer.toByteArray();
  662. }
  663. else
  664. // The future supported tagged profiles should be added here.
  665. throw new BAD_PARAM("Unsupported profile type " + profile.tag);
  666. }
  667. /**
  668. * Checks for equality.
  669. */
  670. public boolean equals(Object x)
  671. {
  672. if (x instanceof IOR)
  673. {
  674. boolean keys;
  675. boolean hosts = true;
  676. IOR other = (IOR) x;
  677. if (Internet==null || other.Internet==null)
  678. return Internet == other.Internet;
  679. if (key != null && other.key != null)
  680. keys = Arrays.equals(key, other.key);
  681. else
  682. keys = key == other.key;
  683. if (Internet != null && Internet.host != null)
  684. if (other.Internet != null && other.Internet.host != null)
  685. hosts = other.Internet.host.equals(Internet.host);
  686. return keys & hosts && Internet.port==other.Internet.port;
  687. }
  688. else
  689. return false;
  690. }
  691. /**
  692. * Get the hashcode of this IOR.
  693. */
  694. public int hashCode()
  695. {
  696. Adler32 adler = new Adler32();
  697. if (key != null)
  698. adler.update(key);
  699. if (Internet != null)
  700. {
  701. if (Internet.host != null)
  702. adler.update(Internet.host.getBytes());
  703. adler.update(Internet.port);
  704. }
  705. return (int) adler.getValue();
  706. }
  707. }