Coverage report

  %line %branch
org.apache.commons.jelly.tags.swing.BorderAlignTag
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.swing;
 17  
 
 18  
 import java.awt.BorderLayout;
 19  
 import java.awt.Component;
 20  
 
 21  
 import org.apache.commons.jelly.JellyTagException;
 22  
 import org.apache.commons.jelly.TagSupport;
 23  
 import org.apache.commons.jelly.XMLOutput;
 24  
 
 25  
 /**
 26  
  * Represents a layout of a child component within its parent <borderLayout> layout.
 27  
  *
 28  
  * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
 29  
  * @version $Revision: 155420 $
 30  
  */
 31  0
 public class BorderAlignTag extends TagSupport implements ContainerTag {
 32  
 
 33  
     private String align;
 34  
 
 35  
     // ContainerTag interface
 36  
     //-------------------------------------------------------------------------
 37  
 
 38  
     /**
 39  
      * Adds a child component to this parent
 40  
      */
 41  
     public void addChild(Component component, Object constraints) throws JellyTagException {
 42  0
         BorderLayoutTag tag = (BorderLayoutTag) findAncestorWithClass( BorderLayoutTag.class );
 43  0
         if (tag == null) {
 44  0
             throw new JellyTagException( "this tag must be nested within a <borderLayout> tag" );
 45  
         }
 46  0
         tag.addLayoutComponent(component, getConstraints());
 47  0
     }
 48  
 
 49  
     // Tag interface
 50  
     //-------------------------------------------------------------------------
 51  
     public void doTag(final XMLOutput output) throws JellyTagException {
 52  0
         invokeBody(output);
 53  0
     }
 54  
 
 55  
     // Properties
 56  
     //-------------------------------------------------------------------------
 57  
 
 58  
     /**
 59  
      * Returns the align.
 60  
      * @return String
 61  
      */
 62  
     public String getAlign() {
 63  0
         return align;
 64  
     }
 65  
 
 66  
     /**
 67  
      * Sets the alignment of the child component which is a case insensitive value
 68  
      * of {NORTH, SOUTH, EAST, WEST, CENTER} which defaults to CENTER
 69  
      */
 70  
     public void setAlign(String align) {
 71  0
         this.align = align;
 72  0
     }
 73  
 
 74  
     // Implementation methods
 75  
     //-------------------------------------------------------------------------
 76  
 
 77  
     protected Object getConstraints() {
 78  0
         if ("north".equalsIgnoreCase(align)) {
 79  0
             return BorderLayout.NORTH;
 80  
         }
 81  0
         else if ("south".equalsIgnoreCase(align)) {
 82  0
             return BorderLayout.SOUTH;
 83  
         }
 84  0
         else if ("east".equalsIgnoreCase(align)) {
 85  0
             return BorderLayout.EAST;
 86  
         }
 87  0
         else if ("west".equalsIgnoreCase(align)) {
 88  0
             return BorderLayout.WEST;
 89  
         }
 90  
         else {
 91  
             // default to CENTER
 92  0
             return BorderLayout.CENTER;
 93  
         }
 94  
     }
 95  
 }
 96  
 

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