Coverage report

  %line %branch
org.apache.commons.jelly.tags.ojb.StoreTag
0% 
0% 

 1  
 /*
 2  
  * Copyright 2002,2004 The Apache Software Foundation.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.apache.commons.jelly.tags.ojb;
 17  
 
 18  
 import org.apache.commons.jelly.JellyTagException;
 19  
 import org.apache.commons.jelly.TagSupport;
 20  
 import org.apache.commons.jelly.XMLOutput;
 21  
 import org.apache.ojb.broker.PersistenceBroker;
 22  
 
 23  
 /**
 24  
  * <p>This Store tag will store the given object in ObjectBridge using
 25  
  * the given broker or it will use the parent broker tags broker instance.</p>
 26  
  *
 27  
  * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
 28  
  * @version $Revision: 1.4 $
 29  
  */
 30  0
 public class StoreTag extends TagSupport {
 31  
 
 32  
     /** the value to persist */
 33  
     private Object value;
 34  
 
 35  
     /** The persistence broker instance */
 36  
     private PersistenceBroker broker;
 37  
 
 38  0
     public StoreTag() {
 39  0
     }
 40  
 
 41  
 
 42  
     // Tag interface
 43  
     //-------------------------------------------------------------------------
 44  
     public void doTag(XMLOutput output) throws JellyTagException {
 45  0
         if ( value == null ) {
 46  0
             throw new JellyTagException( "No value is supplied!" );
 47  
         }
 48  0
         getBroker().store( value );
 49  0
     }
 50  
 
 51  
     // Properties
 52  
     //-------------------------------------------------------------------------
 53  
 
 54  
     /** Sets the value to be persisted */
 55  
     public void setValue(Object value) {
 56  0
         this.value = value;
 57  0
     }
 58  
 
 59  
     /** @return the persistence broker instance */
 60  
     public PersistenceBroker getBroker() {
 61  0
         if (broker == null) {
 62  0
             BrokerTag brokerTag = (BrokerTag) findAncestorWithClass( BrokerTag.class );
 63  0
             if ( brokerTag != null ) {
 64  0
                 broker = brokerTag.getBroker();
 65  
             }
 66  
             else {
 67  0
                 broker = (PersistenceBroker) context.getVariable(
 68  
                     "org.apache.commons.jelly.ojb.Broker"
 69  
                 );
 70  
             }
 71  
         }
 72  0
         return broker;
 73  
     }
 74  
 
 75  
     /** Sets the persistence broker instance */
 76  
     public void setBroker(PersistenceBroker broker) {
 77  0
         this.broker = broker;
 78  0
     }
 79  
 }
 80  
 

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.