001 /** 002 * 003 * Licensed to the Apache Software Foundation (ASF) under one or more 004 * contributor license agreements. See the NOTICE file distributed with 005 * this work for additional information regarding copyright ownership. 006 * The ASF licenses this file to You under the Apache License, Version 2.0 007 * (the "License"); you may not use this file except in compliance with 008 * the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 package org.apache.camel.component.irc; 019 020 import org.apache.camel.RuntimeCamelException; 021 022 import java.net.URI; 023 024 public class IrcConfiguration implements Cloneable { 025 String target; 026 String hostname; 027 String password; 028 String nickname; 029 String realname; 030 String username; 031 boolean persistent = true; 032 boolean colors = true; 033 boolean onNick = true; 034 boolean onQuit = true; 035 boolean onJoin = true; 036 boolean onKick = true; 037 boolean onMode = true; 038 boolean onPart = true; 039 boolean onTopic = true; 040 boolean onPrivmsg = true; 041 int[] ports = {6667, 6668, 6669}; 042 043 public IrcConfiguration() { 044 } 045 046 public IrcConfiguration(String hostname, String nickname, String displayname, String target) { 047 this.target = target; 048 this.hostname = hostname; 049 this.nickname = nickname; 050 this.username = nickname; 051 this.realname = displayname; 052 } 053 054 public IrcConfiguration(String hostname, String username, String password, String nickname, String displayname, String target) { 055 this.target = target; 056 this.hostname = hostname; 057 this.username = username; 058 this.password = password; 059 this.nickname = nickname; 060 this.realname = displayname; 061 } 062 063 public IrcConfiguration copy() { 064 try { 065 return (IrcConfiguration) clone(); 066 } 067 catch (CloneNotSupportedException e) { 068 throw new RuntimeCamelException(e); 069 } 070 } 071 072 public String getCacheKey() { 073 return hostname + ":" + nickname; 074 } 075 076 public void configure(URI uri) { 077 setNickname(uri.getUserInfo()); 078 setUsername(uri.getUserInfo()); 079 setRealname(uri.getUserInfo()); 080 setHostname(uri.getHost()); 081 setTarget(uri.getPath().substring(1)); 082 } 083 084 public String getHostname() { 085 return hostname; 086 } 087 088 public void setHostname(String hostname) { 089 this.hostname = hostname; 090 } 091 092 public String getPassword() { 093 return password; 094 } 095 096 public void setPassword(String password) { 097 this.password = password; 098 } 099 100 public String getNickname() { 101 return nickname; 102 } 103 104 public void setNickname(String nickname) { 105 this.nickname = nickname; 106 } 107 108 public String getRealname() { 109 return realname; 110 } 111 112 public void setRealname(String realname) { 113 this.realname = realname; 114 } 115 116 public String getUsername() { 117 return username; 118 } 119 120 public void setUsername(String username) { 121 this.username = username; 122 } 123 124 public int[] getPorts() { 125 return ports; 126 } 127 128 public void setPorts(int[] ports) { 129 this.ports = ports; 130 } 131 132 public String getTarget() { 133 return target; 134 } 135 136 public void setTarget(String target) { 137 this.target = target; 138 } 139 140 public boolean isPersistent() { 141 return persistent; 142 } 143 144 public void setPersistent(boolean persistent) { 145 this.persistent = persistent; 146 } 147 148 public boolean isColors() { 149 return colors; 150 } 151 152 public void setColors(boolean colors) { 153 this.colors = colors; 154 } 155 156 public boolean isOnNick() { 157 return onNick; 158 } 159 160 public void setOnNick(boolean onNick) { 161 this.onNick = onNick; 162 } 163 164 public boolean isOnQuit() { 165 return onQuit; 166 } 167 168 public void setOnQuit(boolean onQuit) { 169 this.onQuit = onQuit; 170 } 171 172 public boolean isOnJoin() { 173 return onJoin; 174 } 175 176 public void setOnJoin(boolean onJoin) { 177 this.onJoin = onJoin; 178 } 179 180 public boolean isOnKick() { 181 return onKick; 182 } 183 184 public void setOnKick(boolean onKick) { 185 this.onKick = onKick; 186 } 187 188 public boolean isOnMode() { 189 return onMode; 190 } 191 192 public void setOnMode(boolean onMode) { 193 this.onMode = onMode; 194 } 195 196 public boolean isOnPart() { 197 return onPart; 198 } 199 200 public void setOnPart(boolean onPart) { 201 this.onPart = onPart; 202 } 203 204 public boolean isOnTopic() { 205 return onTopic; 206 } 207 208 public void setOnTopic(boolean onTopic) { 209 this.onTopic = onTopic; 210 } 211 212 public boolean isOnPrivmsg() { 213 return onPrivmsg; 214 } 215 216 public void setOnPrivmsg(boolean onPrivmsg) { 217 this.onPrivmsg = onPrivmsg; 218 } 219 220 public String toString() { 221 return "IrcConfiguration{" + 222 "target='" + target + '\'' + 223 ", hostname='" + hostname + '\'' + 224 ", password='" + password + '\'' + 225 ", nickname='" + nickname + '\'' + 226 ", realname='" + realname + '\'' + 227 ", username='" + username + '\'' + 228 ", persistent=" + persistent + 229 ", colors=" + colors + 230 ", onNick=" + onNick + 231 ", onQuit=" + onQuit + 232 ", onJoin=" + onJoin + 233 ", onKick=" + onKick + 234 ", onMode=" + onMode + 235 ", onPart=" + onPart + 236 ", onTopic=" + onTopic + 237 ", onPrivmsg=" + onPrivmsg + 238 ", ports=" + ports + 239 '}'; 240 } 241 }