org.vladnput
Class VladMessages

java.lang.Object
  extended by org.vladnput.VladMessages

public class VladMessages
extends java.lang.Object

Class that defines valid message names and stores the messages for an individual type, parameter, parameter match, or message defaults.

Author:
Patrick Higgins

Field Summary
static java.lang.String MSG_KEY
          Name of the generic message
static java.lang.String REQ_MSG_KEY
          Name of the required message
static java.lang.String TOO_FEW_MSG_KEY
          Name of the too few values given message
static java.lang.String TOO_MANY_MSG_KEY
          Name of the too many values given message
static java.lang.String UNKNOWN_PARAM_MSG_KEY
          Name of the unknown parameter message
static java.util.Set<java.lang.String> VALID_KEYS
          Set of valid message names.
 
Constructor Summary
VladMessages(java.util.Map args)
          Extracts all the arguments from args for which isValidMessageName() returns true and removes them from args.
 
Method Summary
 java.lang.String getMessage(java.lang.String name, VladMessageVars vars)
          Returns the message named name after replacing any variables within it with the values from vars.
static boolean isValidFormat(java.lang.String message)
          Checks message to ensure that any variables references within it are well formed.
static boolean isValidMessageName(java.lang.String name)
          Checks if name is a valid message name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MSG_KEY

public static final java.lang.String MSG_KEY
Name of the generic message

See Also:
Constant Field Values

REQ_MSG_KEY

public static final java.lang.String REQ_MSG_KEY
Name of the required message

See Also:
Constant Field Values

TOO_MANY_MSG_KEY

public static final java.lang.String TOO_MANY_MSG_KEY
Name of the too many values given message

See Also:
Constant Field Values

TOO_FEW_MSG_KEY

public static final java.lang.String TOO_FEW_MSG_KEY
Name of the too few values given message

See Also:
Constant Field Values

UNKNOWN_PARAM_MSG_KEY

public static final java.lang.String UNKNOWN_PARAM_MSG_KEY
Name of the unknown parameter message

See Also:
Constant Field Values

VALID_KEYS

public static final java.util.Set<java.lang.String> VALID_KEYS
Set of valid message names.

Constructor Detail

VladMessages

public VladMessages(java.util.Map args)
Extracts all the arguments from args for which isValidMessageName() returns true and removes them from args. Arguments that are not valid message names are ignored.

Parameters:
args - Arguments
Method Detail

isValidMessageName

public static boolean isValidMessageName(java.lang.String name)
Checks if name is a valid message name. Valid message names are either in VALID_KEYS or end with "_msg".

Parameters:
name - Message name
Returns:
true if name is a valid message name, false otherwise

isValidFormat

public static boolean isValidFormat(java.lang.String message)
Checks message to ensure that any variables references within it are well formed.

Parameters:
message - The message
Returns:
true if message is valid, false otherwise

getMessage

public java.lang.String getMessage(java.lang.String name,
                                   VladMessageVars vars)
Returns the message named name after replacing any variables within it with the values from vars.

Parameters:
name - Message name
vars - Variable values
Returns:
Interpolated message, or null if the message does not exist


Copyright © 2009 Patrick Higgins. All Rights Reserved.