Client
Class Statement

java.lang.Object
  extended by Client.Statement

public class Statement
extends java.lang.Object

A class which stores information about a message anyone sent. Includes useful methods for printing out statements to a JTextPane.


Field Summary
static java.lang.String[] emoticons
          All of the possible emoticons.
static java.util.HashMap<java.lang.String,java.lang.String> textToEmoticon
          A HashMap linking emoticon strings (above) to file locations.
 
Constructor Summary
Statement(java.lang.String username, java.lang.String message)
          Construct a new Statement.
 
Method Summary
static java.lang.String colorate(java.lang.String string)
          Hashes the input string, and returns the input string surrounded by html to make it a random color determined by the hash.
static java.lang.String emotify(java.lang.String message)
          Adds html for emoticons.
static java.lang.String htmlimg(java.lang.String src)
          Returns a html img thing for a particular image address.
static java.lang.String htmlLineBreak(java.lang.String string)
          Inputs line breaks so that the line will wrap around after 34 monospace characters.
static java.util.HashMap<java.lang.String,java.lang.String> initializeHashmap()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

emoticons

public static java.lang.String[] emoticons
All of the possible emoticons.


textToEmoticon

public static java.util.HashMap<java.lang.String,java.lang.String> textToEmoticon
A HashMap linking emoticon strings (above) to file locations.

Constructor Detail

Statement

public Statement(java.lang.String username,
                 java.lang.String message)
Construct a new Statement.

Parameters:
username - who said the statement
message - what the statement is
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
this statement, formatted to play nice in a ConversationPane. Username is highlighted with a random color, and line breaks are placed in to avoid stretching outside the scrollpane. Uses HTML.

colorate

public static java.lang.String colorate(java.lang.String string)
Hashes the input string, and returns the input string surrounded by html to make it a random color determined by the hash.

Parameters:
string - the string to colorate
Returns:
bolded and colored string, as HTML

htmlLineBreak

public static java.lang.String htmlLineBreak(java.lang.String string)
Inputs line breaks so that the line will wrap around after 34 monospace characters. Ignores anything which is inside the of HTML. This is necessary to get strings to play nice inside the JTextPane.

Parameters:
string - the string to insert linebreaks to
Returns:
string, with linebreaks (
), as HTML

initializeHashmap

public static java.util.HashMap<java.lang.String,java.lang.String> initializeHashmap()
Returns:
the HashMap of emoticons to file locations

emotify

public static java.lang.String emotify(java.lang.String message)
Adds html for emoticons.

Parameters:
message - the message to add emoticons to
Returns:
message, with interspersed where emoticons need to be

htmlimg

public static java.lang.String htmlimg(java.lang.String src)
Returns a html img thing for a particular image address.

Parameters:
src - where the image is located
Returns: