ANTS v2.0 API

ants.util
Class KeyArgs

java.lang.Object
  |
  +--ants.util.KeyArgs

public class KeyArgs
extends java.lang.Object

Keyword argument manipulation utilities. These are used for handling command line arguments. The key is any string beginning with a "-"; the argument associated with the key can be any string.

WARNING: Do not try to pass an argument value of "-1" to these routines. It will be recognized as a key, not an argument. (Any negative number will do that, of course.)

XXX fix the above, somehow.

Author:
David Wetherall

Constructor Summary
KeyArgs()
           
KeyArgs(java.lang.String[] ka)
           
KeyArgs(java.lang.String[] ka, int skip)
           
 
Method Summary
 java.lang.String arg(int i)
          Return the i'th argument.
 void compact()
          Compact the list of key/arg pairs.
 java.lang.String get(java.lang.String key)
          Find the arg associated with the given key.
 java.lang.String key(int i)
          Return the i'th key.
 int length()
          Return the number of key/arg pairs.
 void merge(KeyArgs k)
          Merge the given set of KeyArgs into the current list.
 void merge(java.lang.String[] ka)
          Merge the given array of strings into the key/arg list.
 void merge(java.lang.String[] ka, int skip)
          Merge the given array of strings into the key/arg list.
 void noMore()
          A handy routine for debugging.
 void set(java.lang.String key, java.lang.String arg)
          Set the arg for key.
 void strike(int i)
          Strike the i'th key/arg pair from the list.
 java.lang.String toString()
          Generate a nice, readable string representation of the key/arg pairs.
 java.lang.String[] toStrings()
          Generate an array of Strings, one for each Key/Arg pair.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KeyArgs

public KeyArgs(java.lang.String[] ka)
        throws InvalidKeyArgsException

KeyArgs

public KeyArgs()
        throws InvalidKeyArgsException

KeyArgs

public KeyArgs(java.lang.String[] ka,
               int skip)
        throws InvalidKeyArgsException
Method Detail

length

public int length()
Return the number of key/arg pairs.

key

public java.lang.String key(int i)
Return the i'th key.

arg

public java.lang.String arg(int i)
Return the i'th argument.

get

public java.lang.String get(java.lang.String key)
Find the arg associated with the given key. Returns 'null' if the key isn't found.

set

public void set(java.lang.String key,
                java.lang.String arg)
Set the arg for key. Overwrites existing value for key if one is set, otherwise adds a new pair to the list.

strike

public void strike(int i)
Strike the i'th key/arg pair from the list.

compact

public void compact()
Compact the list of key/arg pairs. Removes all the "empty" ones.

merge

public void merge(java.lang.String[] ka)
           throws InvalidKeyArgsException
Merge the given array of strings into the key/arg list.

merge

public void merge(java.lang.String[] ka,
                  int skip)
           throws InvalidKeyArgsException
Merge the given array of strings into the key/arg list. The first skip entries in the string array are skipped.

merge

public void merge(KeyArgs k)
Merge the given set of KeyArgs into the current list. Duplicates in k are thrown away.

toString

public java.lang.String toString()
Generate a nice, readable string representation of the key/arg pairs.
Overrides:
toString in class java.lang.Object

toStrings

public java.lang.String[] toStrings()
Generate an array of Strings, one for each Key/Arg pair.

noMore

public void noMore()
A handy routine for debugging. Throws an Error if there are any key/value pairs in the current KeyArgs.

ANTS v2.0 API

This documentation is Copyright (C) 1998-2001 The University of Utah and the University of Washington. All Rights Reserved. See the individual source files for distribution terms.
Documentation, software, and mailing lists for ANTS v2.0 can be found at the Janos Project: http://www.cs.utah.edu/flux/janos/