Question 5: =========== 4 UNKNOWNs: 10 points each Consider the slightly modified version of the XPath1 class dictionary where each expression has a parent has-a edge to the containing expression (see XPath2 below) in a similar way as each directory in hw 4 had a parent has-a edge to the containing directory. The class dictionary violates the DRY principle because ["parent" Exp] is repeated three times. What is the easiest way to avoid this duplication? Put your answer into UNKNOWN1. Clearly indicate which classes you modify. class dictionary XPath2: // Neven-xpath.pdf import edu.neu.ccs.demeter.dj.*; import java.util.*; XPath = List(Exp) EOF. Exp : Simple | BinaryCompound | UnaryCompound. Simple : ElementTest | WildCard common ["parent" Exp]. BinaryCompound = "(" BOp Exp Exp ")" ["parent" Exp]. UnaryCompound = "{-{" UOp Exp "}-}" ["parent" Exp]. BOp : Disjunction | Child | Descendant | Filter. UOp : Chi | Des. Chi = "/". Des = "desc". Disjunction = "|". Child = "/". Descendant = "desc" . Filter = "filt". ElementTest = Name. WildCard = "*". Name = Ident. Main = String. List(S) ~ "(" {S} ")". CountingVisitor = int extends Visitor . ParentSettingVisitor = extends Visitor . ////////////////////////////////////////////////////////////////// Now that the class dictionary is improved, the next task is to and write a program that sets the parent links in a given list of expressions. The program will visit all Binary- and Unary-objects and set the parent links of the contained subexpressions. Remember that a strategy may have a set of target classes, such as "from A via B to {C,D,E}. Find the UNKNOWNs below. Main { public static void main(String args[]) throws Exception {{ XPath m = XPath.parse(System.in); // m.display(); ClassGraph cgfull = new ClassGraph(true, false); ClassGraph cg = new ClassGraph(cgfull, "from XPath bypassing -> *,tail,* to *"); System.out.println("done"); String parents = "from XPath UNKNOWN2"; cg.traverse(m,parents,new ParentSettingVisitor()); m.display(); }} } ParentSettingVisitor { {{ public void before (BinaryCompound host) { UNKNOWN3 } public void before (UnaryCompound host) { UNKNOWN4 } }} } XPath { void display() bypassing -> *,parent,* to * (DisplayVisitor); }