CLIManFileFinder.javaAPI DocGlassfish v2 API6214Wed Jul 25 01:03:20 BST 2007com.sun.enterprise.cli.framework


public class CLIManFileFinder extends Object
A utility class which gets the I18N xml help file name for the given command. It searches (using Class.getSystemResource()) for the pages, and returns the first one found. For any given man page multiple instances of that page can exist. Man pages are come in sections (1 through 9, 1m through 9m), locales (language, country, variant), and by command version. These instances are ordered by section number (1 - 9, 1m - 9m), local specificity (most specific to least specific) and then by version (later versions before earlier versions). This is probably not what is wanted (I think what is wanted is versions before sections before language specificity), but is this way because of the way the Java Class.getResource() mechanism works. All methods will throw a NullPointerException if given null object arguments. All methods will throw an IllegalArgumentException if their arguments are non-null but are otherwise meaningless.

Fields Summary
private static final String[]
private static final String
Constructors Summary
Methods Summary
public commandName)
Get the man page for the given command, using the default locale

commandName the name of the command

	return getCommandManFile(commandName, Locale.getDefault());
public commandName, java.util.Locale currentLocale)
Get the man page for the given command for the given locale

commandName the name of the command
currentLocale the locale to be used to find the man page

	return getCommandManFile(commandName, currentLocale, this.getClass().getClassLoader());
public commandName, java.util.Locale locale, java.lang.ClassLoader classLoader)
Get the man page for the given command for the given locale using the give classloader.

commandName the name of the command
locale the locale to be used to find the man page
classLoader the class loader to be used to find the man page

	if (commandName.length() == 0) {
	  throw new IllegalArgumentException ("Command name cannot be empty");

	InputStream s = null;
	Iterator it = getPossibleLocations(commandName, locale);
	while (s == null && it.hasNext()){
	  s = classLoader.getResourceAsStream((String);
	return (s == null ? (InputStreamReader) null : new InputStreamReader(s));
java.lang.String[]getLocaleLocations(java.util.Locale locale)

	String language = locale.getLanguage();
	String country = locale.getCountry();
	String variant = locale.getVariant();
	List<String> l = new ArrayList<String>();

	if (language != null && language.length() > 0) {
	  l.add("/" + language);
	  if (country != null && country.length() > 0){
		l.add("/" + language +"/"+country);
		if (variant != null && variant.length() > 0){
		  l.add("/" + language +"/" + country +"/" + variant);
	return (String[]) l.toArray(new String[0]);
java.util.IteratorgetPossibleLocations(java.lang.String commandName, java.util.Locale locale)

	return new Iterator(){
		final String[] locales = getLocaleLocations(locale);
		int i = 0;
		int j = 0;
		public boolean hasNext() {
		  return i < locales.length && j < sections.length;
		public Object next() throws NoSuchElementException{
		  if (!hasNext()){
			throw new NoSuchElementException();
		  final String result = HELPDIR + locales[i] + "/" + commandName+"." + sections[j++];
		  if (j == sections.length) {
			if (i < locales.length ){
			  j = 0;
		  return result;
		public void remove() {
		  throw new UnsupportedOperationException();