package yokohama.unit;

import java.io.InputStream;
import java.io.PrintStream;

public class Docy2Java implements Command {
    @Override
    public int run(InputStream in, PrintStream out, PrintStream err, String... args) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}

@@ -19,16 +19,45 @@
 nit;%0D%0A%0D%0A
+import java.io.IOException;%0D%0A
 import j
@@ -110,228 +110,2886 @@
 m;%0D%0A
-%0D%0Apublic class Docy2Java implements Command %7B%0D%0A    @Override%0D%0A    public int run(InputStream in, PrintStream out, PrintStream err, String... args) %7B%0D%0A        throw new UnsupportedOperationException(%22Not supported yet.%22);
+import java.io.PrintWriter;%0D%0Aimport java.net.URI;%0D%0Aimport java.nio.file.Path;%0D%0Aimport java.nio.file.Paths;%0D%0Aimport java.util.List;%0D%0Aimport java.util.Optional;%0D%0Aimport org.apache.commons.cli.BasicParser;%0D%0Aimport org.apache.commons.cli.CommandLine;%0D%0Aimport org.apache.commons.cli.HelpFormatter;%0D%0Aimport org.apache.commons.cli.OptionBuilder;%0D%0Aimport org.apache.commons.cli.Options;%0D%0Aimport org.apache.commons.cli.ParseException;%0D%0Aimport org.apache.commons.io.FilenameUtils;%0D%0Aimport org.apache.commons.io.IOUtils;%0D%0Aimport yokohama.unit.translator.TranslatorUtils;%0D%0A%0D%0Apublic class Docy2Java implements Command %7B%0D%0A    static Options constructOptions() %7B%0D%0A        Options options = new Options();%0D%0A        options.addOption(OptionBuilder%0D%0A                .hasArg()%0D%0A                .withArgName(%22name%22)%0D%0A                .withDescription(%22Package name of generated source code%22)%0D%0A                .create(%22package%22));%0D%0A        options.addOption(OptionBuilder%0D%0A                .withDescription(%22Print a synopsis of standard options%22)%0D%0A                .create(%22help%22));%0D%0A        return options;%0D%0A    %7D%0D%0A    @Override%0D%0A    public int run(InputStream in, PrintStream out, PrintStream err, String... args) %7B%0D%0A        try %7B%0D%0A            Options options = constructOptions();%0D%0A            CommandLine commandLine = new BasicParser().parse(options, args);%0D%0A            if (commandLine.hasOption(%22help%22)) %7B%0D%0A                PrintWriter pw = new PrintWriter(err);%0D%0A                new HelpFormatter().printHelp(%0D%0A                        pw,%0D%0A                        80,%0D%0A                        %22docy2java %3Coptions%3E %3Csource file%3E%22,%0D%0A                        %22%22,%0D%0A                        options,%0D%0A                        1,%0D%0A                        1,%0D%0A                        %22%22,%0D%0A                        true%0D%0A                );%0D%0A                pw.flush();%0D%0A                return Command.EXIT_SUCCESS;%0D%0A            %7D%0D%0A            @SuppressWarnings(%22unchecked%22) List%3CString%3E files = commandLine.getArgList();%0D%0A            String file = files.get(0);%0D%0A            String className = FilenameUtils.getBaseName(file);%0D%0A            Path path = Paths.get(file).toAbsolutePath();%0D%0A            URI uri = path.toUri();%0D%0A            String packageName = commandLine.getOptionValue(%22package%22);%0D%0A            String docy = IOUtils.toString(uri);%0D%0A            String java = TranslatorUtils.docyToJava(%0D%0A                    Optional.of(path),%0D%0A                    docy,%0D%0A                    className,%0D%0A                    packageName);%0D%0A            out.print(java);%0D%0A            return Command.EXIT_SUCCESS;%0D%0A        %7D catch (ParseException%7CIOException e) %7B%0D%0A            err.println(%22docy2java: %22 + e.getMessage());%0D%0A            err.println(%22Usage: docy2java %3Coptions%3E %3Csource file%3E%22);%0D%0A            err.println(%22use -help for a list of possible options%22);%0D%0A            return Command.EXIT_FAILURE;%0D%0A        %7D
 %0D%0A  

Implement Docy2Java