Clover coverage report - Code Coverage for hivemind release 1.1-beta-1
Coverage timestamp: Thu Apr 28 2005 19:53:41 EDT
file stats: LOC: 70   Methods: 4
NCLOC: 32   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 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  696
     public void begin(SchemaProcessor processor, Element element)
 36   
     {
 37  696
         Translator t = processor.getAttributeTranslator(_attributeName);
 38   
 
 39  696
         String attributeValue = element.getAttributeValue(_attributeName);
 40  696
         String value = RuleUtils.processText(processor, element, attributeValue);
 41   
 
 42  696
         Object finalValue = t.translate(
 43   
                 processor.getContributingModule(),
 44   
                 Object.class,
 45   
                 value,
 46   
                 element.getLocation());
 47   
 
 48  696
         processor.push(finalValue);
 49   
     }
 50   
 
 51   
     /**
 52   
      * Invokes {@link SchemaProcessor#pop()}.
 53   
      */
 54  696
     public void end(SchemaProcessor processor, Element element)
 55   
     {
 56  696
         processor.pop();
 57   
     }
 58   
 
 59  356
     public void setAttributeName(String string)
 60   
     {
 61  356
         _attributeName = string;
 62   
     }
 63   
 
 64  10
     public String getAttributeName()
 65   
     {
 66  10
         return _attributeName;
 67   
     }
 68   
 
 69   
 }
 70