I have a service method that takes a String and then replaces tags in the String with items from a tag library. As follows:
for( MetaDataDTO tag : tagValues )
{
message = message.replace( tag.getKey(), tag.getText1() );
}
Obviously; this make heaps of new strings and is BAD. But the StringBuilder replace method is cumbersome to use for multiple strings inside one string. How can I make my method more efficient?
It is for use with blocks of text such as:
Dear #firstName#, your application for #applicationType# has been #approvedRejected# sorry.
Where #firstName#, etc are the keys in a meta data database. It is also possible that tags may not be surrounded by hash characters.