de.smartics.exceptions.i18n.message
Class MessageParamParser

Package class diagram package MessageParamParser
java.lang.Object
  extended by de.smartics.exceptions.i18n.message.MessageParamParser

public final class MessageParamParser
     
     
extends Object

This class provides methods to parse message parameter.


Nested Class Summary
static class MessageParamParser.MessageParamInfo
          Contains the placeholderId information for one message parameter.
 
Method Summary
static List<MessageParamParser.MessageParamInfo> parse(String propertyName, String input)
          Splits the input string into message param informations.
static Map<String,List<MessageParamParser.MessageParamInfo>> parseParentMessageParam(String input)
          Parses the content of the parent message parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parse

public static List<MessageParamParser.MessageParamInfo> parse(String propertyName,
                                                              String input)
                                                       throws ParseException
Splits the input string into message param informations.

The expected format is a comma separated list of placeholderId:ognlPath strings. The OGNL path may be missing, in this case the placeholderId alone.

Example: 0:user.name,4,3:user.id.

Spaces between tokens are removed.

If the input string is null or empty, the empty list is returned.

Parameters:
propertyName - the name of the property whose message parameter is to be parsed.
input - the input string to parse.
Returns:
the list of message parameter infos.
Throws:
ParseException - if the input is violating the expected syntax.

parseParentMessageParam

public static Map<String,List<MessageParamParser.MessageParamInfo>> parseParentMessageParam(String input)
                                                                                     throws ParseException
Parses the content of the parent message parameter. The input must follow the following syntax:

property=placeholderId:ognl-path as in cause=1:message

If several properties of a referenced entity are to be displayed at different indices, separate them by commas and the information for different attributes separate by colons (;).

cause=1:cause.message,3:message,4:localizedMessage; message=5

Parameters:
input - the input string to parse.
Returns:
the parsed information. The key of the map is the name of the attribute, the value is the placeholderId information for that attribute.
Throws:
ParseException - if the input is violating the expected syntax.


Copyright © 2007-2013 Kronseder & Reiner GmbH - smartics. All Rights Reserved.