Mercurial > 510Connectbot
annotate src/com/five_ten_sg/connectbot/bean/HostBean.java @ 408:0c519d0acdd4 stable-1.9.0-7
bump version number
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Fri, 24 Oct 2014 14:27:11 -0700 |
parents | e0f5e706a655 |
children |
rev | line source |
---|---|
0 | 1 /* |
2 * ConnectBot: simple, powerful, open-source SSH client for Android | |
3 * Copyright 2007 Kenny Root, Jeffrey Sharkey | |
4 * | |
5 * Licensed under the Apache License, Version 2.0 (the "License"); | |
6 * you may not use this file except in compliance with the License. | |
7 * You may obtain a copy of the License at | |
8 * | |
9 * http://www.apache.org/licenses/LICENSE-2.0 | |
10 * | |
11 * Unless required by applicable law or agreed to in writing, software | |
12 * distributed under the License is distributed on an "AS IS" BASIS, | |
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 * See the License for the specific language governing permissions and | |
15 * limitations under the License. | |
16 */ | |
17 | |
18 package com.five_ten_sg.connectbot.bean; | |
19 | |
20 import com.five_ten_sg.connectbot.util.HostDatabase; | |
21 import android.content.ContentValues; | |
22 import android.net.Uri; | |
23 | |
24 /** | |
25 * @author Kenny Root | |
26 * | |
27 */ | |
28 public class HostBean extends AbstractBean { | |
29 public static final String BEAN_NAME = "host"; | |
30 | |
31 /* Database fields */ | |
61 | 32 private long id = -1; |
33 private String nickname = null; | |
34 private String username = null; | |
35 private String hostname = null; | |
36 private int port = 22; | |
37 private String protocol = "ssh"; | |
38 private String hostKeyAlgo = null; | |
39 private byte[] hostKey = null; | |
40 private long lastConnect = -1; | |
41 private String color; | |
0 | 42 private boolean useKeys = true; |
61 | 43 private String useAuthAgent = HostDatabase.AUTHAGENT_NO; |
44 private String postLogin = null; | |
45 private long pubkeyId = -1; | |
46 private String delKey = HostDatabase.DELKEY_DEL; | |
188
cf677a6f586d
use floating point font size, change size by scaling factor rather than linear addition
Carl Byington <carl@five-ten-sg.com>
parents:
123
diff
changeset
|
47 private float fontSize = -1; |
242
e0f5e706a655
add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
241
diff
changeset
|
48 private boolean fixedSize = false; |
241
8b68dfb283d2
add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
238
diff
changeset
|
49 private int fixedWidth = 80; |
8b68dfb283d2
add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
238
diff
changeset
|
50 private int fixedHeight = 25; |
238
bd803721f94a
remove unused update preference; add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
188
diff
changeset
|
51 private boolean wantSession = true; |
0 | 52 private boolean compression = false; |
61 | 53 private String httpproxy = null; |
54 private String encoding = HostDatabase.ENCODING_DEFAULT; | |
0 | 55 private boolean stayConnected = false; |
56 private boolean wantX11Forward = false; | |
61 | 57 private String x11Host = "localhost"; |
58 private int x11Port = 6000; | |
59 private String monitor = null; | |
60 private String hostemulation = null; | |
61 private String encryption5250 = null; | |
119
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
62 private String library = null; |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
63 private String initialMenu = null; |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
64 private String program = null; |
0 | 65 |
66 public HostBean() { | |
67 } | |
68 | |
69 @Override | |
70 public String getBeanName() { | |
71 return BEAN_NAME; | |
72 } | |
73 | |
74 public HostBean(String nickname, String protocol, String username, String hostname, int port) { | |
75 this.nickname = nickname; | |
76 this.protocol = protocol; | |
77 this.username = username; | |
78 this.hostname = hostname; | |
79 this.port = port; | |
80 } | |
81 | |
83
4ccfde0bc506
disable host config items that are not applicable to the host protocol
Carl Byington <carl@five-ten-sg.com>
parents:
63
diff
changeset
|
82 public boolean isSSH() { |
88
1c22e6a7efff
convert ctrl keys to virtual keys; use proper android home directory
Carl Byington <carl@five-ten-sg.com>
parents:
83
diff
changeset
|
83 return protocol.equals("ssh"); |
83
4ccfde0bc506
disable host config items that are not applicable to the host protocol
Carl Byington <carl@five-ten-sg.com>
parents:
63
diff
changeset
|
84 } |
4ccfde0bc506
disable host config items that are not applicable to the host protocol
Carl Byington <carl@five-ten-sg.com>
parents:
63
diff
changeset
|
85 |
4ccfde0bc506
disable host config items that are not applicable to the host protocol
Carl Byington <carl@five-ten-sg.com>
parents:
63
diff
changeset
|
86 public boolean is5250() { |
88
1c22e6a7efff
convert ctrl keys to virtual keys; use proper android home directory
Carl Byington <carl@five-ten-sg.com>
parents:
83
diff
changeset
|
87 return protocol.equals("tn5250"); |
83
4ccfde0bc506
disable host config items that are not applicable to the host protocol
Carl Byington <carl@five-ten-sg.com>
parents:
63
diff
changeset
|
88 } |
4ccfde0bc506
disable host config items that are not applicable to the host protocol
Carl Byington <carl@five-ten-sg.com>
parents:
63
diff
changeset
|
89 |
4ccfde0bc506
disable host config items that are not applicable to the host protocol
Carl Byington <carl@five-ten-sg.com>
parents:
63
diff
changeset
|
90 public boolean isTelnet() { |
88
1c22e6a7efff
convert ctrl keys to virtual keys; use proper android home directory
Carl Byington <carl@five-ten-sg.com>
parents:
83
diff
changeset
|
91 return protocol.equals("telnet"); |
83
4ccfde0bc506
disable host config items that are not applicable to the host protocol
Carl Byington <carl@five-ten-sg.com>
parents:
63
diff
changeset
|
92 } |
4ccfde0bc506
disable host config items that are not applicable to the host protocol
Carl Byington <carl@five-ten-sg.com>
parents:
63
diff
changeset
|
93 |
4ccfde0bc506
disable host config items that are not applicable to the host protocol
Carl Byington <carl@five-ten-sg.com>
parents:
63
diff
changeset
|
94 public boolean isAsync() { |
4ccfde0bc506
disable host config items that are not applicable to the host protocol
Carl Byington <carl@five-ten-sg.com>
parents:
63
diff
changeset
|
95 return isSSH() || isTelnet(); |
4ccfde0bc506
disable host config items that are not applicable to the host protocol
Carl Byington <carl@five-ten-sg.com>
parents:
63
diff
changeset
|
96 } |
4ccfde0bc506
disable host config items that are not applicable to the host protocol
Carl Byington <carl@five-ten-sg.com>
parents:
63
diff
changeset
|
97 |
0 | 98 public void setId(long id) { |
99 this.id = id; | |
100 } | |
101 public long getId() { | |
102 return id; | |
103 } | |
104 public void setNickname(String nickname) { | |
105 this.nickname = nickname; | |
106 } | |
107 public String getNickname() { | |
108 return nickname; | |
109 } | |
110 public void setUsername(String username) { | |
111 this.username = username; | |
112 } | |
113 public String getUsername() { | |
114 return username; | |
115 } | |
116 public void setHostname(String hostname) { | |
117 this.hostname = hostname; | |
118 } | |
119 public String getHostname() { | |
120 return hostname; | |
121 } | |
122 public void setPort(int port) { | |
123 this.port = port; | |
124 } | |
125 public int getPort() { | |
126 return port; | |
127 } | |
128 | |
129 public void setProtocol(String protocol) { | |
130 this.protocol = protocol; | |
131 } | |
132 | |
133 public String getProtocol() { | |
134 return protocol; | |
135 } | |
136 | |
137 public void setHostKeyAlgo(String hostKeyAlgo) { | |
138 this.hostKeyAlgo = hostKeyAlgo; | |
139 } | |
140 public String getHostKeyAlgo() { | |
141 return hostKeyAlgo; | |
142 } | |
143 public void setHostKey(byte[] hostKey) { | |
144 if (hostKey == null) | |
145 this.hostKey = null; | |
146 else | |
147 this.hostKey = hostKey.clone(); | |
148 } | |
149 public byte[] getHostKey() { | |
150 if (hostKey == null) | |
151 return null; | |
152 else | |
153 return hostKey.clone(); | |
154 } | |
155 public void setLastConnect(long lastConnect) { | |
156 this.lastConnect = lastConnect; | |
157 } | |
158 public long getLastConnect() { | |
159 return lastConnect; | |
160 } | |
161 public void setColor(String color) { | |
162 this.color = color; | |
163 } | |
164 public String getColor() { | |
165 return color; | |
166 } | |
167 public void setUseKeys(boolean useKeys) { | |
168 this.useKeys = useKeys; | |
169 } | |
170 public boolean getUseKeys() { | |
171 return useKeys; | |
172 } | |
173 public void setUseAuthAgent(String useAuthAgent) { | |
174 this.useAuthAgent = useAuthAgent; | |
175 } | |
176 public String getUseAuthAgent() { | |
177 return useAuthAgent; | |
178 } | |
179 public void setPostLogin(String postLogin) { | |
180 this.postLogin = postLogin; | |
181 } | |
182 public String getPostLogin() { | |
183 return postLogin; | |
184 } | |
185 public void setPubkeyId(long pubkeyId) { | |
186 this.pubkeyId = pubkeyId; | |
187 } | |
188 public long getPubkeyId() { | |
189 return pubkeyId; | |
190 } | |
191 public void setWantSession(boolean wantSession) { | |
192 this.wantSession = wantSession; | |
193 } | |
194 public boolean getWantSession() { | |
195 return wantSession; | |
196 } | |
197 public void setDelKey(String delKey) { | |
198 this.delKey = delKey; | |
199 } | |
200 public String getDelKey() { | |
201 return delKey; | |
202 } | |
188
cf677a6f586d
use floating point font size, change size by scaling factor rather than linear addition
Carl Byington <carl@five-ten-sg.com>
parents:
123
diff
changeset
|
203 public void setFontSize(float fontSize) { |
0 | 204 this.fontSize = fontSize; |
205 } | |
188
cf677a6f586d
use floating point font size, change size by scaling factor rather than linear addition
Carl Byington <carl@five-ten-sg.com>
parents:
123
diff
changeset
|
206 public float getFontSize() { |
0 | 207 return fontSize; |
208 } | |
238
bd803721f94a
remove unused update preference; add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
188
diff
changeset
|
209 public void setFixedSize(boolean fixedSize) { |
bd803721f94a
remove unused update preference; add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
188
diff
changeset
|
210 this.fixedSize = fixedSize; |
bd803721f94a
remove unused update preference; add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
188
diff
changeset
|
211 } |
bd803721f94a
remove unused update preference; add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
188
diff
changeset
|
212 public boolean getFixedSize() { |
bd803721f94a
remove unused update preference; add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
188
diff
changeset
|
213 return fixedSize; |
bd803721f94a
remove unused update preference; add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
188
diff
changeset
|
214 } |
241
8b68dfb283d2
add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
238
diff
changeset
|
215 public void setFixedWidth(int fixedWidth) { |
238
bd803721f94a
remove unused update preference; add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
188
diff
changeset
|
216 this.fixedWidth = fixedWidth; |
bd803721f94a
remove unused update preference; add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
188
diff
changeset
|
217 } |
241
8b68dfb283d2
add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
238
diff
changeset
|
218 public int getFixedWidth() { |
238
bd803721f94a
remove unused update preference; add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
188
diff
changeset
|
219 return fixedWidth; |
bd803721f94a
remove unused update preference; add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
188
diff
changeset
|
220 } |
241
8b68dfb283d2
add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
238
diff
changeset
|
221 public void setFixedHeight(int fixedHeight) { |
238
bd803721f94a
remove unused update preference; add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
188
diff
changeset
|
222 this.fixedHeight = fixedHeight; |
bd803721f94a
remove unused update preference; add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
188
diff
changeset
|
223 } |
241
8b68dfb283d2
add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
238
diff
changeset
|
224 public int getFixedHeight() { |
238
bd803721f94a
remove unused update preference; add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
188
diff
changeset
|
225 return fixedHeight; |
bd803721f94a
remove unused update preference; add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
188
diff
changeset
|
226 } |
0 | 227 public void setCompression(boolean compression) { |
228 this.compression = compression; | |
229 } | |
230 public boolean getCompression() { | |
231 return compression; | |
232 } | |
233 public void setHttpproxy(String httpproxy) { | |
234 this.httpproxy = httpproxy; | |
235 } | |
236 public String getHttpproxy() { | |
237 return httpproxy; | |
238 } | |
239 | |
240 public void setEncoding(String encoding) { | |
241 this.encoding = encoding; | |
242 } | |
243 | |
244 public String getEncoding() { | |
245 return this.encoding; | |
246 } | |
247 | |
248 public void setStayConnected(boolean stayConnected) { | |
249 this.stayConnected = stayConnected; | |
250 } | |
251 | |
252 public boolean getStayConnected() { | |
253 return stayConnected; | |
254 } | |
255 | |
256 public String getDescription() { | |
257 String description = String.format("%s@%s", username, hostname); | |
258 | |
259 if (port != 22) | |
260 description += String.format(":%d", port); | |
261 | |
262 return description; | |
263 } | |
264 | |
265 public boolean getWantX11Forward() { | |
266 return this.wantX11Forward; | |
267 } | |
268 | |
269 public void setWantX11Forward(boolean wantX11Forward) { | |
270 this.wantX11Forward = wantX11Forward; | |
271 } | |
272 | |
273 public String getX11Host() { | |
274 return this.x11Host; | |
275 } | |
276 | |
277 public void setX11Host(String x11Host) { | |
278 this.x11Host = x11Host; | |
279 } | |
280 | |
281 public int getX11Port() { | |
282 return this.x11Port; | |
283 } | |
284 | |
285 public void setX11Port(int x11Port) { | |
286 this.x11Port = x11Port; | |
287 } | |
288 | |
289 public String getMonitor() { | |
290 return this.monitor; | |
291 } | |
292 | |
293 public void setMonitor(String monitor) { | |
294 this.monitor = monitor; | |
295 } | |
296 | |
61 | 297 public String getHostEmulation() { |
298 return this.hostemulation; | |
299 } | |
300 | |
301 public void setHostEmulation(String hostemulation) { | |
302 this.hostemulation = hostemulation; | |
303 } | |
304 | |
305 public String getEncryption5250() { | |
306 return this.encryption5250; | |
307 } | |
308 | |
309 public void setEncryption5250(String encryption5250) { | |
310 this.encryption5250 = encryption5250; | |
311 } | |
312 | |
119
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
313 public String getLibrary() { |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
314 return this.library; |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
315 } |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
316 |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
317 public void setLibrary(String library) { |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
318 this.library = library; |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
319 } |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
320 |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
321 public String getInitialMenu() { |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
322 return this.initialMenu; |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
323 } |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
324 |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
325 public void setInitialMenu(String initialMenu) { |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
326 this.initialMenu = initialMenu; |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
327 } |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
328 |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
329 public String getProgram() { |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
330 return this.program; |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
331 } |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
332 |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
333 public void setProgram(String program) { |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
334 this.program = program; |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
335 } |
6969d6cebcd7
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
88
diff
changeset
|
336 |
0 | 337 @Override |
338 public ContentValues getValues() { | |
339 ContentValues values = new ContentValues(); | |
340 values.put(HostDatabase.FIELD_HOST_NICKNAME, nickname); | |
341 values.put(HostDatabase.FIELD_HOST_PROTOCOL, protocol); | |
342 values.put(HostDatabase.FIELD_HOST_USERNAME, username); | |
343 values.put(HostDatabase.FIELD_HOST_HOSTNAME, hostname); | |
344 values.put(HostDatabase.FIELD_HOST_PORT, port); | |
345 values.put(HostDatabase.FIELD_HOST_HOSTKEYALGO, hostKeyAlgo); | |
346 values.put(HostDatabase.FIELD_HOST_HOSTKEY, hostKey); | |
347 values.put(HostDatabase.FIELD_HOST_LASTCONNECT, lastConnect); | |
348 values.put(HostDatabase.FIELD_HOST_COLOR, color); | |
349 values.put(HostDatabase.FIELD_HOST_USEKEYS, Boolean.toString(useKeys)); | |
350 values.put(HostDatabase.FIELD_HOST_USEAUTHAGENT, useAuthAgent); | |
351 values.put(HostDatabase.FIELD_HOST_POSTLOGIN, postLogin); | |
352 values.put(HostDatabase.FIELD_HOST_PUBKEYID, pubkeyId); | |
353 values.put(HostDatabase.FIELD_HOST_WANTSESSION, Boolean.toString(wantSession)); | |
354 values.put(HostDatabase.FIELD_HOST_DELKEY, delKey); | |
355 values.put(HostDatabase.FIELD_HOST_FONTSIZE, fontSize); | |
238
bd803721f94a
remove unused update preference; add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
188
diff
changeset
|
356 values.put(HostDatabase.FIELD_HOST_FIXEDSIZE, Boolean.toString(fixedSize)); |
bd803721f94a
remove unused update preference; add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
188
diff
changeset
|
357 values.put(HostDatabase.FIELD_HOST_FIXEDWIDTH, fixedWidth); |
bd803721f94a
remove unused update preference; add host preference for fixed screen size
Carl Byington <carl@five-ten-sg.com>
parents:
188
diff
changeset
|
358 values.put(HostDatabase.FIELD_HOST_FIXEDHEIGHT, fixedHeight); |
0 | 359 values.put(HostDatabase.FIELD_HOST_COMPRESSION, Boolean.toString(compression)); |
360 values.put(HostDatabase.FIELD_HOST_HTTPPROXY, httpproxy); | |
361 values.put(HostDatabase.FIELD_HOST_ENCODING, encoding); | |
362 values.put(HostDatabase.FIELD_HOST_STAYCONNECTED, stayConnected); | |
363 values.put(HostDatabase.FIELD_HOST_WANTX11FORWARD, wantX11Forward); | |
364 values.put(HostDatabase.FIELD_HOST_X11HOST, x11Host); | |
365 values.put(HostDatabase.FIELD_HOST_X11PORT, x11Port); | |
366 values.put(HostDatabase.FIELD_HOST_MONITOR, monitor); | |
63
07c7055cc124
add 5250 config entries
Carl Byington <carl@five-ten-sg.com>
parents:
61
diff
changeset
|
367 values.put(HostDatabase.FIELD_HOST_EMULATION, hostemulation); |
61 | 368 values.put(HostDatabase.FIELD_HOST_ENCRYPTION5250, encryption5250); |
123
446dbcf606eb
add more 5250 config items; ignore drawing outside the screen
Carl Byington <carl@five-ten-sg.com>
parents:
122
diff
changeset
|
369 values.put(HostDatabase.FIELD_HOST_LIBRARY5250, library); |
446dbcf606eb
add more 5250 config items; ignore drawing outside the screen
Carl Byington <carl@five-ten-sg.com>
parents:
122
diff
changeset
|
370 values.put(HostDatabase.FIELD_HOST_MENU5250, initialMenu); |
446dbcf606eb
add more 5250 config items; ignore drawing outside the screen
Carl Byington <carl@five-ten-sg.com>
parents:
122
diff
changeset
|
371 values.put(HostDatabase.FIELD_HOST_PROGRAM5250, program); |
0 | 372 return values; |
373 } | |
374 | |
375 @Override | |
376 public boolean equals(Object o) { | |
377 if (o == null || !(o instanceof HostBean)) | |
378 return false; | |
379 | |
380 HostBean host = (HostBean)o; | |
381 | |
382 if (id != -1 && host.getId() != -1) | |
383 return host.getId() == id; | |
384 | |
385 if (nickname == null) { | |
386 if (host.getNickname() != null) | |
387 return false; | |
388 } | |
389 else if (!nickname.equals(host.getNickname())) | |
390 return false; | |
391 | |
392 if (protocol == null) { | |
393 if (host.getProtocol() != null) | |
394 return false; | |
395 } | |
396 else if (!protocol.equals(host.getProtocol())) | |
397 return false; | |
398 | |
399 if (username == null) { | |
400 if (host.getUsername() != null) | |
401 return false; | |
402 } | |
403 else if (!username.equals(host.getUsername())) | |
404 return false; | |
405 | |
406 if (hostname == null) { | |
407 if (host.getHostname() != null) | |
408 return false; | |
409 } | |
410 else if (!hostname.equals(host.getHostname())) | |
411 return false; | |
412 | |
413 if (port != host.getPort()) | |
414 return false; | |
415 | |
416 return true; | |
417 } | |
418 | |
419 @Override | |
420 public int hashCode() { | |
421 int hash = 7; | |
422 | |
423 if (id != -1) | |
424 return (int)id; | |
425 | |
426 hash = 31 * hash + (null == nickname ? 0 : nickname.hashCode()); | |
427 hash = 31 * hash + (null == protocol ? 0 : protocol.hashCode()); | |
428 hash = 31 * hash + (null == username ? 0 : username.hashCode()); | |
429 hash = 31 * hash + (null == hostname ? 0 : hostname.hashCode()); | |
430 hash = 31 * hash + port; | |
431 return hash; | |
432 } | |
433 | |
434 /** | |
435 * @return URI identifying this HostBean | |
436 */ | |
437 public Uri getUri() { | |
438 StringBuilder sb = new StringBuilder(); | |
439 sb.append(protocol) | |
440 .append("://"); | |
441 | |
442 if (username != null) | |
443 sb.append(Uri.encode(username)) | |
444 .append('@'); | |
445 | |
446 sb.append(Uri.encode(hostname)) | |
447 .append(':') | |
448 .append(port) | |
449 .append("/#") | |
450 .append(nickname); | |
451 return Uri.parse(sb.toString()); | |
452 } | |
453 | |
454 } |