xmlBlaster 2.2.0 API

org.xmlBlaster.util.property
Class Args

java.lang.Object
  extended by org.xmlBlaster.util.property.Args

public class Args
extends java.lang.Object

Evaluate parameters at process startup (args).

JDK 1.1 or higher only.

Example:

 If you call your application e.g. like that:

    java myapp -file myfile.txt

 you can access the paramater:

    String fileName = Args.getArg(args, "-file", "dummy.txt");

 (dummy.txt would be the fallback if no -file ... is given)
 

Author:
Marcel Ruff

Field Summary
private static java.lang.String[] args
           
private static java.lang.String ME
           
 
Constructor Summary
Args()
           
 
Method Summary
static boolean getArg(java.lang.String[] args, java.lang.String arg)
          Try to find the given arg without a value (flag parameter).
static boolean getArg(java.lang.String[] args, java.lang.String key, boolean defaultVal)
          Try to find the given key in the args list.
static byte[] getArg(java.lang.String[] args, java.lang.String key, byte[] defaultVal)
          Try to find the given key in the args list.
static int getArg(java.lang.String[] args, java.lang.String key, int defaultVal)
          Try to find the given key in the args list.
static java.lang.String getArg(java.lang.String[] args, java.lang.String key, java.lang.String defaultVal)
          Try to find the given key in the args list.
static boolean getArg(java.lang.String arg, boolean defVal)
           
static int getArg(java.lang.String arg, int defVal)
           
static java.lang.String getArg(java.lang.String arg, java.lang.String defVal)
           
static void main(java.lang.String[] args)
          For testing only

java org.xmlBlaster.util.property.Args

static void setArg(java.lang.String[] myargs)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ME

private static final java.lang.String ME
See Also:
Constant Field Values

args

private static java.lang.String[] args
Constructor Detail

Args

public Args()
Method Detail

getArg

public static final java.lang.String getArg(java.lang.String[] args,
                                            java.lang.String key,
                                            java.lang.String defaultVal)
                                     throws XmlBlasterException
Try to find the given key in the args list.

Parameters:
the - argument array
key - the key to look for
defaultVal - the default value to return if key is not found
Returns:
The String value for the given key
Throws:
XmlBlasterException

getArg

public static final byte[] getArg(java.lang.String[] args,
                                  java.lang.String key,
                                  byte[] defaultVal)
                           throws XmlBlasterException
Try to find the given key in the args list.

Parameters:
the - argument array
key - the key to look for
defaultVal - the default value to return if key is not found
Returns:
The byte[] value for the given key
Throws:
XmlBlasterException

getArg

public static final int getArg(java.lang.String[] args,
                               java.lang.String key,
                               int defaultVal)
                        throws XmlBlasterException
Try to find the given key in the args list.

Parameters:
the - argument array
key - the key to look for
defaultVal - the default value to return if key is not found
Returns:
The int value for the given key
Throws:
XmlBlasterException

getArg

public static final boolean getArg(java.lang.String[] args,
                                   java.lang.String key,
                                   boolean defaultVal)
                            throws XmlBlasterException
Try to find the given key in the args list.

true for one of "true", "yes", "1", "ok"
false for "false", "0", "no"
else the defaultVal

Parameters:
the - argument array
key - the key to look for
defaultVal - the default value to return if key is not found
Returns:
The boolean value for the given key
Throws:
XmlBlasterException

getArg

public static final boolean getArg(java.lang.String[] args,
                                   java.lang.String arg)
Try to find the given arg without a value (flag parameter).

Parameters:
the - argument array
arg - The argument to find (without a value)
Returns:
true found it

setArg

public static final void setArg(java.lang.String[] myargs)

getArg

public static final java.lang.String getArg(java.lang.String arg,
                                            java.lang.String defVal)
                                     throws XmlBlasterException
Throws:
XmlBlasterException

getArg

public static final int getArg(java.lang.String arg,
                               int defVal)
                        throws XmlBlasterException
Throws:
XmlBlasterException

getArg

public static final boolean getArg(java.lang.String arg,
                                   boolean defVal)
                            throws XmlBlasterException
Throws:
XmlBlasterException

main

public static void main(java.lang.String[] args)
For testing only

java org.xmlBlaster.util.property.Args


xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.