PropertyDefaultSource (JSAP: the Java Simple Argument Parser)
Keywords: com.martiansoftware.jsap.defaultsources.PropertyDefaultSource class

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.martiansoftware.jsap.defaultsources
Class PropertyDefaultSource

    java.lang.Object
      com.martiansoftware.jsap.defaultsources.PropertyDefaultSource

All Implemented Interfaces:
  DefaultSource

    public class PropertyDefaultSource

extends Object
implements DefaultSource

A DefaultSource with values defined in a java.util.Properties object. In order to determine which parameter a value is associated with, each property key is first compared to each parameter's unique ID. Failing a match, each parameter's long flag is checked, and finally the short flags are checked. A PropertyDefaultSource may contain a mix of IDs, long flags, and short flags.

A PropertyDefaultSource is also incredibly useful as a configuration file loader. Multiple PropertyDefaultSources can be chained together in a JSAP in order to prioritize their entries (e.g., load "~/myproject.conf" first, then "/etc/myproject.conf").

Author:
  Marty Lamb
See Also:
  `DefaultSource`, `Properties`

Constructor Summary
`PropertyDefaultSource(InputStream in, boolean throwIOExceptions)` Creates a new PropertyDefaultSource based upon the specified InputStream.
`PropertyDefaultSource(Properties properties)` Creates a new PropertyDefaultSource based upon the specified Properties object.
`PropertyDefaultSource(String propertyFileName, boolean throwIOExceptions)` Creates a new PropertyDefaultSource by loading the specified file.

Method Summary
`Defaults` | `getDefaults(IDMap idMap, ExceptionMap exceptionMap)` Returns a Defaults object based upon this PropertyDefaultSource's properties and the specified IDMap.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PropertyDefaultSource

    public PropertyDefaultSource(String propertyFileName,
                                 boolean throwIOExceptions)

  Creates a new PropertyDefaultSource by loading the specified file. The file is loaded when the JSAP requests the defaults from this object.

  Parameters:
    `propertyFileName` - the name of the properties file containing the default values.
    `throwIOExceptions` - if true, any encountered IOExceptions will be re-thrown. Set this to false if you want to ignore any exceptions (e.g., specified file does not exist).

### PropertyDefaultSource

    public PropertyDefaultSource(Properties properties)

  Creates a new PropertyDefaultSource based upon the specified Properties object.

  Parameters:
    `properties` - the Properties object containing the default values.

### PropertyDefaultSource

    public PropertyDefaultSource(InputStream in,
                                 boolean throwIOExceptions)

  Creates a new PropertyDefaultSource based upon the specified InputStream.

  Parameters:
    `in` - the InputStream containing the Properties.
    `throwIOExceptions` - if true, any encountered IOExceptions will be re-thrown.

Method Detail

### getDefaults

    public Defaults getDefaults(IDMap idMap,
                                ExceptionMap exceptionMap)

  Returns a Defaults object based upon this PropertyDefaultSource's properties and the specified IDMap. In order to determine which parameter a value is associated with, each property key is first compared to each parameter's unique ID. Failing a match, each parameter's long flag is checked, and finally the short flags are checked. A PropertyDefaultSource may contain a mix of IDs, long flags, and short flags.

  Specified by:
    `getDefaults` in interface `DefaultSource`
  Parameters:
    `idMap` - the IDMap containing the current JSAP configuration.
    `exceptionMap` - the ExceptionMap object within which any encountered exceptions will be thrown.
  Returns:
    a Defaults object based upon this PropertyDefaultSource's properties and the specified IDMap.
  See Also:
    `ExceptionMap.addException(String,Exception)`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2005, Martian Software, Inc.. All Rights Reserved.
For the latest version and documentation, please visit http://www.martiansoftware.com/jsap