Hubiquitus Android  0.3
Android client for hubiquitus protocol
HTransportOptions.java
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Novedia Group 2012.
00003  *
00004  *     This file is part of Hubiquitus.
00005  *
00006  *     Hubiquitus is free software: you can redistribute it and/or modify
00007  *     it under the terms of the GNU General Public License as published by
00008  *     the Free Software Foundation, either version 3 of the License, or
00009  *     (at your option) any later version.
00010  *
00011  *     Hubiquitus is distributed in the hope that it will be useful,
00012  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *     GNU General Public License for more details.
00015  *
00016  *     You should have received a copy of the GNU General Public License
00017  *     along with Hubiquitus.  If not, see <http://www.gnu.org/licenses/>.
00018  */
00019 
00020 package org.hubiquitus.hapi.transport;
00021 
00022 import org.hubiquitus.hapi.structures.JabberID;
00023 
00030 public class HTransportOptions {
00031          private JabberID jid = null;
00032          private String password = null;
00033          private String serverHost = null;
00034          private int serverPort = 0;
00035          private String endpointHost = null;
00036          private int endpointPort = 0;
00037          private String endpointPath = null;
00038          private String hserver = "hnode";
00039          
00040          public HTransportOptions() {
00041                   super();
00042          }
00043          
00044          /* getters and setters */
00045 
00051          public String getUsername() {
00052                   if (jid == null) {
00053                            throw new NullPointerException("Error : " + this.getClass().getName() + " need a jid");
00054                   }
00055                   
00056                   return jid.getUsername();
00057          }
00058          
00064          public String getResource() {
00065                   if (jid == null) {
00066                            throw new NullPointerException("Error : " + this.getClass().getName() + " need a jid");
00067                   }
00068                   
00069                   return jid.getResource();
00070          }
00071          
00075          public String getHserverService() {
00076                   String nodeService = null;
00077                   
00078                   if(this.jid != null) {
00079                            nodeService = this.hserver + "@" + this.jid.getDomain();
00080                   }
00081                   
00082                   return nodeService;
00083          }
00084          
00088          public String getPubsubService() {
00089                   return "pubsub" + "." + this.jid.getDomain();
00090          }
00091          
00095          public JabberID getJid() {
00096                   return jid;
00097          }
00098 
00099 
00100          public void setJid(JabberID jid) {
00101                   this.jid = jid;
00102          }
00103 
00104 
00105          public String getPassword() {
00106                   return password;
00107          }
00108 
00109 
00110          public void setPassword(String password) {
00111                   this.password = password;
00112          }
00113 
00114 
00118          public String getServerHost() {
00119                   return serverHost;
00120          }
00121 
00122 
00123          public void setServerHost(String serverHost) {
00124                   if (serverHost == null || serverHost.equals("")) {
00125                            this.serverHost = null;
00126                   } else {
00127                            this.serverHost = serverHost;
00128                   }
00129          }
00130 
00134          public int getServerPort() {
00135                   return serverPort;
00136          }
00137 
00138 
00139          public void setServerPort(int serverPort) {
00140                   this.serverPort = serverPort;
00141          }
00142 
00143 
00147          public String getEndpointHost() {
00148                   return endpointHost;
00149          }
00150 
00151 
00152          public void setEndpointHost(String endpointHost) {
00153                   this.endpointHost = endpointHost;
00154          }
00155          
00159          public int getEndpointPort() {
00160                   return endpointPort;
00161          }
00162 
00163 
00164          public void setEndpointPort(int endpointPort) {
00165                   this.endpointPort = endpointPort;
00166          }
00167 
00171          public String getEndpointPath() {
00172                   return endpointPath;
00173          }
00174 
00175 
00176          public void setEndpointPath(String endpointPath) {
00177                   this.endpointPath = endpointPath;
00178          }
00179 
00180          public String getHserver() {
00181                   return hserver;
00182          }
00183 
00184          public void setHserver(String hserver) {
00185                   this.hserver = hserver;
00186          }
00187          /* overrides */
00188          
00189          @Override
00190          public String toString() {
00191                   return "HTransportOptions [jid=" + jid + ", password=" + password
00192                                     + ", serverHost=" + serverHost + ", serverPort=" + serverPort
00193                                     + ", endpointHost=" + endpointHost + ", endpointPort="
00194                                     + endpointPort + ", endpointPath=" + endpointPath + ", hNode="
00195                                     + hserver + "]";
00196          }
00197 
00198          @Override
00199          public int hashCode() {
00200                   final int prime = 31;
00201                   int result = 1;
00202                   result = prime * result
00203                                     + ((endpointHost == null) ? 0 : endpointHost.hashCode());
00204                   result = prime * result
00205                                     + ((endpointPath == null) ? 0 : endpointPath.hashCode());
00206                   result = prime * result + endpointPort;
00207                   result = prime * result + ((hserver == null) ? 0 : hserver.hashCode());
00208                   result = prime * result + ((jid == null) ? 0 : jid.hashCode());
00209                   result = prime * result
00210                                     + ((password == null) ? 0 : password.hashCode());
00211                   result = prime * result
00212                                     + ((serverHost == null) ? 0 : serverHost.hashCode());
00213                   result = prime * result + serverPort;
00214                   return result;
00215          }
00216 
00217          @Override
00218          public boolean equals(Object obj) {
00219                   if (this == obj)
00220                            return true;
00221                   if (obj == null)
00222                            return false;
00223                   if (getClass() != obj.getClass())
00224                            return false;
00225                   HTransportOptions other = (HTransportOptions) obj;
00226                   if (endpointHost == null) {
00227                            if (other.endpointHost != null)
00228                                     return false;
00229                   } else if (!endpointHost.equals(other.endpointHost))
00230                            return false;
00231                   if (endpointPath == null) {
00232                            if (other.endpointPath != null)
00233                                     return false;
00234                   } else if (!endpointPath.equals(other.endpointPath))
00235                            return false;
00236                   if (endpointPort != other.endpointPort)
00237                            return false;
00238                   if (hserver == null) {
00239                            if (other.hserver != null)
00240                                     return false;
00241                   } else if (!hserver.equals(other.hserver))
00242                            return false;
00243                   if (jid == null) {
00244                            if (other.jid != null)
00245                                     return false;
00246                   } else if (!jid.equals(other.jid))
00247                            return false;
00248                   if (password == null) {
00249                            if (other.password != null)
00250                                     return false;
00251                   } else if (!password.equals(other.password))
00252                            return false;
00253                   if (serverHost == null) {
00254                            if (other.serverHost != null)
00255                                     return false;
00256                   } else if (!serverHost.equals(other.serverHost))
00257                            return false;
00258                   if (serverPort != other.serverPort)
00259                            return false;
00260                   return true;
00261          }
00262 }
00263 
 All Classes Namespaces Files Functions Variables