001package daikon.tools.runtimechecker; 002 003import static java.nio.charset.StandardCharsets.UTF_8; 004 005import java.io.BufferedReader; 006import java.io.IOException; 007import java.io.InputStream; 008import java.io.InputStreamReader; 009import java.io.UncheckedIOException; 010 011/** 012 * A command handler handles a set of commands. A command is the first argument given to the 013 * instrumenter. 014 */ 015public class CommandHandler { 016 017 public boolean handles(String command) { 018 throw new UnsupportedOperationException(); 019 } 020 021 public boolean handle(String[] args) { 022 throw new UnsupportedOperationException(); 023 } 024 025 public void usageMessage() { 026 String[] classnameArray = getClass().getName().split("\\."); 027 String simpleClassname = classnameArray[classnameArray.length - 1]; 028 029 String docFile = simpleClassname + ".doc"; 030 InputStream in = getClass().getResourceAsStream(docFile); 031 if (in == null) { 032 System.err.println("Didn't find documentation for " + getClass()); 033 return; 034 } 035 try (BufferedReader reader = new BufferedReader(new InputStreamReader(in, UTF_8))) { 036 String line; 037 while ((line = reader.readLine()) != null) { 038 System.err.println(line); 039 } 040 } catch (IOException e) { 041 throw new UncheckedIOException("problem reading " + docFile, e); 042 } 043 } 044}