to top
public class

OptionSetter

extends Object
java.lang.Object
   ↳ com.android.tradefed.config.OptionSetter
Known Direct Subclasses

Class Overview

Populates Option fields.

Setting of numeric fields such byte, short, int, long, float, and double fields is supported. This includes both unboxed and boxed versions (e.g. int vs Integer). If there is a problem setting the argument to match the desired type, a ConfigurationException is thrown.

File option fields are supported by simply wrapping the string argument in a File object without testing for the existence of the file.

Parameterized Collection fields such as List<File> and Set<String> are supported as long as the parameter type is otherwise supported by the option setter. The collection field should be initialized with an appropriate collection instance.

All fields will be processed, including public, protected, default (package) access, private and inherited fields.

ported from dalvik.runner.OptionParser

Summary

Constants
String BOOL_FALSE_PREFIX
char NAMESPACE_SEPARATOR
Public Constructors
OptionSetter(Object... optionSources)
Constructs a new OptionParser for setting the @Option fields of 'optionSources'.
OptionSetter(Collection<Object> optionSources)
Constructs a new OptionParser for setting the @Option fields of 'optionSources'.
Public Methods
String getTypeForOption(String name)
Returns a string describing the type of the field with given name.
boolean isBooleanOption(String name)
boolean isMapOption(String name)
void setOptionMapValue(String optionName, String keyText, String valueText)
Sets the key and value for a Map option.
void setOptionValue(String optionName, String valueText)
Sets the value for an option.
Protected Methods
Collection<String> getUnsetMandatoryOptions()
Returns the names of all of the Options that are marked as mandatory but remain unset.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

static final String BOOL_FALSE_PREFIX

Constant Value: "no-"

static final char NAMESPACE_SEPARATOR

Constant Value: 58 (0x0000003a)

Public Constructors

public OptionSetter (Object... optionSources)

Constructs a new OptionParser for setting the @Option fields of 'optionSources'.

public OptionSetter (Collection<Object> optionSources)

Constructs a new OptionParser for setting the @Option fields of 'optionSources'.

Public Methods

public String getTypeForOption (String name)

Returns a string describing the type of the field with given name.

Parameters
name the Option field name
Returns
  • a String describing the field's type
Throws
ConfigurationException if field could not be found

public boolean isBooleanOption (String name)

public boolean isMapOption (String name)

public void setOptionMapValue (String optionName, String keyText, String valueText)

Sets the key and value for a Map option.

Parameters
optionName the name of Option to set
keyText the key, if applicable. Will be ignored for non-Map fields
valueText the value
Throws
ConfigurationException if Option cannot be found or valueText is wrong type

public void setOptionValue (String optionName, String valueText)

Sets the value for an option.

Parameters
optionName the name of Option to set
valueText the value
Throws
ConfigurationException if Option cannot be found or valueText is wrong type

Protected Methods

protected Collection<String> getUnsetMandatoryOptions ()

Returns the names of all of the Options that are marked as mandatory but remain unset.

Returns
  • A Collection of Strings containing the (unqualified) names of unset mandatory options.
Throws
ConfigurationException if a field to be checked is inaccessible