Package com.dtolabs.rundeck.core.utils
Class PropertyLookup
- java.lang.Object
-
- com.dtolabs.rundeck.core.utils.PropertyLookup
-
- All Implemented Interfaces:
PropertyRetriever
,IPropertyLookup
public class PropertyLookup extends java.lang.Object implements IPropertyLookup
Simple utiltiy class to lookup property info
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
countProperties()
Counts number of properties currently in this object.static PropertyLookup
create(IPropertyLookup defaultsLookup)
static PropertyLookup
create(IPropertyLookup data, IPropertyLookup defaultsLookup)
static PropertyLookup
create(java.io.File propFile)
static PropertyLookup
create(java.io.File propfile, IPropertyLookup defaultsLookup)
Calls base constructor with data from IPropertyLookup paramater as defaults.static PropertyLookup
create(java.io.File propfile, java.util.Map defaults, IPropertyLookup defaultsLookup)
Calls base constructor feeding defaults from Map and IPropertyLookup paramsstatic PropertyLookup
create(java.util.Properties props)
static PropertyLookup
create(java.util.Properties data, IPropertyLookup defaultsLookup)
static PropertyLookup
createDeferred(java.io.File propFile)
protected java.util.Properties
difference(java.util.Map map)
Reads map of input properties and returns a collection of those that are unique to that input set.PropertyLookup
expand()
CallsPropertyUtil.expand(Map)
to expand all properties.static java.util.Properties
fetchProperties(java.io.File propFile)
given a file reads in its propertiesjava.util.Map
getPropertiesMap()
Retrieves map of property datajava.lang.String
getProperty(java.lang.String key)
Get the property per specified keyboolean
hasProperty(java.lang.String key)
Check if property exists in filestatic boolean
hasProperty(java.lang.String propKey, java.io.File propFile)
Reads propFile and then checks if specified key exists.
-
-
-
Method Detail
-
create
public static PropertyLookup create(java.util.Properties props)
-
create
public static PropertyLookup create(IPropertyLookup defaultsLookup)
-
create
public static PropertyLookup create(java.io.File propFile)
- Parameters:
propFile
- File where proeprty data is contained- Returns:
- Factory method to create a property lookup object
-
createDeferred
public static PropertyLookup createDeferred(java.io.File propFile)
- Parameters:
propFile
- File where proeprty data is contained- Returns:
- Factory method to create a property lookup object
-
create
public static PropertyLookup create(java.io.File propfile, IPropertyLookup defaultsLookup)
Calls base constructor with data from IPropertyLookup paramater as defaults. Defaults data is read via theIPropertyLookup.getPropertiesMap()
method.- Parameters:
propfile
- File containing property datadefaultsLookup
- IPropertyLookup of default properties- Returns:
- lookup
-
create
public static PropertyLookup create(java.util.Properties data, IPropertyLookup defaultsLookup)
- Parameters:
data
- Properties datadefaultsLookup
- IPropertyLookup of default properties- Returns:
- lookup
-
create
public static PropertyLookup create(IPropertyLookup data, IPropertyLookup defaultsLookup)
- Parameters:
data
- Properties datadefaultsLookup
- IPropertyLookup of default properties- Returns:
- lookup
-
create
public static PropertyLookup create(java.io.File propfile, java.util.Map defaults, IPropertyLookup defaultsLookup)
Calls base constructor feeding defaults from Map and IPropertyLookup params- Parameters:
propfile
- File containing property datadefaults
- Map of default propertiesdefaultsLookup
- IPropertyLookup of default properties- Returns:
- lookup
-
getProperty
public java.lang.String getProperty(java.lang.String key)
Get the property per specified key- Specified by:
getProperty
in interfaceIPropertyLookup
- Specified by:
getProperty
in interfacePropertyRetriever
- Parameters:
key
- name of the property- Returns:
- Value of the property, or null
-
hasProperty
public boolean hasProperty(java.lang.String key)
Check if property exists in file- Specified by:
hasProperty
in interfaceIPropertyLookup
- Parameters:
key
- Name of the property- Returns:
- true if it exists; false otherwise
-
fetchProperties
public static java.util.Properties fetchProperties(java.io.File propFile)
given a file reads in its properties- Parameters:
propFile
- File to read- Returns:
- a Properties object with data filled from propFile
- Throws:
PropertyLookupException
- thrown if error loading property file
-
getPropertiesMap
public java.util.Map getPropertiesMap()
Retrieves map of property data- Specified by:
getPropertiesMap
in interfaceIPropertyLookup
- Returns:
- Unmodifiable
Map
containing property key/value pair - Throws:
PropertyLookupException
- thrown if loaderror
-
expand
public PropertyLookup expand()
CallsPropertyUtil.expand(Map)
to expand all properties.- Returns:
- expanded lookup
-
difference
protected java.util.Properties difference(java.util.Map map)
Reads map of input properties and returns a collection of those that are unique to that input set.- Parameters:
map
- Map of key/value pairs- Returns:
- Properties unique to map
-
countProperties
protected int countProperties()
Counts number of properties currently in this object.- Returns:
- number of properties
-
hasProperty
public static boolean hasProperty(java.lang.String propKey, java.io.File propFile)
Reads propFile and then checks if specified key exists.- Parameters:
propKey
- property namepropFile
- property file- Returns:
- file if a property with that name exists. If an exception occurs while reading the file, false is returned.
-
-