1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
/* Copyright (C) 2003 Vladimir Roubtsov. All rights reserved.
*
* This program and the accompanying materials are made available under
* the terms of the Common Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/cpl-v10.html
*
* $Id: IOptsParser.java,v 1.1.1.1 2004/05/09 16:57:56 vlad_r Exp $
*/
package com.vladium.util.args;
import java.io.PrintWriter;
// ----------------------------------------------------------------------------
/**
* @author Vlad Roubtsov, (C) 2002
*/
public
interface IOptsParser
{
// public: ................................................................
int SHORT_USAGE = 1;
int DETAILED_USAGE = 2;
interface IOpt
{
String getName ();
String getCanonicalName ();
String getPatternPrefix ();
int getValueCount ();
String getFirstValue ();
String [] getValues ();
} // end of interface
interface IOpts
{
/**
* 0: none, 1: short, 2: detailed
*
* @return
*/
int usageRequestLevel ();
void error (PrintWriter out, int width);
IOpt [] getOpts ();
boolean hasArg (String name);
IOpt [] getOpts (String pattern);
/**
*
* @return [never null, could be empty]
*/
String [] getFreeArgs ();
} // end of interface
void usage (PrintWriter out, int level, int width);
IOpts parse (String [] args);
abstract class Factory
{
// TODO: pass short/long usage opt names in?
public static IOptsParser create (final String metadataResourceName, final ClassLoader loader,
final String msgPrefix, final String [] usageOpts)
{
return new OptsParser (metadataResourceName, loader, msgPrefix, usageOpts);
}
} // end of nested class
} // end of interface
// ----------------------------------------------------------------------------
|