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