I'm trying to make a string formatting mechanism, which pretty much looks like the Winamp Advanced Title Formatting.
I have some 'variables' (or metadata fields) bound to object properties, in the form %varname%. So, for example, the %title% metadata field is bound to a song title, say 'Conquest of Paradise', the %artist% metadata field is bound to the song artist, say 'Vangelis', and the %feat% metadata field is bound to the featuring artists, say 'English Chamber Choir'.
Now I want to display the song depending on a given formatting, for example:
%title%[ (by %artist%[ featuring %feat%])]
Square brackets mean don't display unless (all) metadata inside the brackets were set. Nesting of square brackets should be possible.
So abovementioned formatting string says: display the metadata field %title% and, if %artist% is set (not an empty string), display (by %artist%), but if the %feat% metadata field is also non-empty, then display that field also. In the abovementioned example, it would become:
Conquest of Paradise (by Vangelis featuring English Chamber Choir)
Now how do I make such mechanism? Where do I start?
I guess that I have to tokenize the string and then per 'section' search for metadata tags?
String.format().