public abstract class AbstractExpansion extends Object implements Expansion
doExpansion
method to be overridden with the appropriate logic.Modifier and Type | Field and Description |
---|---|
static String |
CFG_COMMENT_STR
String to mark the line as a comment in the configuration file
|
static String |
DEFAULT_CONFIG_FILE_NAME
Default filename for the user attribute mapping configuration file.
|
static String |
DEFAULT_VALUE_SEPARATOR
Default string that separates individual attributes in the replacement strings.
|
protected Map<String,List<String[]>> |
expansionTable |
protected static org.slf4j.Logger |
LOGGER |
static String |
RULE_SPLIT_REGEX
Separator for various parts of the rules when presented as a string.
|
protected Pattern |
rulePattern |
static String |
SEPARATOR_PREFIX
String to identify the line containing the attribute separator string in the configuration
file.
|
Constructor and Description |
---|
AbstractExpansion() |
Modifier and Type | Method and Description |
---|---|
void |
addExpansionList(String key,
List<String[]> list)
Adds a list of rules corresponding to the give key in the expansion map.
|
void |
addExpansionRule(String key,
String[] rule)
Adds an individual expansion rule to the existing (or newly created) expansion map.
|
protected abstract String |
doExpansion(String original,
String[] rule)
This is the method that will do the actual expansion - interpreting the rules and expanding the
values.
|
Map<String,Set<String>> |
expand(Map<String,Set<String>> map)
Expands the values for an entire map of security entries.
|
Set<String> |
expand(String key,
Set<String> values)
Expands the values for a given key and its values.
|
Map<String,List<String[]>> |
getExpansionMap()
Returns the list of configured expansions.
|
protected void |
loadConfiguration(String filename)
Does the work of reading the configuration file and configuring the expansion map and attribute
separator.
|
boolean |
removeExpansionRule(String key,
String[] rule)
Removes a single rule from the expansion map (if it exists).
|
void |
setAttributeSeparator(String separator)
Sets the separator to be used in splitting up replacement strings.
|
void |
setExpansionFileName(String filename)
Sets the name of the configuration file defining the attribute separator and the mapping of
attributes to their expanded values.
|
void |
setExpansionMap(Map<String,List<String[]>> table)
Sets the expansion map (which includes a set of keys corresponding to attribute names, each
with a corresponding list of rules that apply to that attribute.
|
void |
setExpansionRules(List<String> rulesList)
Adds a list of rules provided in String form.
|
protected Collection<String> |
split(String source,
String separator)
Takes a string with potentially multiple values and splits it into a collection of strings.
|
void |
update(Map<String,String> properties) |
public static final String DEFAULT_VALUE_SEPARATOR
public static final String RULE_SPLIT_REGEX
public static final String CFG_COMMENT_STR
public static final String SEPARATOR_PREFIX
public static final String DEFAULT_CONFIG_FILE_NAME
protected static final org.slf4j.Logger LOGGER
protected Pattern rulePattern
public Map<String,Set<String>> expand(Map<String,Set<String>> map)
Expansion
public Set<String> expand(String key, Set<String> values)
Expansion
protected abstract String doExpansion(String original, String[] rule)
original
- the original value of the attributerule
- the rule that describes the expansion for one specific attribute valuepublic Map<String,List<String[]>> getExpansionMap()
Expansion
getExpansionMap
in interface Expansion
public void setExpansionMap(Map<String,List<String[]>> table)
table
- the complete map of attributes and their corresponding list of rulespublic void addExpansionRule(String key, String[] rule)
key
- the attribute for which the corresponding rule should be addedrule
- the expansion rule to apply to the corresponding attributepublic boolean removeExpansionRule(String key, String[] rule)
key
- the attribute for which the corresponding rule should be removedrule
- the rule to be removed from the list of rules for the corresponding attributepublic void addExpansionList(String key, List<String[]> list)
key
- the attribute for which the corresponding list of rules will be addedlist
- the list of rules to be added to the corresponding attributepublic void setExpansionRules(List<String> rulesList)
rulesList
- list of rules (in String form) to be added to the expansion mapprotected Collection<String> split(String source, String separator)
source
- input source string potentially containing multiple tokensseparator
- the sequence separating the individual tokenspublic void setAttributeSeparator(String separator)
separator
- the separator to be used to split up replacement stringspublic void setExpansionFileName(String filename)
filename
- the name of the configuration file to be loaded into the expansion serviceprotected void loadConfiguration(String filename)
filename
- the name of the file to be read and processedThis work is licensed under a Creative Commons Attribution 4.0 International License.