Package com.ibm.dbb.build
Class BuildProperties
- java.lang.Object
-
- com.ibm.dbb.build.BuildProperties
-
- All Implemented Interfaces:
java.util.Map<java.lang.String,java.lang.String>
public class BuildProperties extends java.lang.Object implements java.util.Map<java.lang.String,java.lang.String>
The BuildProperties class represents a persistent set of properties similar tojava.util.Properties
. The main differences are:- BuildProperties are stored in static tables and use static getters and setters allowing them to be available to the entire application.
- In addition to normal (String key,String value) properties, BuildProperties also introduce file properties which are properties that are associated to specific files via a list of file path patterns.
**/cobol_cics/*.cbl
glob:**/copybook/*.cpy
regex:.*/HAL30SAM\.COB$
ThegetFileProperty(key, file)
method first checks the file property table to see if a property exists that matches the key. If so it then does a pattern match search of the file for all of the file path patterns listed for the key. If no pattern matches the file, it will then check the basic properties table to see if the key exists there. If so, it will return the value as the "default" value for the file property.
Theload(...)
methods support the following file properties format:- key1 = value1
- key2 = value2 :: filePattern,filePattern
- key3 = value2 :: filePattern,filePattern \
filePattern
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
BUILD_REPORT_ONLY
static java.lang.String
METADATA_STORE_PASSWORD
static java.lang.String
METADATA_STORE_SCHEMA
static java.lang.String
METADATA_STORE_TYPE
static java.lang.String
METADATA_STORE_TYPE_DB2
static java.lang.String
METADATA_STORE_TYPE_FILE
static java.lang.String
METADATA_STORE_URL
static java.lang.String
METADATA_STORE_USERID
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
addFilePattern(java.lang.String key, java.lang.String value, java.lang.String filePattern)
Appends a file pattern to the list of associated file patterns for the propertystatic void
addFilePatterns(java.lang.String key, java.lang.String value, java.util.List<java.lang.String> filePatterns)
Appends a list of file patterns to the list of associated file patterns for the propertystatic java.util.Set<java.lang.String>
basicPropertyKeySet()
Returns a set of keys used as basic propertiesvoid
clear()
static void
clearFileProperties()
Removes all file propertiesstatic void
clearProperties()
Removes all basic propertiesboolean
containsKey(java.lang.Object arg0)
boolean
containsValue(java.lang.Object arg0)
java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.String>>
entrySet()
static java.util.Map<java.lang.String,java.util.Set<java.lang.String>>
filePropertyValueKeySet()
Returns a Map containing the file properties key set.java.lang.String
get(java.lang.Object arg0)
static java.lang.String
getFileProperty(java.lang.String key, java.lang.String file)
Searches for the file property for the given key that is associated to the file.static java.util.List<java.lang.String>
getFilePropertyPatterns(java.lang.String key, java.lang.String value)
Returns the list of file patterns associated with a file propertystatic BuildProperties
getInstance()
Returns a singleton instance of BuildProperties.static java.lang.String
getProperty(java.lang.String key)
Returns the basic property valueboolean
isEmpty()
java.util.Set<java.lang.String>
keySet()
static java.lang.String
list()
Returns a list of all the basic and file propertiesstatic void
load(java.io.File file)
Loads a list of file properties from an external properties filestatic void
load(java.io.File file, java.lang.String encoding)
Loads a list of file properties from an external properties filestatic void
load(java.lang.String sourceDir, java.lang.String file)
Loads a list of file properties from an external properties filestatic void
load(java.lang.String sourceDir, java.lang.String file, java.lang.String encoding)
Loads a list of file properties from an external properties filejava.lang.String
put(java.lang.String arg0, java.lang.String arg1)
void
putAll(java.util.Map<? extends java.lang.String,? extends java.lang.String> arg0)
java.lang.String
remove(java.lang.Object arg0)
static void
removeFileProperty(java.lang.String key)
Removes all file properties for the key givenstatic void
removeProperty(java.lang.String key)
Removes the basic property for the key givenstatic void
setFileProperty(java.lang.String key, java.lang.String value, java.lang.String filePattern)
Sets a name value property associated to a file pattern in the file properties table.static void
setFileProperty(java.lang.String key, java.lang.String value, java.util.List<java.lang.String> filePatterns)
Sets a name value property with a list of associated file patterns in the file properties table.static void
setProperty(java.lang.String key, java.lang.String value)
Sets a basic propertyint
size()
static void
staticReset()
java.util.Collection<java.lang.String>
values()
-
-
-
Field Detail
-
METADATA_STORE_TYPE
public static final java.lang.String METADATA_STORE_TYPE
- See Also:
- Constant Field Values
-
METADATA_STORE_TYPE_FILE
public static final java.lang.String METADATA_STORE_TYPE_FILE
- See Also:
- Constant Field Values
-
METADATA_STORE_TYPE_DB2
public static final java.lang.String METADATA_STORE_TYPE_DB2
- See Also:
- Constant Field Values
-
METADATA_STORE_USERID
public static final java.lang.String METADATA_STORE_USERID
- See Also:
- Constant Field Values
-
METADATA_STORE_URL
public static final java.lang.String METADATA_STORE_URL
- See Also:
- Constant Field Values
-
METADATA_STORE_PASSWORD
public static final java.lang.String METADATA_STORE_PASSWORD
- See Also:
- Constant Field Values
-
METADATA_STORE_SCHEMA
public static final java.lang.String METADATA_STORE_SCHEMA
- See Also:
- Constant Field Values
-
BUILD_REPORT_ONLY
public static final java.lang.String BUILD_REPORT_ONLY
- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
public static BuildProperties getInstance()
Returns a singleton instance of BuildProperties. Though all methods are static, an instance of the class is useful in some scripting languages.- Returns:
- a singleton instance of BuildProperties
-
load
public static void load(java.lang.String sourceDir, java.lang.String file) throws java.io.IOException
Loads a list of file properties from an external properties file- Parameters:
sourceDir
- The absolute directory that contains the properties file. Pass null to use an absolute file path.file
- The relative path of the properties file, or absolute path if sourceDir is null.- Throws:
java.io.IOException
- If an error occurred in loading the files.
-
load
public static void load(java.lang.String sourceDir, java.lang.String file, java.lang.String encoding) throws java.io.IOException
Loads a list of file properties from an external properties file- Parameters:
sourceDir
- The absolute directory that contains the properties file. Pass null to use an absolute file path.file
- The relative path of the properties file, or absolute path if sourceDir is null.encoding
- The encoding of the properties file- Throws:
java.io.IOException
- If an error occurred in loading the files.
-
load
public static void load(java.io.File file) throws java.io.IOException
Loads a list of file properties from an external properties file- Parameters:
file
- The properties file to load- Throws:
java.io.IOException
- If an error occurred in loading the files.
-
load
public static void load(java.io.File file, java.lang.String encoding) throws java.io.IOException
Loads a list of file properties from an external properties file- Parameters:
file
- The properties file to loadencoding
- The encoding of the properties file- Throws:
java.io.IOException
- If an error occurred in loading the files.
-
getFileProperty
public static java.lang.String getFileProperty(java.lang.String key, java.lang.String file)
Searches for the file property for the given key that is associated to the file. If the property is not found for the file, then a search for a basic property with that key is performed. If no property is found, thenNULL
is returned.- Parameters:
key
- The key of the file property to be searched.file
- The relative path of the file to search for.- Returns:
- The value of the property search or
NULL
if no property is found.
-
getProperty
public static java.lang.String getProperty(java.lang.String key)
Returns the basic property value- Parameters:
key
- The name of the property to be set- Returns:
- The property value or
NULL
if it does not exist
-
setFileProperty
public static void setFileProperty(java.lang.String key, java.lang.String value, java.lang.String filePattern)
Sets a name value property associated to a file pattern in the file properties table. If the name value property already exists in the table, the file patterns are replaced with the new file patterns.- Parameters:
key
- The name of the property to be setvalue
- The value of the property to be setfilePattern
- The file pattern to associate the property to property.
-
setFileProperty
public static void setFileProperty(java.lang.String key, java.lang.String value, java.util.List<java.lang.String> filePatterns)
Sets a name value property with a list of associated file patterns in the file properties table. If the name value property already exists in the table, the file patterns are replaced with the new file patterns.- Parameters:
key
- The name of the property to be setvalue
- The value of the property to be setfilePatterns
- The list of file patterns to associate the property to property.
-
setProperty
public static void setProperty(java.lang.String key, java.lang.String value)
Sets a basic property- Parameters:
key
- The name of the property to be setvalue
- The value of the property to be set
-
removeProperty
public static void removeProperty(java.lang.String key)
Removes the basic property for the key given- Parameters:
key
- The key of the property to remove
-
removeFileProperty
public static void removeFileProperty(java.lang.String key)
Removes all file properties for the key given- Parameters:
key
- - The key of the properties to remove
-
clearProperties
public static void clearProperties()
Removes all basic properties
-
clearFileProperties
public static void clearFileProperties()
Removes all file properties
-
basicPropertyKeySet
public static java.util.Set<java.lang.String> basicPropertyKeySet()
Returns a set of keys used as basic properties- Returns:
- The set of keys in us
-
filePropertyValueKeySet
public static java.util.Map<java.lang.String,java.util.Set<java.lang.String>> filePropertyValueKeySet()
Returns a Map containing the file properties key set. The format of the Map is <values>- Returns:
- Map containing the file properties key set
-
getFilePropertyPatterns
public static java.util.List<java.lang.String> getFilePropertyPatterns(java.lang.String key, java.lang.String value)
Returns the list of file patterns associated with a file property- Parameters:
key
- The name of the file property to retrievevalue
- The value of the property to retrieve- Returns:
- The list of file patterns associated with a file property
-
addFilePattern
public static void addFilePattern(java.lang.String key, java.lang.String value, java.lang.String filePattern)
Appends a file pattern to the list of associated file patterns for the property- Parameters:
key
- The name of the file propertyvalue
- The value of the file propertyfilePattern
- The file pattern to add to the file property
-
addFilePatterns
public static void addFilePatterns(java.lang.String key, java.lang.String value, java.util.List<java.lang.String> filePatterns)
Appends a list of file patterns to the list of associated file patterns for the property- Parameters:
key
- The name of the file propertyvalue
- The value of the file propertyfilePatterns
- The list of file patterns to add to the file property
-
list
public static java.lang.String list()
Returns a list of all the basic and file properties- Returns:
- List of all properties
-
staticReset
public static void staticReset()
-
clear
public void clear()
- Specified by:
clear
in interfacejava.util.Map<java.lang.String,java.lang.String>
-
containsKey
public boolean containsKey(java.lang.Object arg0)
- Specified by:
containsKey
in interfacejava.util.Map<java.lang.String,java.lang.String>
-
containsValue
public boolean containsValue(java.lang.Object arg0)
- Specified by:
containsValue
in interfacejava.util.Map<java.lang.String,java.lang.String>
-
entrySet
public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.String>> entrySet()
- Specified by:
entrySet
in interfacejava.util.Map<java.lang.String,java.lang.String>
-
get
public java.lang.String get(java.lang.Object arg0)
- Specified by:
get
in interfacejava.util.Map<java.lang.String,java.lang.String>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfacejava.util.Map<java.lang.String,java.lang.String>
-
keySet
public java.util.Set<java.lang.String> keySet()
- Specified by:
keySet
in interfacejava.util.Map<java.lang.String,java.lang.String>
-
put
public java.lang.String put(java.lang.String arg0, java.lang.String arg1)
- Specified by:
put
in interfacejava.util.Map<java.lang.String,java.lang.String>
-
putAll
public void putAll(java.util.Map<? extends java.lang.String,? extends java.lang.String> arg0)
- Specified by:
putAll
in interfacejava.util.Map<java.lang.String,java.lang.String>
-
remove
public java.lang.String remove(java.lang.Object arg0)
- Specified by:
remove
in interfacejava.util.Map<java.lang.String,java.lang.String>
-
size
public int size()
- Specified by:
size
in interfacejava.util.Map<java.lang.String,java.lang.String>
-
values
public java.util.Collection<java.lang.String> values()
- Specified by:
values
in interfacejava.util.Map<java.lang.String,java.lang.String>
-
-