Implement a Java Interface class that parses a specific file format into an ordered dictionary and processes user commands to retrieve or manipulate multimedia records based on type and label.
Implement a Java Interface class that parses a specific file format into an ordered dictionary and processes user commands to retrieve or manipulate multimedia records based on type and label.
You are a Java developer implementing an Interface class for a multimedia ordered dictionary application. The class must read an input file, populate a BSTDictionary, and handle user commands to display or play content.
processInputFile)args[0].label.ℓ).RecordBSTDictionaryKey.determineType)Analyze the string ℓ to determine the integer type:
-, return 3 (Sound file).+, return 4 (Music file).*, return 5 (Voice file)./, return 2 (Translation)..:
gif, return 7 (Animated image).jpg, return 6 (Image).html, return 8 (Webpage).1 (Definition).extractData)-, +, *, or /, the data is the substring starting from index 1.processUserCommands, handleCommand)Use StringReader to read commands in a loop until "exit" is entered.
Process the following commands:
define w: Get record with Key(label=w, type=1). Print data or "The word w is not in the ordered dictionary".translate w: Get record with Key(label=w, type=2). Print data or "There is no definition for the word w".sound w: Get record with Key(label=w, type=3). Play sound or print "There is no sound file for w".play w: Get record with Key(label=w, type=4). Play music or print "There is no music file for w".say w: Get record with Key(label=w, type=5). Play voice or print "There is no voice file for w".show w: Get record with Key(label=w, type=6). Show image or print "There is no image file for w".animate w: Get record with Key(label=w, type=7). Show image or print "There is no animated image file for w".browse w: Get record with Key(label=w, type=8). Show webpage or print "There is no webpage called w".add w t c: Insert Record((w,t),c). If exists, print "A record with the given key (w,t) is already in the ordered dictionary".delete w k: Remove record with Key(w,k). If missing, print "No record in the ordered dictionary has key (w,k)".list prefix: Print all labels starting with prefix. If none, print "No label attributes in the ordered dictionary start with prefix [prefix]".first: Print attributes of the record with the smallest key (label,type,data).last: Print attributes of the record with the largest key (label,type,data).exit: Terminate the program.SoundPlayer.play(String) for types 3, 4, 5.PictureViewer.show(String) for types 6, 7.ShowHTML.show(String) for type 8.MultimediaException and handle errors appropriately.StringReader for reading the input file; use BufferedReader with FileReader.