/** * Return an InputStream for the man page for the named command. */ public static BufferedReader getManPage(String commandName, CommandModel model) { Class clazz = model.getCommandClass(); if (clazz == null) { return null; } return ManPageFinder.getCommandManPage(commandName, clazz.getName(), Locale.getDefault(), clazz.getClassLoader(), logger); }
/** * Get the man page for the given command for the given locale * using the given classloader. * * @param cmdName the command name * @param cmdClass the command class * @param locale the locale to be used to find the man page * @param classLoader the class loader to be used to find the man page */ public static BufferedReader getCommandManPage( String cmdName, String cmdClass, Locale locale, ClassLoader classLoader, Logger logger) { InputStream s = null; Iterator it = getPossibleLocations(cmdName, cmdClass, locale, logger); while (s == null && it.hasNext()) { s = classLoader.getResourceAsStream((String)it.next()); } if (s == null) return null; Reader r; try { r = new InputStreamReader(s, "utf-8"); } catch (UnsupportedEncodingException ex) { r = new InputStreamReader(s); } return new BufferedReader(r); }
/** * Return an InputStream for the man page for the named command. */ public static BufferedReader getManPage(String commandName, CommandModel model) { Class clazz = model.getCommandClass(); if (clazz == null) { return null; } return ManPageFinder.getCommandManPage(commandName, clazz.getName(), Locale.getDefault(), clazz.getClassLoader(), logger); }
/** * Get the man page for the given command for the given locale * using the given classloader. * * @param cmdName the command name * @param cmdClass the command class * @param locale the locale to be used to find the man page * @param classLoader the class loader to be used to find the man page */ public static BufferedReader getCommandManPage( String cmdName, String cmdClass, Locale locale, ClassLoader classLoader, Logger logger) { InputStream s = null; Iterator it = getPossibleLocations(cmdName, cmdClass, locale, logger); while (s == null && it.hasNext()) { s = classLoader.getResourceAsStream((String)it.next()); } if (s == null) return null; Reader r; try { r = new InputStreamReader(s, "utf-8"); } catch (UnsupportedEncodingException ex) { r = new InputStreamReader(s); } return new BufferedReader(r); }
/** * Return a BufferedReader for the man page for this command, * or null if not found. */ public BufferedReader getManPage() { String commandName = getName(); if (commandName.length() == 0) throw new IllegalArgumentException("Command name cannot be empty"); // special case "help" --> "asadmin" if (commandName.equals("help")) commandName = "asadmin"; return ManPageFinder.getCommandManPage( commandName, getClass().getName(), Locale.getDefault(), getClass().getClassLoader(), logger); }
/** * Get the man page for the given command for the given locale * using the given classloader. * * @param cmdName the command name * @param cmdClass the command class * @param locale the locale to be used to find the man page * @param classLoader the class loader to be used to find the man page */ public static BufferedReader getCommandManPage( String cmdName, String cmdClass, Locale locale, ClassLoader classLoader, Logger logger) { InputStream s = null; Iterator it = getPossibleLocations(cmdName, cmdClass, locale, logger); while (s == null && it.hasNext()) { s = classLoader.getResourceAsStream((String)it.next()); } if (s == null) return null; Reader r; try { r = new InputStreamReader(s, "utf-8"); } catch (UnsupportedEncodingException ex) { r = new InputStreamReader(s); } return new BufferedReader(r); }
/** * Return a BufferedReader for the man page for this command, * or null if not found. */ public BufferedReader getManPage() { String commandName = getName(); if (commandName.length() == 0) throw new IllegalArgumentException("Command name cannot be empty"); // special case "help" --> help for the command if (commandName.equals("help")) commandName = programOpts.getCommandName(); return ManPageFinder.getCommandManPage( commandName, getClass().getName(), Locale.getDefault(), getClass().getClassLoader(), logger); }
/** * Try to find a local version of the man page for this command. */ private BufferedReader getLocalManPage() { logger.fine(strings.get("NoRemoteManPage")); String cmdClass = getCommandClass(getName()); ClassLoader mcl = getModuleClassLoader(); if (cmdClass != null && mcl != null) { return ManPageFinder.getCommandManPage(getName(), cmdClass, Locale.getDefault(), mcl, logger); } return null; }
/** * Try to find a local version of the man page for this command. */ private BufferedReader getLocalManPage() { logger.fine(strings.get("NoRemoteManPage")); String cmdClass = getCommandClass(getName()); ClassLoader mcl = getModuleClassLoader(); if (cmdClass != null && mcl != null) { return ManPageFinder.getCommandManPage(getName(), cmdClass, Locale.getDefault(), mcl, logger); } return null; }
/** * Try to find a local version of the man page for this command. */ private BufferedReader getLocalManPage() { logger.fine(strings.get("NoRemoteManPage")); String cmdClass = getCommandClass(getName()); ClassLoader mcl = getModuleClassLoader(); if (cmdClass != null && mcl != null) { return ManPageFinder.getCommandManPage(getName(), cmdClass, Locale.getDefault(), mcl, logger); } return null; }