public final class MatchPhraseDictionary extends java.lang.Object implements MatchPhraseConstants
NameConverter
class. A match phrase definition
consists of a string token to be matched and a string value with which
to replace the token once it has been matched. NameConverter
uses these definitions to carry out its string conversion operations.
Several categories of match phrase definitions are managed by this
dictionary (identifier constants are defined in MatchPhraseConstants
):
STANDARD
- standard set of replacements which are
broadly applicable across all name symbols. These typically include
special characters, such as separators and similar symbols.
CUSTOM
- a set of substring replacements which is
specific to the naming conventions of a particular project or
customer. These typically include acronym and abbreviation expansions.
PRESERVE
- a set of substrings which represent tokens
to be left unconverted in the output string. This provides a
mechanism to override other, less specific match phrase definitions
which might otherwise cause unexpected or undesirable conversions.
matchlist
parameter).Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
ATTR_FULL
XML attribute defining the if only a fulltext match is valid.
|
private static java.lang.String |
ATTR_MATCH
XML attribute defining the match token
|
private static java.lang.String |
ATTR_REPLACE
XML attribute defining the replacement string
|
private static MatchPhraseDictionary |
cache
A cached instance of this object
|
private static java.lang.String |
CFG_MATCHLIST
Match list parameter key in global configuration
|
private static java.lang.String |
ELEM_CUSTOM
XML element containing all custom match phrases
|
private static java.lang.String |
ELEM_PHRASE
XML match phrase element
|
private static java.lang.String |
ELEM_PRESERVE
XML element containing all preserve match phrases
|
private static java.lang.String |
ELEM_STANDARD
XML element containing all standard match phrases
|
private java.util.Map<java.lang.String,java.lang.String> |
fulltxt
Map of full text names.
|
private java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> |
maps
Map of objects containing the match phrase definitions
|
ALL, CUSTOM, PRESERVE, STANDARD, TYPE_CLASS, TYPE_COLUMN, TYPE_CONSTANT, TYPE_DATABASE, TYPE_INDEX, TYPE_METHOD, TYPE_PROPERTY, TYPE_SIMPLE, TYPE_TABLE, TYPE_VARIABLE
Constructor and Description |
---|
MatchPhraseDictionary(java.util.Map<java.lang.String,java.lang.String> std)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.String,java.lang.String> |
getEntries(int categories)
Get a map containing all match phrase definitions included in the
requested subset of match phrase categories.
|
java.util.Map<java.lang.String,java.lang.String> |
getFullText()
Get a map containing all forced full text matches.
|
static MatchPhraseDictionary |
load(boolean force,
java.util.Map<java.lang.String,java.lang.String> std)
Load the match phrase dictionary definitions from the default persisted
match list defined for the current project.
|
static MatchPhraseDictionary |
load(java.lang.String list,
java.util.Map<java.lang.String,java.lang.String> std)
Load or reload the match phrase dictionary definitions from the given
persisted match list defined for the current project.
|
private void |
loadEntries(org.w3c.dom.Document dom)
Load the match phrase definitions from the specified XML document.
|
void |
putFullText(java.lang.String match,
java.lang.String replace)
Put a specific mapping into the forced full text matches list.
|
private static final java.lang.String CFG_MATCHLIST
private static final java.lang.String ELEM_STANDARD
private static final java.lang.String ELEM_CUSTOM
private static final java.lang.String ELEM_PRESERVE
private static final java.lang.String ELEM_PHRASE
private static final java.lang.String ATTR_MATCH
private static final java.lang.String ATTR_REPLACE
private static final java.lang.String ATTR_FULL
private static MatchPhraseDictionary cache
private java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> maps
private java.util.Map<java.lang.String,java.lang.String> fulltxt
public MatchPhraseDictionary(java.util.Map<java.lang.String,java.lang.String> std)
std
- The standard mappings that should always be available.public static MatchPhraseDictionary load(java.lang.String list, java.util.Map<java.lang.String,java.lang.String> std) throws ConfigurationException
list
- The match list to use or null
to use the default
match list.std
- The standard mappings that should always be available.ConfigurationException
- if there is any error with the global configuration or an
error loading the dictionary from persistence. A missing
match list file is not fatal and does not trigger
this exception, but does elicit a warning message to
stderr
.public static MatchPhraseDictionary load(boolean force, java.util.Map<java.lang.String,java.lang.String> std) throws ConfigurationException
force
option is true
, in which case a
reload from persistence is forced.force
- true
to force a load from persistence,
regardless of whether a cached dictionary is available;
false
to lazily load the dictionary.std
- The standard mappings that should always be available.ConfigurationException
- if there is any error with the global configuration or an
error loading the dictionary from persistence. A missing
match list file is not fatal and does not trigger
this exception, but does elicit a warning message to
stderr
.public java.util.Map<java.lang.String,java.lang.String> getEntries(int categories)
categories
- A bitwise OR'd combination of match phrase categories.
Expects the category identifiers defined in MatchPhraseConstants
.public java.util.Map<java.lang.String,java.lang.String> getFullText()
public void putFullText(java.lang.String match, java.lang.String replace)
match
- The text to match.replace
- The replacement text.private void loadEntries(org.w3c.dom.Document dom) throws ConfigurationException
MatchPhraseConstants
category identifier
constants with the getEntries(int)
method.dom
- XML document object model containing the definitions.ConfigurationException
- if an illegal match phrase category is encountered.