Which String to use in get functions in UriImplementation.java

Hello there.
I know, I’m a bit late to the party, but anyways:
I just started with the project and tried to write the get-functions in UriImplementation.java. I understand what they should do and I also know, how I will implement them. But there’s one problem I did not find a solution for (yet):
Which string do I use in for example the getScheme function? Do I use the input string of the whole program or which one? And, next question, how do I work with that string?
Thanks in advance for reading and possible answers! :slight_smile:

From the Uri interface:

	/**
	 * @return the result of parsing the non-terminal "scheme" in the grammar,
	 *         must not be {@code null}
	 */
	public String getScheme();

The getScheme scheme method returns the scheme of a valid URI as String.
The scheme is the part of the URI that is matched by the scheme category of the grammar.

For example, the sanity test prog2.tests.pub.UriParserTests::testScheme tests that for the valid URI "http://", getScheme returns the scheme part "http".

What exactly do you mean?

I understand what you wrote, but I don’t think that this answers my question.
My problem is that there is no parameter given to the getScheme function, which I can give split().
If getScheme() would have a string as argument, then I could easily use that.
But there is no argument
So which string do I split?

Maybe I’m just confused, but in my eyes this makes no sense without a parameter given…

See the public test cases and the test cases you wrote for the general working mechanism of the parser.
For instance, look at prog2.tests.pub.UriParserTests::testScheme:

  • One first creates the parser using the factory
  • Then, the URI is parsed
  • Afterward, one can access the components from the URI instance.

You can also look at the lecture nodes for general interaction with class instances.
Look at how we get the y-coordinate of a polar vector.
It is similar to how we get a component of a URI.

1 Like