Question: Need help with a Java problem First, write a reference class called XMLToken to represent a token object. It will have only one instance variable,

Need help with a Java problemNeed help with a Java problem First, write a reference class called

First, write a reference class called XMLToken to represent a token object. It will have only one instance variable, which is the token string itself. It will have the following constructor and instance methods: public XMLToken (String token): This creates an XMLToken object and initializes the instance variable with the stringparameter passed to it. public boolean isTag() This returns true iff the token is a tag, that is, it contains at least three character and the first and last characters are . public boolean isopeningTag() This returns true iff the token is an opening tag. public boolean isClosingTag() This returns true iff the token is a closing tag. public string getTagName: For a tag, this returns the tag name, that is, the alphanumeric text inside the tag. If the token is not a tag, this returns the empty string " ". Next, write a program called CountTokens that: Prompts the user for the pathname of a fle; Redirects StdIn to read from that file; Reads in the file's contents token by token (where tokens are separated by whitespace) and, for each token: creates a XMLToken object; adds the object to the end of an array list of XML tokens. Iterates throught the array list to count the number of words, opening tags, closing tags, and malformed tokens (that is, any token that is neither a word nor a tag). Prints the counts with explanatory text. You may test your program with the files found in the XML 1 test zip file. You can easily verify that your program produces the correct output by working out the counts of each test file by hand

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!