PageRenderTime 50ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/raptor/src/raptor/chat/ChatEvent.java

http://raptor-chess-interface.googlecode.com/
Java | 158 lines | 71 code | 20 blank | 67 comment | 0 complexity | f52efeb328438ebe73abb83d0c1b419c MD5 | raw file
Possible License(s): Apache-2.0, GPL-2.0, IPL-1.0, BSD-3-Clause, LGPL-2.0, CC-BY-SA-3.0, AGPL-1.0, LGPL-2.1
  1. /**
  2. * New BSD License
  3. * http://www.opensource.org/licenses/bsd-license.php
  4. * Copyright 2009-2011 RaptorProject (http://code.google.com/p/raptor-chess-interface/)
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  8. *
  9. * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  10. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  11. * Neither the name of the RaptorProject nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
  12. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  13. */
  14. package raptor.chat;
  15. /**
  16. * A class defining an inbound message received from a server.
  17. */
  18. public class ChatEvent {
  19. protected String channel;
  20. protected String gameId;
  21. protected String message;
  22. protected String source;
  23. protected long time;
  24. protected ChatType type;
  25. protected boolean hasSoundBeenHandled;
  26. public ChatEvent() {
  27. time = System.currentTimeMillis();
  28. }
  29. public ChatEvent(String source, ChatType type, String message) {
  30. this();
  31. this.source = source;
  32. this.type = type;
  33. this.message = message;
  34. }
  35. public ChatEvent(String source, ChatType type, String message, String gameId) {
  36. this(source, type, message);
  37. this.gameId = gameId;
  38. }
  39. /**
  40. * If the chat event represents a channel tell this contains the channel
  41. * number. Otherwise it is null.
  42. */
  43. public String getChannel() {
  44. return channel;
  45. }
  46. /**
  47. * If the chat event represents a tell about a game, i.e.
  48. * kibitz,whisper,etc, this is the game id. Otherwise it is null.
  49. *
  50. * @return
  51. */
  52. public String getGameId() {
  53. return gameId;
  54. }
  55. /**
  56. * Returns the entire server message.
  57. *
  58. * @return Entire message involved in this ChatEvent.
  59. */
  60. public String getMessage() {
  61. return message;
  62. }
  63. /**
  64. * This is the source of the ChatEvent. If it is a tell event, it is the
  65. * user sending the tell. If it is a channel tell event, it is the user
  66. * sending the tell to the channel. If its a shout or c-shout, its the
  67. * person shouting. If its a kibitz or whisper, its the person kibitzing or
  68. * whispering. If its a say, its the person sending the say.
  69. *
  70. * @return The user name of the person involved in this ChatEvent.
  71. */
  72. public String getSource() {
  73. return source;
  74. }
  75. /**
  76. * The time in EPOC the chat event was created.
  77. *
  78. * @return ChatEvent creation timestamp in EPOC millisconds.
  79. */
  80. public long getTime() {
  81. return time;
  82. }
  83. /**
  84. * @return The type of ChatEvent.
  85. * @see ChatTypes.
  86. */
  87. public ChatType getType() {
  88. return type;
  89. }
  90. /**
  91. * Returns true if this event has been handled.
  92. */
  93. public boolean hasSoundBeenHandled() {
  94. return hasSoundBeenHandled;
  95. }
  96. public void setChannel(String channel) {
  97. this.channel = channel;
  98. }
  99. public void setGameId(String gameId) {
  100. this.gameId = gameId;
  101. }
  102. /**
  103. * Sets the flag denoting this event has been handled.
  104. */
  105. public void setHasSoundBeenHandled(boolean hasSoundBeenHandled) {
  106. this.hasSoundBeenHandled = hasSoundBeenHandled;
  107. }
  108. public void setMessage(String message) {
  109. this.message = message;
  110. }
  111. public void setSource(String source) {
  112. this.source = source;
  113. }
  114. /**
  115. * @param time
  116. * The time that this chat event occurred.
  117. */
  118. public void setTime(long time) {
  119. this.time = time;
  120. }
  121. /**
  122. * @param type
  123. * The type of ChatEvent this is.
  124. * @see ChatTypes.
  125. */
  126. public void setType(ChatType type) {
  127. this.type = type;
  128. }
  129. /**
  130. * Dumps information about this ChatEvent to a string.
  131. */
  132. @Override
  133. public String toString() {
  134. return "ChatEvent: source=" + source + " type=" + type.name()
  135. + " gameId=" + gameId + " channel=" + channel
  136. + " message='" + message + "'";
  137. }
  138. }