uk.me.parabola.mkgmap.osmstyle
Class RuleSet

java.lang.Object
  extended by uk.me.parabola.mkgmap.osmstyle.RuleSet
All Implemented Interfaces:
java.lang.Iterable<Rule>, Rule

public class RuleSet
extends java.lang.Object
implements Rule, java.lang.Iterable<Rule>

A list of rules and the logic to select the correct one. A separate RuleIndex class is used to speed access to the rule list.

Author:
Steve Ratcliffe

Constructor Summary
RuleSet()
           
 
Method Summary
 void add(java.lang.String keystring, Rule rule, java.util.Set<java.lang.String> changeableTags)
          Add a rule to this rule set.
 void addAll(RuleSet rs)
          Add all rules from the given rule set to this one.
 void addUsedTags(java.util.Collection<java.lang.String> usedTags)
           
 java.util.Set<java.lang.String> getUsedTags()
           
 java.util.Iterator<Rule> iterator()
           
 void merge(RuleSet rs)
          Merge the two rulesets together so that they appear to be one.
 void prepare()
          Prepare this rule set for use.
 void resolveType(Element el, TypeResult result)
          Resolve the type for this element by running the rules in order.
 java.lang.String toString()
          Format the rule set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RuleSet

public RuleSet()
Method Detail

resolveType

public void resolveType(Element el,
                        TypeResult result)
Resolve the type for this element by running the rules in order. This is a very performance critical part of the style system as parts of the code are run for every tag in the input file.

Specified by:
resolveType in interface Rule
Parameters:
el - The element as read from an OSM xml file in 'tag' format.
result - A GType describing the Garmin type of the first rule that matches is returned here. If continue types are used then more than one type may be saved here. If there are no matches then nothing will be saved.

iterator

public java.util.Iterator<Rule> iterator()
Specified by:
iterator in interface java.lang.Iterable<Rule>

add

public void add(java.lang.String keystring,
                Rule rule,
                java.util.Set<java.lang.String> changeableTags)
Add a rule to this rule set.

Parameters:
keystring - The string form of the first term of the rule. It will be A=B or A=*. (In the future we may allow other forms).
rule - The actual rule.
changeableTags - The tags that may be changed by the rule. This will be either a plain tag name A, or with a value A=B.

addAll

public void addAll(RuleSet rs)
Add all rules from the given rule set to this one.

Parameters:
rs - The other rule set.

toString

public java.lang.String toString()
Format the rule set. Warning: this doesn't produce a valid input rule file.

Overrides:
toString in class java.lang.Object

merge

public void merge(RuleSet rs)
Merge the two rulesets together so that they appear to be one.

Parameters:
rs - The other rule set, it will have lower priority, that is the rules will be tried after the rules of this ruleset.

prepare

public void prepare()
Prepare this rule set for use. The index is built and and the rules are saved to an array for fast access.


getUsedTags

public java.util.Set<java.lang.String> getUsedTags()

addUsedTags

public void addUsedTags(java.util.Collection<java.lang.String> usedTags)