2009/04/15 - Apache HiveMind has been retired.

For more information, please explore the Attic.

Clover coverage report - Code Coverage for hivemind release 1.2.1
Coverage timestamp: Fri Feb 10 2006 16:33:43 PST
file stats: LOC: 69   Methods: 4
NCLOC: 32   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
PushAttributeRule.java - 100% 100% 100%
coverage
 1    // Copyright 2004, 2005 The Apache Software Foundation
 2    //
 3    // Licensed under the Apache License, Version 2.0 (the "License");
 4    // you may not use this file except in compliance with the License.
 5    // You may obtain a copy of the License at
 6    //
 7    // http://www.apache.org/licenses/LICENSE-2.0
 8    //
 9    // Unless required by applicable law or agreed to in writing, software
 10    // distributed under the License is distributed on an "AS IS" BASIS,
 11    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12    // See the License for the specific language governing permissions and
 13    // limitations under the License.
 14   
 15    package org.apache.hivemind.schema.rules;
 16   
 17    import org.apache.hivemind.Element;
 18    import org.apache.hivemind.schema.SchemaProcessor;
 19    import org.apache.hivemind.schema.Translator;
 20   
 21    /**
 22    * A rule that reads an attribute, passes it through a translator, then pushes the result onto the
 23    * processor stack.
 24    *
 25    * @author Howard Lewis Ship
 26    */
 27    public class PushAttributeRule extends BaseRule
 28    {
 29    private String _attributeName;
 30   
 31    /**
 32    * Uses the translator to convert the specified attribute into an object and pushes that object
 33    * onto the processor stack.
 34    */
 35  739 public void begin(SchemaProcessor processor, Element element)
 36    {
 37  739 Translator t = processor.getAttributeTranslator(_attributeName);
 38   
 39  739 String attributeValue = element.getAttributeValue(_attributeName);
 40  739 String value = RuleUtils.processText(processor, element, attributeValue);
 41   
 42  739 Object finalValue = t.translate(
 43    processor.getContributingModule(),
 44    Object.class,
 45    value,
 46    element.getLocation());
 47   
 48  739 processor.push(finalValue);
 49    }
 50   
 51    /**
 52    * Invokes {@link SchemaProcessor#pop()}.
 53    */
 54  739 public void end(SchemaProcessor processor, Element element)
 55    {
 56  739 processor.pop();
 57    }
 58   
 59  378 public void setAttributeName(String string)
 60    {
 61  378 _attributeName = string;
 62    }
 63   
 64  10 public String getAttributeName()
 65    {
 66  10 return _attributeName;
 67    }
 68   
 69    }