it.amattioli.workstate.exceptions
Class KeyedMessage

Show UML class diagram
java.lang.Object
  extended by it.amattioli.workstate.exceptions.KeyedMessage

public class KeyedMessage
extends Object

A message identified by a key inside a bundle. You can also pass a set of parameters that can be substituted inside the message.


Constructor Summary
KeyedMessage(String key)
          Construct a message identified by the given key.
KeyedMessage(String key, Map<String,String> parameters)
          Construct a message identified by the given key and with the given parameters.
 
Method Summary
 void addParameter(String tag, String value)
          Add a parameter to the message.
 boolean equals(Object o)
          Two messages are equal if they have the same key and the same parameters.
 String getKey()
          Returns the message key.
 Map<String,String> getParameters()
          Return an immutable map containing the message parameters.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyedMessage

public KeyedMessage(String key)
Construct a message identified by the given key.

Parameters:
key - the key that identifies the message inside a message bundle
Throws:
NullPointerException - if the parameter is null

KeyedMessage

public KeyedMessage(String key,
                    Map<String,String> parameters)
Construct a message identified by the given key and with the given parameters.

Parameters:
key - the key that identifies the message inside a message bundle
parameters - the parameters to be substituted inside a message
Method Detail

addParameter

public void addParameter(String tag,
                         String value)
Add a parameter to the message.

Parameters:
tag - the parameter key
value - the value to be substituted inside the message
Throws:
IllegalArgumentException - if the message already contains a parameter with the same key

getKey

public String getKey()
Returns the message key.

Returns:
the message key

getParameters

public Map<String,String> getParameters()
Return an immutable map containing the message parameters.

Returns:
an immutable map containing the message parameters

equals

public boolean equals(Object o)
Two messages are equal if they have the same key and the same parameters.

Overrides:
equals in class Object
Parameters:
o - the object to be compared to this for equality
Returns:
true if and only if the parameter is a message with the same key and the same parameters of this one


Copyright © 2011. All Rights Reserved.