ymsg.support
Class EmoteManager

Object
  extended byEmoteManager

public class EmoteManager
extends Object

Creates emote texts for chat rooms. Emotes enable shortcut 'action' messages to be broadcast to a chat room, along the lines of "Waves" or "Winks". It is also possible to mention a specific user in an Emote, although the message still goes to the entire room - for example "Waves at fred" or "Winks at jenny".

Each Emote therefore has a dual form, the 'room' form, and the 'user' form. In the user form, the string "%s" is used as a placeholder for the name of the targeted user - for example "Waves at %s" when targeted at "jenny" becomes "Waves at jenny".

Yahoo allows users to add their own Emotes via a configuration file which is read and appended to the default Emotes Yahoo holds internally. This class mimics this behaviour, by loading and building lists of Emotes from various input sources. The class holds an array of default Emotes. When creating an instance, these defaults can either be included or ignored. Any Emotes loaded by this class which share the same name as an Emote already defined will override the original.

The standard file format for custom Yahoo Emotes is:

	# Comment line
	<name>\<room form>\<user form>
	
The sequence %s is a placeholder for the target user's name in a room Emote. For example:
	# This is a winks Emote
	Winks\Winks.\Winks at %s.
	# This is a waves Emote
	Waves\Waves at room.\Waves at %s.
	

Since:
1.0

Constructor Summary
EmoteManager(File fl, boolean b)
          Creates an Emote list from a given file.
EmoteManager(String fn, boolean b)
          Creates an Emote list from a given filename.
EmoteManager(URL u, boolean b)
          Creates an Emote list from a given URL.
 
Method Summary
static String encodeEmote(String u, String em)
          Utility method to combine an Emote string (from getRoomEmote) with the supplied username.
 Vector getErrors()
          Returns the loading/parsing errors which occured during creation.
 Vector getNames()
          Returns a list of all Emote names held by this manager.
 String getRoomEmote(String name)
          Returns the room version of a given Emote.
 String getUserEmote(String name)
          Returns the user version of a given Emote.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmoteManager

public EmoteManager(File fl,
                    boolean b)
Creates an Emote list from a given file. The facility to pre-load the default Emotes before the file is processed is optional.

Parameters:
fl - file with emote config
b - true to pre-load default Emotes
Since:
1.0

EmoteManager

public EmoteManager(String fn,
                    boolean b)
Creates an Emote list from a given filename. The facility to pre-load the default Emotes before the file is processed is optional.

Parameters:
fn - file with emote config
b - true to pre-load default Emotes
Since:
1.0

EmoteManager

public EmoteManager(URL u,
                    boolean b)
Creates an Emote list from a given URL. The facility to pre-load the default Emotes before the file is processed is optional.

Parameters:
u - file with emote config
b - true to pre-load default Emotes
Since:
1.0
Method Detail

getErrors

public Vector getErrors()
Returns the loading/parsing errors which occured during creation. The Vector holds String objects which detail the various errors while attempting to load and parse the Emote configurations. If the vector is empty, no errors occured.

Returns:
Vector of error strings
Since:
1.0

getRoomEmote

public String getRoomEmote(String name)
Returns the room version of a given Emote. Returns null if it doesn't exist.

Parameters:
name - name of Emote
Returns:
Emote text, or null
Since:
1.0

getUserEmote

public String getUserEmote(String name)
Returns the user version of a given Emote. Returns null if it doesn't exist.

Parameters:
name - name of Emote
Returns:
Emote text, or null
Since:
1.0

getNames

public Vector getNames()
Returns a list of all Emote names held by this manager.

Returns:
Vector of Emote name strings
Since:
1.0

encodeEmote

public static String encodeEmote(String u,
                                 String em)
Utility method to combine an Emote string (from getRoomEmote) with the supplied username. Any reference to %s in the Emote string is replaced with the contents of the username string. This method is not fooled by "%s" occurances inside the username string itself.

Parameters:
u - target username
em - Emote text
Since:
1.0