01: /*
02: * The contents of this file are subject to the terms of the Common Development
03: * and Distribution License (the License). You may not use this file except in
04: * compliance with the License.
05: *
06: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
07: * or http://www.netbeans.org/cddl.txt.
08: *
09: * When distributing Covered Code, include this CDDL Header Notice in each file
10: * and include the License file at http://www.netbeans.org/cddl.txt.
11: * If applicable, add the following below the CDDL Header, with the fields
12: * enclosed by brackets [] replaced by your own identifying information:
13: * "Portions Copyrighted [year] [name of copyright owner]"
14: *
15: * The Original Software is NetBeans. The Initial Developer of the Original
16: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17: * Microsystems, Inc. All Rights Reserved.
18: */
19:
20: package org.netbeans.modules.bpel.debugger.api;
21:
22: /**
23: * Mechanism to store host and port number of a
24: * BPEL service engine that we are attaching to.
25: *
26: * @author Sun Microsystems
27: */
28: public final class AttachingCookie {
29:
30: /**
31: * Public ID used for registration in Meta-inf/debugger.
32: */
33: public static final String ID = "netbeans-bpel-AttachingDICookie";
34:
35: private String mHost;
36: private int mPort;
37:
38: private AttachingCookie(String host, String port) {
39: mHost = host;
40: mPort = Integer.parseInt(port);
41: }
42:
43: /**
44: * Creates a new instance of AttachingDICookie for given parameters.
45: *
46: * @param hostName a name of computer to attach to
47: * @param portNumber a potr number
48: * @return a new instance of AttachingDICookie for given parameters
49: */
50: public static AttachingCookie create(String host, String port) {
51: return new AttachingCookie(host, port);
52:
53: }
54:
55: /**
56: * Returns port number.
57: *
58: * @return port number
59: */
60: public int getPort() {
61: return mPort;
62: }
63:
64: /**
65: * Returns name of computer.
66: *
67: * @return name of computer
68: */
69: public String getHost() {
70: return mHost;
71: }
72:
73: @Override
74: public int hashCode() {
75: // TODO Auto-generated method stub
76: return mHost.hashCode() * 37 + mPort * 7;
77: }
78:
79: @Override
80: public String toString() {
81: // TODO Auto-generated method stub
82: return mHost + "/" + mPort;
83: }
84:
85: @Override
86: public boolean equals(Object obj) {
87: // TODO Auto-generated method stub
88: if (!(obj instanceof AttachingCookie))
89: return false;
90: return ((AttachingCookie) obj).mHost.equals(mHost)
91: && (((AttachingCookie) obj).mPort == mPort);
92: }
93: }
|