Previously Id asked this question Putting a simple expression language into java about allowing the user to enter a formatting mask with support for if statements, substrings and the like.
The answer to use Script Engine with javascript worked , however the javascript syntax is not very easy for users
(albumartist.length>0 ? albumartist +'-' :(artist.length>0 ? artist + '-' : ' ')) + (album.length>0 ? album + '-' :'') + (trackno.length>0 ? trackno + '-' :'') + title
could give output
U2-Boy-Twilight-02
but an easier syntax would be something like
if(%albumartist%,%artist%)-if(%album%,%album%-)if(%trackno%,%trackno-)%title
The main difference being is we don’t have to explicity concatenate strings with ‘+’ or quote string literals with ‘ ‘
which is similar to the Foobar title formatting reference detailed at http://wiki.hydrogenaudio.org/index.php?title=Foobar2000:Title_Formatting_Reference#.24if2.28a.2Celse.29 but there is not a physical implemention of this I could parse in Java.
Any ideas ?
You can read more about engines here, there and there.
Finally you could “simply” parse the FooBar2000 syntax in Java.
To summarise, what you are trying to do does not sound like an easy task – good luck! 😉