Map oMap = new HashMap();
List oFilenameList = new ArrayList();
int i = 0;
while (i < args.length)
{
if (args[i].startsWith("--album="))
{
oMap.put("album", args[i].replaceFirst("--album=", ""));
}
else if (args[i].startsWith("--artist="))
{
oMap.put("artist", args[i].replaceFirst("--artist=", ""));
}
else if (args[i].startsWith("--comment="))
{
oMap.put("comment", args[i].replaceFirst("--comment=", ""));
}
else if (args[i].startsWith("--genre="))
{
oMap.put("genre", args[i].replaceFirst("--genre=", ""));
}
else if (args[i].startsWith("--title="))
{
oMap.put("title", args[i].replaceFirst("--title=", ""));
}
else if (args[i].startsWith("--year="))
{
try
{
oMap.put("year", Integer.valueOf(args[i].replaceFirst("--year=", "")));
}
catch (Exception e)
{
throw new ID3Exception("Invalid year value specified.");
}
}
else if (args[i].startsWith("--track="))
{
try
{
String sTrack = args[i].replaceFirst("--track=", "");
int iTrackNumber;
int iTotalTracks;
if (sTrack.indexOf('/") > 0)
{
String[] asParts = sTrack.split("/", 2);
oMap.put("track", Integer.valueOf(asParts[0]));
oMap.put("total", Integer.valueOf(asParts[1]));
}
else
{
oMap.put("track", Integer.valueOf(sTrack));
}
}
catch (Exception e)
{
throw new ID3Exception("Invalid track value specified.");
}
}
else if (args[i].equals("--display"))
{
oMap.put("display", Boolean.TRUE);
}
else if (args[i].equals("--1"))
{
oMap.put("1", Boolean.TRUE);
}
else if (args[i].equals("--2"))
{
oMap.put("2", Boolean.TRUE);
}
else
{
oFilenameList.add(args[i]);
}
i++;
}
// add filenames
if (oFilenameList.size() == 0)
{
throw new ID3Exception("At least one filename must be specified.");
}
oMap.put("filenames", oFilenameList.toArray(new String[0]));
// if not version has been chosen, we will just do a v1.1 tag
if ((!oMap.containsKey("1")) && (!oMap.containsKey("2")))
{
oMap.put("1", Boolean.TRUE);
}
return oMap;