Source Code Cross Referenced for Channel.java in  » Workflow-Engines » Dalma » dalma » endpoints » irc » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » Dalma » dalma.endpoints.irc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package dalma.endpoints.irc;
002:
003:        import f00f.net.irc.martyr.clientstate.Member;
004:        import f00f.net.irc.martyr.commands.InviteCommand;
005:        import f00f.net.irc.martyr.commands.JoinCommand;
006:        import f00f.net.irc.martyr.commands.KickCommand;
007:        import f00f.net.irc.martyr.commands.PartCommand;
008:        import f00f.net.irc.martyr.commands.RawCommand;
009:        import f00f.net.irc.martyr.commands.MessageCommand;
010:        import f00f.net.irc.martyr.commands.TopicCommand;
011:
012:        import java.util.ArrayList;
013:        import java.util.Collection;
014:        import java.util.Enumeration;
015:        import java.util.List;
016:        import java.io.Serializable;
017:
018:        /**
019:         * Represents a channel in IRC.
020:         *
021:         * @author Kohsuke Kawaguchi
022:         */
023:        public final class Channel extends Session {
024:            private final String name;
025:
026:            /**
027:             * True if the endpoint is a member of this channel.
028:             */
029:            private boolean joined;
030:
031:            public Channel(IRCEndPoint endpoint, String name) {
032:                super (endpoint);
033:                this .name = name;
034:            }
035:
036:            /**
037:             * Gets the channel name, such as "#dalma"
038:             *
039:             * @return never null.
040:             */
041:            public String getName() {
042:                return name;
043:            }
044:
045:            /**
046:             * Join this channel.
047:             *
048:             * @throws IllegalStateException
049:             *      if we've already joined this channel.
050:             */
051:            public synchronized void join() {
052:                makeSureNotJoined();
053:                endpoint.connection.sendCommand(new JoinCommand(name));
054:                joined = true;
055:            }
056:
057:            /**
058:             * Join this channel.
059:             *
060:             * @throws IllegalStateException
061:             *      if we've already joined this channel.
062:             */
063:            public synchronized void join(String secret) {
064:                makeSureNotJoined();
065:                endpoint.connection.sendCommand(new JoinCommand(name, secret));
066:                joined = true;
067:            }
068:
069:            /**
070:             * Returns true if we
071:             */
072:            public synchronized boolean isJoined() {
073:                return getChannelInfo() != null;
074:            }
075:
076:            private synchronized void makeSureNotJoined() {
077:                if (joined)
078:                    throw new IllegalStateException("already joined");
079:            }
080:
081:            /**
082:             * Invites the specified user to this channel.
083:             */
084:            public void invite(Buddy buddy) {
085:                endpoint.connection.sendCommand(new InviteCommand(buddy.name,
086:                        name));
087:            }
088:
089:            /**
090:             * Kicks out the specified user from this channel.
091:             */
092:            public void kick(Buddy buddy, String comment) {
093:                endpoint.connection.sendCommand(new KickCommand(name,
094:                        buddy.name, comment));
095:            }
096:
097:            public void knock(String msg) {
098:                makeSureNotJoined();
099:                endpoint.connection.sendCommand(new RawCommand(name, msg));
100:            }
101:
102:            /**
103:             * Gets all the people on this channel.
104:             */
105:            public Collection<Buddy> getMembers() {
106:                List<Buddy> buddies = new ArrayList<Buddy>();
107:                Enumeration members = getChannelInfo().getMembers();
108:                while (members.hasMoreElements()) {
109:                    Member m = (Member) members.nextElement();
110:                    Buddy b = endpoint.getBuddy(m.getNick().getNick());
111:                    buddies.add(b);
112:                }
113:                return buddies;
114:            }
115:
116:            /**
117:             * Gets the object that represents information about this channel
118:             * from martyr.
119:             *
120:             * @return null
121:             *      if we aren't joined this channel yet.
122:             */
123:            private f00f.net.irc.martyr.clientstate.Channel getChannelInfo() {
124:                return endpoint.connection.getClientState().getChannel(name);
125:            }
126:
127:            /**
128:             * Gets the channel topic.
129:             *
130:             * @return
131:             *      never null.
132:             */
133:            public String getTopic() {
134:                return getChannelInfo().getTopic();
135:            }
136:
137:            public void setTopic(String newTopic) {
138:                endpoint.connection
139:                        .sendCommand(new TopicCommand(name, newTopic));
140:            }
141:
142:            public void setMode(Object... modes) {
143:                // TODO: implement this method later
144:                throw new UnsupportedOperationException();
145:            }
146:
147:            /**
148:             * Sends a message to this {@link Channel}.
149:             */
150:            public void send(String message) {
151:                endpoint.connection.sendCommand(new MessageCommand(name,
152:                        message));
153:            }
154:
155:            /**
156:             * Sends the 'PART' message and leaves from this channel.
157:             */
158:            public synchronized void close() {
159:                endpoint.connection.sendCommand(new PartCommand(name));
160:                joined = false;
161:            }
162:
163:            protected Object writeReplace() {
164:                return new Moniker(endpoint, name);
165:            }
166:
167:            private static final class Moniker implements  Serializable {
168:                private final IRCEndPoint endPoint;
169:                private final String channelName;
170:
171:                public Moniker(IRCEndPoint endPoint, String channelName) {
172:                    this .endPoint = endPoint;
173:                    this .channelName = channelName;
174:                }
175:
176:                private Object readResolve() {
177:                    return endPoint.getChannel(channelName);
178:                }
179:
180:                private static final long serialVersionUID = 1L;
181:            }
182:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.