Java Reference
In-Depth Information
public class CommandLineClient {
public static void main(String[] args) {
if (args.length != 2) {
System.out.println("Requested parameters: " +
"<source currency code> <target currency code>");
}
else {
CurrencyExchangeService service =
CurrencyExchangeServiceFactory.getService();
double rate =
service.requestCurrentRate(args[0], args[1]);
System.out.println("Rate is " + rate);
}
}
}
Request currency
exchange service
Determine
exchange rate
Print calculated rate
Note that this command-line client won't work yet. You know the interface
details, and you can easily create a client that uses that interface, but you still
need an implementation of that interface to be provided by the factory. Save
your work, and we'll discuss some of
IDEA
's features that can help you write
that implementation.
2.2.2
Opening files into the editor
As discussed in chapter 1, the
Project
window gives you access to all the files in
your project. You can double-click any recognized file (other than binary files, of
course) to open it in the editor; alternatively, select the file and press
F4
. You can
also load files into the editor through most of the other places where Java classes
are referenced: for example, there are direct class references in result windows
like compilation error messages, search usages windows, and so forth. When you
see a class referenced somewhere, such as in a
Find
result tool window like that
shown in figure 2.10, right-click and select the
Jump to Source
option from the
context menu (or, again, press
F4
).
Figure 2.10
This Find tool window is
the result of searching the
project for usages of the
word
Currency
. You can
click the results to jump
directly to the underlying
source by loading it into
the IDEA editor.