public class Configuration extends Object implements IOReadableWritable, Serializable
Constructor and Description |
---|
Configuration() |
Modifier and Type | Method and Description |
---|---|
void |
addAll(Configuration other) |
void |
addAll(Configuration other,
String prefix)
Adds all entries from the given configuration into this configuration.
|
boolean |
containsKey(String key)
Checks whether there is an entry with the specified key
|
boolean |
equals(Object obj) |
boolean |
getBoolean(String key,
boolean defaultValue)
Returns the value associated with the given key as a boolean.
|
byte[] |
getBytes(String key,
byte[] defaultValue)
Returns the value associated with the given key as a byte array.
|
<T> Class<T> |
getClass(String key,
Class<? extends T> defaultValue,
ClassLoader classLoader)
Returns the class associated with the given key as a string.
|
double |
getDouble(String key,
double defaultValue)
Returns the value associated with the given key as a double.
|
float |
getFloat(String key,
float defaultValue)
Returns the value associated with the given key as a float.
|
int |
getInteger(String key,
int defaultValue)
Returns the value associated with the given key as an integer.
|
long |
getLong(String key,
long defaultValue)
Returns the value associated with the given key as a long.
|
String |
getString(String key,
String defaultValue)
Returns the value associated with the given key as a string.
|
int |
hashCode() |
Set<String> |
keySet()
Returns the keys of all key/value pairs stored inside this
configuration object.
|
void |
read(DataInputView in)
Reads the object's internal data from the given data input view.
|
void |
setBoolean(String key,
boolean value)
Adds the given key/value pair to the configuration object.
|
void |
setBytes(String key,
byte[] bytes)
Adds the given byte array to the configuration object.
|
void |
setClass(String key,
Class<?> klazz)
Adds the given key/value pair to the configuration object.
|
void |
setDouble(String key,
double value)
Adds the given key/value pair to the configuration object.
|
void |
setFloat(String key,
float value)
Adds the given key/value pair to the configuration object.
|
void |
setInteger(String key,
int value)
Adds the given key/value pair to the configuration object.
|
void |
setLong(String key,
long value)
Adds the given key/value pair to the configuration object.
|
void |
setString(String key,
String value)
Adds the given key/value pair to the configuration object.
|
String |
toString() |
void |
write(DataOutputView out)
Writes the object's internal data to the given data output view.
|
public <T> Class<T> getClass(String key, Class<? extends T> defaultValue, ClassLoader classLoader) throws ClassNotFoundException
T
- The type of the class to return.key
- The key pointing to the associated valuedefaultValue
- The optional default value returned if no entry existsclassLoader
- The class loader used to resolve the class.ClassNotFoundException
public void setClass(String key, Class<?> klazz)
getClass(String, Class, ClassLoader)
if it is in the scope of the class loader on the caller.key
- The key of the pair to be addedklazz
- The value of the pair to be addedgetClass(String, Class, ClassLoader)
public String getString(String key, String defaultValue)
key
- the key pointing to the associated valuedefaultValue
- the default value which is returned in case there is no value associated with the given keypublic void setString(String key, String value)
key
- the key of the key/value pair to be addedvalue
- the value of the key/value pair to be addedpublic int getInteger(String key, int defaultValue)
key
- the key pointing to the associated valuedefaultValue
- the default value which is returned in case there is no value associated with the given keypublic void setInteger(String key, int value)
key
- the key of the key/value pair to be addedvalue
- the value of the key/value pair to be addedpublic long getLong(String key, long defaultValue)
key
- the key pointing to the associated valuedefaultValue
- the default value which is returned in case there is no value associated with the given keypublic void setLong(String key, long value)
key
- the key of the key/value pair to be addedvalue
- the value of the key/value pair to be addedpublic boolean getBoolean(String key, boolean defaultValue)
key
- the key pointing to the associated valuedefaultValue
- the default value which is returned in case there is no value associated with the given keypublic void setBoolean(String key, boolean value)
key
- the key of the key/value pair to be addedvalue
- the value of the key/value pair to be addedpublic float getFloat(String key, float defaultValue)
key
- the key pointing to the associated valuedefaultValue
- the default value which is returned in case there is no value associated with the given keypublic void setFloat(String key, float value)
key
- the key of the key/value pair to be addedvalue
- the value of the key/value pair to be addedpublic double getDouble(String key, double defaultValue)
key
- the key pointing to the associated valuedefaultValue
- the default value which is returned in case there is no value associated with the given keypublic void setDouble(String key, double value)
key
- the key of the key/value pair to be addedvalue
- the value of the key/value pair to be addedpublic byte[] getBytes(String key, byte[] defaultValue)
key
- The key pointing to the associated value.defaultValue
- The default value which is returned in case there is no value associated with the given key.public void setBytes(String key, byte[] bytes)
null
then nothing is added.key
- The key under which the bytes are added.bytes
- The bytes to be added.public Set<String> keySet()
public void addAll(Configuration other)
public void addAll(Configuration other, String prefix)
other
- The configuration whose entries are added to this configuration.prefix
- The prefix to prepend.public boolean containsKey(String key)
key
- key of entrypublic void read(DataInputView in) throws IOException
IOReadableWritable
read
in interface IOReadableWritable
in
- the input view to read the data fromIOException
- thrown if any error occurs while reading from the input streampublic void write(DataOutputView out) throws IOException
IOReadableWritable
write
in interface IOReadableWritable
out
- the output view to receive the data.IOException
- thrown if any error occurs while writing to the output streamCopyright © 2015 The Apache Software Foundation. All rights reserved.