예제 #1
0
        private void ExtractValues(string elementName, XmlReader reader)
        {
            for (int i = 0; i < reader.AttributeCount; ++i)
            {
                reader.MoveToAttribute(i);

                string name  = reader.Name;
                string value = reader.Value;

                if (E.Equals(name))
                {
                    this.element = value.ToElement();
                }
                else if (K.Equals(name))
                {
                    this.keys = value;
                }
                else if (V.Equals(name))
                {
                    this.values = value;
                }
                else if (CAT.Equals(name))
                {
                    this.cat = value;
                }
                else if (CLOSED.Equals(name))
                {
                    this.closed = value.ToClosed();
                }
                else if (ZOOM_MIN.Equals(name))
                {
                    this.zoomMin = XmlUtils.ParseNonNegativeByte(name, value);
                }
                else if (ZOOM_MAX.Equals(name))
                {
                    this.zoomMax = XmlUtils.ParseNonNegativeByte(name, value);
                }
                else
                {
                    throw XmlUtils.CreateXmlReaderException(elementName, name, value, i);
                }
            }

            Validate(elementName);

            this.keyList   = new List <string>(this.keys.Split(SPLIT_PATTERN, StringSplitOptions.RemoveEmptyEntries));
            this.valueList = new List <string>(this.values.Split(SPLIT_PATTERN, StringSplitOptions.RemoveEmptyEntries));

            this.elementMatcher = getElementMatcher(this.element);
            this.closedMatcher  = GetClosedMatcher(this.closed);

            this.elementMatcher = RuleOptimizer.optimize(this.elementMatcher, this.ruleStack);
            this.closedMatcher  = RuleOptimizer.optimize(this.closedMatcher, this.ruleStack);
        }
예제 #2
0
        /// <returns> a new {@code Rule} instance. </returns>
        public virtual Rule Build()
        {
            if (this.valueList.Remove(STRING_NEGATION))
            {
                AttributeMatcher attributeMatcher = new NegativeMatcher(this.keyList, this.valueList);
                return(new NegativeRule(this, attributeMatcher));
            }

            AttributeMatcher keyMatcher   = GetKeyMatcher(this.keyList);
            AttributeMatcher valueMatcher = GetValueMatcher(this.valueList);

            keyMatcher   = RuleOptimizer.optimize(keyMatcher, this.ruleStack);
            valueMatcher = RuleOptimizer.optimize(valueMatcher, this.ruleStack);

            return(new PositiveRule(this, keyMatcher, valueMatcher));
        }