1 16 package org.apache.axis.utils; 19 20 21 27 public final class CLUtil 28 { 29 private static final int MAX_DESCRIPTION_COLUMN_LENGTH = 60; 30 31 38 public static final StringBuffer describeOptions( final CLOptionDescriptor[] options ) 39 { 40 final StringBuffer sb = new StringBuffer (); 41 42 for( int i = 0; i < options.length; i++ ) 43 { 44 final char ch = (char) options[i].getId(); 45 final String name = options[i].getName(); 46 String description = options[i].getDescription(); 47 int flags = options[i].getFlags(); 48 boolean argumentRequired = 49 ( (flags & CLOptionDescriptor.ARGUMENT_REQUIRED) == 50 CLOptionDescriptor.ARGUMENT_REQUIRED); 51 boolean twoArgumentsRequired = 52 ( (flags & CLOptionDescriptor.ARGUMENTS_REQUIRED_2) == 53 CLOptionDescriptor.ARGUMENTS_REQUIRED_2); 54 boolean needComma = false; 55 if (twoArgumentsRequired) 56 argumentRequired = true; 57 58 sb.append('\t'); 59 60 if( Character.isLetter(ch) ) 61 { 62 sb.append( "-" ); 63 sb.append( ch ); 64 needComma = true; 65 } 66 67 if( null != name ) 68 { 69 if( needComma ) 70 { 71 sb.append( ", " ); 72 } 73 74 sb.append( "--" ); 75 sb.append( name ); 76 if (argumentRequired) 77 { 78 sb.append(" <argument>"); 79 } 80 if (twoArgumentsRequired) 81 { 82 sb.append("=<value>"); 83 } 84 sb.append( JavaUtils.LS ); 85 } 86 87 if( null != description ) 88 { 89 while( description.length() > MAX_DESCRIPTION_COLUMN_LENGTH ) 90 { 91 final String descriptionPart = 92 description.substring( 0, MAX_DESCRIPTION_COLUMN_LENGTH ); 93 description = 94 description.substring( MAX_DESCRIPTION_COLUMN_LENGTH ); 95 sb.append( "\t\t" ); 96 sb.append( descriptionPart ); 97 sb.append( JavaUtils.LS ); 98 } 99 100 sb.append( "\t\t" ); 101 sb.append( description ); 102 sb.append( JavaUtils.LS ); 103 } 104 } 105 return sb; 106 } 107 108 112 private CLUtil() 113 { 114 } 115 } 116 | Popular Tags |