kafka.etl
Class Props

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable<java.lang.Object,java.lang.Object>
          extended by java.util.Properties
              extended by kafka.etl.Props
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.Object,java.lang.Object>

public class Props
extends java.util.Properties

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
Props()
          default constructor
Props(java.io.InputStream... inputStreams)
          construct props from a list of input streams
Props(java.util.List<java.lang.String> files)
          construct props from a list of files
Props(java.util.Map<java.lang.String,java.lang.String>... props)
          construct props from a list of maps
Props(java.util.Properties... properties)
          construct props from a list of Properties
Props(Props props)
          copy constructor
Props(java.lang.String... files)
          construct props from a list of files
 
Method Summary
static Props clone(Props p)
          clone a Props
 boolean equalsProps(Props p)
          compare two props
 java.lang.Boolean getBoolean(java.lang.String key)
          get boolean value
 java.lang.Boolean getBoolean(java.lang.String key, java.lang.Boolean defaultValue)
          get boolean value with default value
 double getDouble(java.lang.String name)
          get double value
 java.lang.Double getDouble(java.lang.String name, double defaultValue)
          get double value with default value
 java.lang.Integer getInt(java.lang.String name)
          get integer value
 java.lang.Integer getInt(java.lang.String name, java.lang.Integer defaultValue)
          get integer value with default value
 java.util.Set<java.lang.String> getKeySet()
          get all property names
 java.lang.Long getLong(java.lang.String name)
          get long value
 java.lang.Long getLong(java.lang.String name, java.lang.Long defaultValue)
          get long value with default value
 java.util.Map<java.lang.String,java.lang.String> getMapByPrefix(java.lang.String prefix)
          Get a map of all properties by string prefix
 java.util.List<java.lang.String> getStringList(java.lang.String key)
          get property of "key" and split the value by " ,"
 java.util.List<java.lang.String> getStringList(java.lang.String key, java.util.List<java.lang.String> defaultValue)
          get string list with default value.
 java.util.List<java.lang.String> getStringList(java.lang.String key, java.util.List<java.lang.String> defaultValue, java.lang.String sep)
          get string list with default value
 java.util.List<java.lang.String> getStringList(java.lang.String key, java.lang.String sep)
          get property of "key" and split the value by "sep"
 java.net.URI getUri(java.lang.String name)
          get URI value
 java.net.URI getUri(java.lang.String name, java.lang.String defaultValue)
          get URI value
 java.net.URI getUri(java.lang.String name, java.net.URI defaultValue)
          get URI value with default value
protected
<T> T
getValue(java.lang.String key, java.lang.Class<T> mclass)
           
protected
<T> T
getValue(java.lang.String key, T defaultValue)
           
 void logProperties(java.lang.String comment)
          log properties
static Props of(java.lang.String... args)
          build props from a list of strings and interpret them as key, value, key, value,....
 void put(java.util.Properties properties)
          Put the given Properties into the Props.
 void store(java.io.OutputStream out)
          Store all properties
 
Methods inherited from class java.util.Properties
getProperty, getProperty, list, list, load, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNames
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Props

public Props()
default constructor


Props

public Props(Props props)
copy constructor

Parameters:
props -

Props

public Props(java.lang.String... files)
      throws java.io.FileNotFoundException,
             java.io.IOException
construct props from a list of files

Parameters:
files - paths of files
Throws:
java.io.FileNotFoundException
java.io.IOException

Props

public Props(java.util.List<java.lang.String> files)
      throws java.io.FileNotFoundException,
             java.io.IOException
construct props from a list of files

Parameters:
files - paths of files
Throws:
java.io.FileNotFoundException
java.io.IOException

Props

public Props(java.io.InputStream... inputStreams)
      throws java.io.IOException
construct props from a list of input streams

Parameters:
inputStreams -
Throws:
java.io.IOException

Props

public Props(java.util.Map<java.lang.String,java.lang.String>... props)
construct props from a list of maps

Parameters:
props -

Props

public Props(java.util.Properties... properties)
construct props from a list of Properties

Parameters:
properties -
Method Detail

of

public static Props of(java.lang.String... args)
build props from a list of strings and interpret them as key, value, key, value,....

Parameters:
args -
Returns:
props

put

public void put(java.util.Properties properties)
Put the given Properties into the Props.

Parameters:
properties - The properties to put

getStringList

public java.util.List<java.lang.String> getStringList(java.lang.String key)
get property of "key" and split the value by " ,"

Parameters:
key -
Returns:
list of values

getStringList

public java.util.List<java.lang.String> getStringList(java.lang.String key,
                                                      java.lang.String sep)
