Reputation: 399
We have many property files inside our java project. I don't understand the meaning of the integer values inside the curly braces.
Example:
validation.error=Input Validation Failed for field:[{0}]. Reason:[{1}]
Upvotes: 5
Views: 3419
Reputation: 10249
The curly brackets are placeholders.
You can use placeholders in your messages and replace them with location-appropriate values at runtime based on the semantics of your user's language. For this you use the MessageFormat class.
Upvotes: 1
Reputation: 178253
They are for use with the MessageFormat
class. Something of the form {n}
, where n
is a number, is a placeholder for a dynamic value.
There are additional things you can add to the placeholder for formatting purposes; see the linked Javadocs above for more information.
Upvotes: 3
Reputation: 73528
They're placeholders for parameters. When used, two parameters would be passed to indicate the name of the field and the reason for failure.
Upvotes: 2