You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Riyaz Mansoor <rm...@gmail.com> on 2005/05/26 10:13:32 UTC

[OT] MessageFormat and curly brackets

not strictly struts ... but lots of smart guys here :)

String str = "<arg name=\"minlength\" key=\"${var:minlength}\" ";
MessageFormat mf = new MessageFormat(str);

throws error saying "can't parse argument number var:minlength"

how place literal curly brackets in String such that MessageFormat 
ignores them?


thanx for helping

riyaz


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [OT] MessageFormat and curly brackets

Posted by Jason Lea <ja...@kumachan.net.nz>.
 From the java docs for MessageFormat:

 Within a String, "''" represents a single quote. A QuotedString can 
contain arbitrary characters except single quotes; the surrounding 
single quotes are removed. An UnquotedString can contain arbitrary 
characters except single quotes and left curly brackets. Thus, a string 
that should result in the formatted message "'{0}'" can be written as 
"'''{'0}''" or "'''{0}'''".

So at a guess, something like:

String str = "<arg name=\"minlength\" key=\"$'{'var:minlength}\" ";



Riyaz Mansoor wrote:

>not strictly struts ... but lots of smart guys here :)
>
>String str = "<arg name=\"minlength\" key=\"${var:minlength}\" ";
>MessageFormat mf = new MessageFormat(str);
>
>throws error saying "can't parse argument number var:minlength"
>
>how place literal curly brackets in String such that MessageFormat 
>ignores them?
>
>
>thanx for helping
>
>riyaz
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>
>  
>

-- 
Jason Lea



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org