Java examples for java.lang:String Contain
Return a string that contains a description of how to use a class that calls this method.
/* Utilities used to manipulate strings. Copyright (c) 2002-2006 The Regents of the University of California. All rights reserved./*from w ww.j a v a 2 s . co m*/ Permission is hereby granted, without written agreement and without license or royalty fees, to use, copy, modify, and distribute this software and its documentation for any purpose, provided that the above copyright notice and the following two paragraphs appear in all copies of this software. IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. PT_COPYRIGHT_VERSION_2 COPYRIGHTENDKEY */ //package com.java2s; public class Main { /** Return a string that contains a description of how to use a * class that calls this method. For example, this method is * called by "$PTII/bin/vergil -help". * @param commandTemplate A string naming the command and the * format of the arguments, for example * "moml [options] [file . . .]" * @param commandOptions A 2xN array of Strings that list command-line * options that take arguments where the first * element is a String naming the command line option, and the * second element is the argument, for example * <code>{"-class", "<classname>")</code> * @param commandFlags An array of Strings that list command-line * options that are either present or not. * @return A string that describes the command. */ public static String usageString(String commandTemplate, String[][] commandOptions, String[] commandFlags) { // This method is static so that we can reuse it in places // like copernicus/kernel/Copernicus and actor/gui/MoMLApplication StringBuffer result = new StringBuffer("Usage: " + commandTemplate + "\n\n" + "Options that take values:\n"); int i; for (i = 0; i < commandOptions.length; i++) { result.append(" " + commandOptions[i][0] + " " + commandOptions[i][1] + "\n"); } result.append("\nBoolean flags:\n"); for (i = 0; i < commandFlags.length; i++) { result.append(" " + commandFlags[i]); } return result.toString(); } }