public static class MapCSSStyleSource.MapCSSRuleIndex extends java.lang.Object
MapCSSRules, that are indexed by tag key and value.
Speeds up the process of finding all rules that match a certain primitive.
Rules with a ConditionFactory.SimpleKeyValueCondition [key=value] or rules that require a specific key to be set are
indexed. Now you only need to loop the tags of a primitive to retrieve the possibly matching rules.
To use this index, you need to add(MapCSSRule) all rules to it. You then need to call
initIndex(). Afterwards, you can use getRuleCandidates(IPrimitive) to get an iterator over
all rules that might be applied to that primitive.| Modifier and Type | Class and Description |
|---|---|
private static class |
MapCSSStyleSource.MapCSSRuleIndex.MapCSSKeyRules
This is a map of all rules that are only applied if the primitive has a given key (and possibly value)
|
private class |
MapCSSStyleSource.MapCSSRuleIndex.RuleCandidatesIterator
This is an iterator over all rules that are marked as possible in the bitset.
|
| Modifier and Type | Field and Description |
|---|---|
private java.util.Map<java.lang.String,MapCSSStyleSource.MapCSSRuleIndex.MapCSSKeyRules> |
index
All rules that only apply when the given key is present.
|
private java.util.BitSet |
remaining
Rules that do not require any key to be present.
|
private java.util.List<MapCSSRule> |
rules
All rules this index is for.
|
| Constructor and Description |
|---|
MapCSSRuleIndex() |
| Modifier and Type | Method and Description |
|---|---|
void |
add(MapCSSRule rule)
Add a rule to this index.
|
void |
clear()
Clear the index.
|
private static boolean |
conditionRequiresKeyPresence(ConditionFactory.KeyMatchType matchType) |
private static java.lang.String |
findAnyRequiredKey(java.util.List<Condition> conds)
Search for any key that condition might depend on.
|
private MapCSSStyleSource.MapCSSRuleIndex.MapCSSKeyRules |
getEntryInIndex(java.lang.String key) |
java.util.Iterator<MapCSSRule> |
getRuleCandidates(IPrimitive osm)
Get a subset of all rules that might match the primitive.
|
void |
initIndex()
Initialize the index.
|
private final java.util.List<MapCSSRule> rules
private final java.util.Map<java.lang.String,MapCSSStyleSource.MapCSSRuleIndex.MapCSSKeyRules> index
public MapCSSRuleIndex()
public void add(MapCSSRule rule)
initIndex() is called.rule - The rule to add.public void initIndex()
You must own the write lock of STYLE_SOURCE_LOCK when calling this method.
private static java.lang.String findAnyRequiredKey(java.util.List<Condition> conds)
conds - The conditions to search through.null if there is no such key.private static boolean conditionRequiresKeyPresence(ConditionFactory.KeyMatchType matchType)
private MapCSSStyleSource.MapCSSRuleIndex.MapCSSKeyRules getEntryInIndex(java.lang.String key)
public java.util.Iterator<MapCSSRule> getRuleCandidates(IPrimitive osm)
You must have a read lock of STYLE_SOURCE_LOCK when calling this method.
osm - the primitive to matchpublic void clear()
You must own the write lock STYLE_SOURCE_LOCK when calling this method.