com.endeca.edf.adapter
Class AdapterConfig

java.lang.Object
  extended by com.endeca.edf.adapter.AdapterConfig

public class AdapterConfig
extends java.lang.Object

Contains configuration information handed to the adapter class via the execute method. The configuration data herein is essentially a multimap of name-value pairs, where a given name name may have one or more values associated with it.

See Also:
Adapter

Field Summary
 java.util.Map<java.lang.String,java.util.Set<java.lang.String>> map
           
 
Constructor Summary
AdapterConfig()
          Constructs a new configuration container that is empty.
 
Method Summary
 boolean containsName(java.lang.String name)
          Tests to see if any values are associated with the given name.
 java.lang.String first(java.lang.String name)
          Retrieves the first value associated with the given name (this corresponds to the first value stored under this name).
 double firstDoubleOrDefault(java.lang.String key, double defaultVal)
          Same as firstOrDefault(), but throws an AdapterException if the value cannot be converted into a double.
 int firstIntOrDefault(java.lang.String key, int defaultVal)
          Same as firstOrDefault(), but throws an AdapterException if the value cannot be converted into an integer.
 java.lang.String firstOrDefault(java.lang.String name, java.lang.String defaultValue)
          Same as first(), but returns defaultValue if there is no value associated with the given name.
 java.lang.String[] get(java.lang.String name)
          Retrieves a string array of values associated with the given name.
 java.util.Set<java.lang.String> nameSet()
          Provides a set of all names contained within this object.
 void put(java.lang.String name, java.lang.String value)
          Add a name-value pair to the configuration (a name can be associated with multiple values).
 void put(java.lang.String name, java.lang.String[] values)
          Add values associated with the given name to the configuration.
 java.lang.String requiredFirst(java.lang.String name)
          Same as first(), but throws an AdapterException if there is no value associated with the given name.
 java.lang.String toString()
          Provides a user-readable string representation of this configuration.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

map

public java.util.Map<java.lang.String,java.util.Set<java.lang.String>> map
Constructor Detail

AdapterConfig

public AdapterConfig()
Constructs a new configuration container that is empty.

Method Detail

put

public void put(java.lang.String name,
                java.lang.String value)
Add a name-value pair to the configuration (a name can be associated with multiple values).

Parameters:
name - the name of the configuration data.
value - the value of the configuration data.

put

public void put(java.lang.String name,
                java.lang.String[] values)
Add values associated with the given name to the configuration.

Parameters:
name - the name of the configuration data.
values - a string array of configuration data.

get

public java.lang.String[] get(java.lang.String name)
Retrieves a string array of values associated with the given name.

Parameters:
name - the name of the values to retrieve.
Returns:
a string array of values associated with the given name; an empty array if no values are associated with this name.

first

public java.lang.String first(java.lang.String name)
Retrieves the first value associated with the given name (this corresponds to the first value stored under this name).

Parameters:
name - the name of the value to retrieve.
Returns:
the first value associated with this name; null if no-values are associated with this name.

requiredFirst

public java.lang.String requiredFirst(java.lang.String name)
                               throws AdapterException
Same as first(), but throws an AdapterException if there is no value associated with the given name.

Throws:
AdapterException

firstOrDefault

public java.lang.String firstOrDefault(java.lang.String name,
                                       java.lang.String defaultValue)
                                throws AdapterException
Same as first(), but returns defaultValue if there is no value associated with the given name.

Throws:
AdapterException

firstIntOrDefault

public int firstIntOrDefault(java.lang.String key,
                             int defaultVal)
                      throws AdapterException
Same as firstOrDefault(), but throws an AdapterException if the value cannot be converted into an integer.

Throws:
AdapterException

firstDoubleOrDefault

public double firstDoubleOrDefault(java.lang.String key,
                                   double defaultVal)
                            throws AdapterException
Same as firstOrDefault(), but throws an AdapterException if the value cannot be converted into a double.

Throws:
AdapterException

containsName

public boolean containsName(java.lang.String name)
Tests to see if any values are associated with the given name. This method is equivalent to:
AdapterConfig.get(name) != null

Parameters:
name - the name to check for value association.
Returns:
true if one or more values are associated with this name; false otherwise.

toString

public java.lang.String toString()
Provides a user-readable string representation of this configuration. The string returned is of the form:

name1={value1,value2}
name2={value1}
...

Overrides:
toString in class java.lang.Object
Returns:
a user-readable representation of this configuration.

nameSet

public java.util.Set<java.lang.String> nameSet()
Provides a set of all names contained within this object.

Returns:
all of the names of associated name-value pairs in this object.


© 2003, 2012 Oracle and/or its affiliates. All rights reserved.
Oracle and/or its affiliates Confidential