org.apache.oozie.util
Class XConfiguration

java.lang.Object
  extended by org.apache.hadoop.conf.Configuration
      extended by org.apache.oozie.util.XConfiguration
All Implemented Interfaces:
Iterable<Map.Entry<String,String>>, org.apache.hadoop.io.Writable

public class XConfiguration
extends org.apache.hadoop.conf.Configuration

Extends Hadoop Configuration providing a new constructor which reads an XML configuration from an InputStream.

OConfiguration(InputStream is).


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.hadoop.conf.Configuration
org.apache.hadoop.conf.Configuration.IntegerRanges
 
Constructor Summary
XConfiguration()
          Create an empty configuration.
XConfiguration(InputStream is)
          Create a configuration from an InputStream.
XConfiguration(Properties props)
          Create an configuration from a Properties instance.
XConfiguration(Reader reader)
          Create a configuration from an Reader.
 
Method Summary
static void copy(org.apache.hadoop.conf.Configuration source, org.apache.hadoop.conf.Configuration target)
          Copy configuration key/value pairs from one configuration to another if a property exists in the target, it gets replaced.
 String get(String name)
          Get the value of the name property, null if no such property exists.
 String get(String name, String defaultValue)
          Get the value of the name property.
 Class<?> getClassByName(String name)
          This is a stop gap fix for HADOOP-4416.
 String[] getTrimmedStrings(String name)
          Get the comma delimited values of the name property as an array of trimmed Strings.
static void injectDefaults(org.apache.hadoop.conf.Configuration source, org.apache.hadoop.conf.Configuration target)
          Injects configuration key/value pairs from one configuration to another if the key does not exist in the target configuration.
 XConfiguration resolve()
          Returns a new XConfiguration instance with all inline values resolved.
 Properties toProperties()
          Return a Properties instance with the configuration properties.
 String toXmlString()
          Return a string with the configuration in XML format.
 String toXmlString(boolean prolog)
           
 XConfiguration trim()
          Returns a new XConfiguration with all values trimmed.
 
Methods inherited from class org.apache.hadoop.conf.Configuration
addDefaultResource, addResource, addResource, addResource, addResource, clear, dumpConfiguration, getBoolean, getClass, getClass, getClasses, getClassLoader, getConfResourceAsInputStream, getConfResourceAsReader, getEnum, getFile, getFloat, getInstances, getInt, getLocalPath, getLong, getRange, getRaw, getResource, getStringCollection, getStrings, getStrings, getValByRegex, iterator, main, readFields, reloadConfiguration, set, setBoolean, setBooleanIfUnset, setClass, setClassLoader, setEnum, setFloat, setIfUnset, setInt, setLong, setQuietMode, setStrings, size, toString, write, writeXml
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XConfiguration

public XConfiguration()
Create an empty configuration.

Default values are not loaded.


XConfiguration

public XConfiguration(InputStream is)
               throws IOException
Create a configuration from an InputStream.

Code canibalized from Configuration.loadResource().

Parameters:
is - inputstream to read the configuration from.
Throws:
IOException - thrown if the configuration could not be read.

XConfiguration

public XConfiguration(Reader reader)
               throws IOException
Create a configuration from an Reader.

Code canibalized from Configuration.loadResource().

Parameters:
reader - reader to read the configuration from.
Throws:
IOException - thrown if the configuration could not be read.

XConfiguration

public XConfiguration(Properties props)
Create an configuration from a Properties instance.

Parameters:
props - Properties instance to get all properties from.
Method Detail

toProperties

public Properties toProperties()
Return a Properties instance with the configuration properties.

Returns:
a Properties instance with the configuration properties.

get

public String get(String name)
Get the value of the name property, null if no such property exists. Values are processed for variable expansion before being returned.

Overrides:
get in class org.apache.hadoop.conf.Configuration
Parameters:
name - the property name.
Returns:
the value of the name property, or null if no such property exists.

get

public String get(String name,
                  String defaultValue)
Get the value of the name property. If no such property exists, then defaultValue is returned.

Overrides:
get in class org.apache.hadoop.conf.Configuration
Parameters:
name - property name.
defaultValue - default value.
Returns:
property value, or defaultValue if the property doesn't exist.

getClassByName

public Class<?> getClassByName(String name)
                        throws ClassNotFoundException
This is a stop gap fix for HADOOP-4416.

Overrides:
getClassByName in class org.apache.hadoop.conf.Configuration
Throws:
ClassNotFoundException

copy

public static void copy(org.apache.hadoop.conf.Configuration source,
                        org.apache.hadoop.conf.Configuration target)
Copy configuration key/value pairs from one configuration to another if a property exists in the target, it gets replaced.

Parameters:
source - source configuration.
target - target configuration.

injectDefaults

public static void injectDefaults(org.apache.hadoop.conf.Configuration source,
                                  org.apache.hadoop.conf.Configuration target)
Injects configuration key/value pairs from one configuration to another if the key does not exist in the target configuration.

Parameters:
source - source configuration.
target - target configuration.

trim

public XConfiguration trim()
Returns a new XConfiguration with all values trimmed.

Returns:
a new XConfiguration with all values trimmed.

resolve

public XConfiguration resolve()
Returns a new XConfiguration instance with all inline values resolved.

Returns:
a new XConfiguration instance with all inline values resolved.

toXmlString

public String toXmlString()
Return a string with the configuration in XML format.

Returns:
a string with the configuration in XML format.

toXmlString

public String toXmlString(boolean prolog)

getTrimmedStrings

public String[] getTrimmedStrings(String name)
Get the comma delimited values of the name property as an array of trimmed Strings. If no such property is specified then null is returned.

Parameters:
name - property name.
Returns:
property value as an array of trimmed Strings, or null.


Copyright © 2013 Apache Software Foundation. All Rights Reserved.