get property of "key" and split the value by "sep"

Parameters:
key -
sep -
Returns:
string list of values

getStringList

public java.util.List<java.lang.String> getStringList(java.lang.String key,
                                                      java.util.List<java.lang.String> defaultValue)
get string list with default value. default delimiter is ","

Parameters:
key -
defaultValue -
Returns:
string list of values

getStringList

public java.util.List<java.lang.String> getStringList(java.lang.String key,
                                                      java.util.List<java.lang.String> defaultValue,
                                                      java.lang.String sep)
get string list with default value

Parameters:
key -
defaultValue -
Returns:
string list of values

getValue

protected <T> T getValue(java.lang.String key,
                         T defaultValue)
              throws java.lang.Exception
Throws:
java.lang.Exception

getValue

protected <T> T getValue(java.lang.String key,
                         java.lang.Class<T> mclass)
              throws java.lang.Exception
Throws:
java.lang.Exception

getBoolean

public java.lang.Boolean getBoolean(java.lang.String key,
                                    java.lang.Boolean defaultValue)
                             throws java.lang.Exception
get boolean value with default value

Parameters:
key -
defaultValue -
Returns:
boolean value
Throws:
java.lang.Exception - if value is not of type boolean or string

getBoolean

public java.lang.Boolean getBoolean(java.lang.String key)
                             throws java.lang.Exception
get boolean value

Parameters:
key -
Returns:
boolean value
Throws:
java.lang.Exception - if value is not of type boolean or string or if value doesn't exist

getLong

public java.lang.Long getLong(java.lang.String name,
                              java.lang.Long defaultValue)
                       throws java.lang.Exception
get long value with default value

Parameters:
name -
defaultValue -
Returns:
long value
Throws:
java.lang.Exception - if value is not of type long or string

getLong

public java.lang.Long getLong(java.lang.String name)
                       throws java.lang.Exception
get long value

Parameters:
name -
Returns:
long value
Throws:
java.lang.Exception - if value is not of type long or string or if value doesn't exist

getInt

public java.lang.Integer getInt(java.lang.String name,
                                java.lang.Integer defaultValue)
                         throws java.lang.Exception
get integer value with default value

Parameters:
name -
defaultValue -
Returns:
integer value
Throws:
java.lang.Exception - if value is not of type integer or string

getInt

public java.lang.Integer getInt(java.lang.String name)
                         throws java.lang.Exception
get integer value

Parameters:
name -
Returns:
integer value
Throws:
java.lang.Exception - if value is not of type integer or string or if value doesn't exist

getDouble

public java.lang.Double getDouble(java.lang.String name,
                                  double defaultValue)
                           throws java.lang.Exception
get double value with default value

Parameters:
name -
defaultValue -
Returns:
double value
Throws:
java.lang.Exception - if value is not of type double or string

getDouble

public double getDouble(java.lang.String name)
                 throws java.lang.Exception
get double value

Parameters:
name -
Returns:
double value
Throws:
java.lang.Exception - if value is not of type double or string or if value doesn't exist

getUri

public java.net.URI getUri(java.lang.String name,
                           java.net.URI defaultValue)
                    throws java.lang.Exception
get URI value with default value

Parameters:
name -
defaultValue -
Returns:
URI value
Throws:
java.lang.Exception - if value is not of type URI or string

getUri

public java.net.URI getUri(java.lang.String name,
                           java.lang.String defaultValue)
                    throws java.lang.Exception
get URI value

Parameters:
name -
defaultValue -
Returns:
URI value
Throws:
java.lang.Exception - if value is not of type URI or string

getUri

public java.net.URI getUri(java.lang.String name)
                    throws java.lang.Exception
get URI value

Parameters:
name -
Returns:
URI value
Throws:
java.lang.Exception - if value is not of type URI or string or if value doesn't exist

equalsProps

public boolean equalsProps(Props p)
compare two props

Parameters:
p -
Returns:
true or false

getMapByPrefix

public java.util.Map<java.lang.String,java.lang.String> getMapByPrefix(java.lang.String prefix)
Get a map of all properties by string prefix

Parameters:
prefix - The string prefix

store

public void store(java.io.OutputStream out)
           throws java.io.IOException
Store all properties

Parameters:
out - The stream to write to
Throws:
java.io.IOException - If there is an error writing

getKeySet

public java.util.Set<java.lang.String> getKeySet()
get all property names

Returns:
set of property names

logProperties

public void logProperties(java.lang.String comment)
log properties

Parameters:
comment -

clone

public static Props clone(Props p)
clone a Props

Parameters:
p -
Returns:
props