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 intcountProperties()Counts number of properties currently in this object.static PropertyLookupcreate(IPropertyLookup defaultsLookup)static PropertyLookupcreate(IPropertyLookup data, IPropertyLookup defaultsLookup)static PropertyLookupcreate(java.io.File propFile)static PropertyLookupcreate(java.io.File propfile, IPropertyLookup defaultsLookup)Calls base constructor with data from IPropertyLookup paramater as defaults.static PropertyLookupcreate(java.io.File propfile, java.util.Map defaults, IPropertyLookup defaultsLookup)Calls base constructor feeding defaults from Map and IPropertyLookup paramsstatic PropertyLookupcreate(java.util.Properties props)static PropertyLookupcreate(java.util.Properties data, IPropertyLookup defaultsLookup)static PropertyLookupcreateDeferred(java.io.File propFile)protected java.util.Propertiesdifference(java.util.Map map)Reads map of input properties and returns a collection of those that are unique to that input set.PropertyLookupexpand()CallsPropertyUtil.expand(Map)to expand all properties.static java.util.PropertiesfetchProperties(java.io.File propFile)given a file reads in its propertiesjava.util.MapgetPropertiesMap()Retrieves map of property datajava.lang.StringgetProperty(java.lang.String key)Get the property per specified keybooleanhasProperty(java.lang.String key)Check if property exists in filestatic booleanhasProperty(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:
getPropertyin interfaceIPropertyLookup- Specified by:
getPropertyin 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:
hasPropertyin 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:
getPropertiesMapin interfaceIPropertyLookup- Returns:
- Unmodifiable
Mapcontaining 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.
-
-