Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

jena.cmdline
Class CommandLine  view CommandLine download CommandLine.java

java.lang.Object
  extended byjena.cmdline.CommandLine

public class CommandLine
extends java.lang.Object

Command line argument processing based on a trigger model. An action is called whenever an argument is encountered. Example: public static void main (String[] args) { CommandLine cl = new CommandLine() ; cl.add(false, "verbose") .add(true, "--file") ; cl.process(args) ; for ( Iterator iter = cl.args() ; iter.hasNext() ; ) ... } A gloabl hook is provided to inspect arguments just before the action. Tracing is enabled by setting this to a suitable function such as that provided by trace(): cl.setHook(cl.trace()) ;

Version:
$Id: CommandLine.java,v 1.4 2005/02/21 11:48:56 andy_seaborne Exp $

Field Summary
protected  ArgHandler argHook
           
protected  java.util.Map argMap
           
protected  java.util.List args
           
protected  java.util.Set argValue
           
protected  java.util.List items
           
protected  java.io.PrintStream out
           
protected  java.lang.String usage
           
 
Constructor Summary
CommandLine()
          Creates new CommandLine
 
Method Summary
 CommandLine add(ArgDecl arg)
          Add an argument object
 CommandLine add(java.lang.String argName, boolean hasValue)
          Add an argument to those to be accepted on the command line
 java.util.List args()
           
 boolean contains(ArgDecl argDecl)
          Test whether an argument was seen.
 boolean contains(java.lang.String s)
          Test whether an argument was seen.
 Arg getArg(ArgDecl argDecl)
          Get the argument associated with the argurment declaration.
 Arg getArg(java.lang.String s)
           
 java.io.PrintStream getOutput()
           
 java.util.List items()
           
static void main(java.lang.String[] argv)
           
 void process(java.lang.String[] argv)
          Process a set of command line arguments.
 void setHook(ArgHandler argHandler)
          Set the global argument handler.
 void setOutput(java.io.PrintStream out)
          Set the output stream, or null for silent.
 void setUsage(java.lang.String usageMessage)
           
 ArgHandler trace()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

argHook

protected ArgHandler argHook

usage

protected java.lang.String usage

argMap

protected java.util.Map argMap

argValue

protected java.util.Set argValue

out

protected java.io.PrintStream out

args

protected java.util.List args

items

protected java.util.List items
Constructor Detail

CommandLine

public CommandLine()
Creates new CommandLine

Method Detail

setHook

public void setHook(ArgHandler argHandler)
Set the global argument handler. Called on every valid argument.


setOutput

public void setOutput(java.io.PrintStream out)
Set the output stream, or null for silent. Default value is System.err


getOutput

public java.io.PrintStream getOutput()

setUsage

public void setUsage(java.lang.String usageMessage)

args

public java.util.List args()

items

public java.util.List items()

process

public void process(java.lang.String[] argv)
             throws java.lang.IllegalArgumentException
Process a set of command line arguments.


contains

public boolean contains(ArgDecl argDecl)
Test whether an argument was seen.


contains

public boolean contains(java.lang.String s)
Test whether an argument was seen.


getArg

public Arg getArg(ArgDecl argDecl)
Get the argument associated with the argurment declaration. Actually retruns the LAST one seen


getArg

public Arg getArg(java.lang.String s)

add

public CommandLine add(java.lang.String argName,
                       boolean hasValue)
Add an argument to those to be accepted on the command line


add

public CommandLine add(ArgDecl arg)
Add an argument object


trace

public ArgHandler trace()

main

public static void main(java.lang.String[] argv)