Coverage Report - net.sf.jolene.dom.Header
 
Classes in this File Line Coverage Branch Coverage Complexity
Header
88%
14/16
83%
5/6
0
 
 1  
 package net.sf.jolene.dom;
 2  
 
 3  
 import net.sf.jolene.constants.Tags;
 4  
 
 5  
 /**
 6  
  * An element in the header in a html document. Usually a meta, script, link or style tag.
 7  
  *
 8  
  * @author Dan Howard
 9  
  * @since Sep 19, 2006 9:11:49 AM
 10  
  */
 11  0
 public final class Header extends HTMLElement {
 12  
 
 13  
     /**
 14  
      * Default construcor.
 15  
      */
 16  80
     public Header() {
 17  80
         tag = Tags.meta;
 18  80
     }
 19  
 
 20  
     /**
 21  
      * Construct a Header using a predefined Tag. Note the shoot in the footness here. You can define a header with
 22  
      * any defined Tag.  Really you should only use meta, link, script or style.
 23  
      *
 24  
      * @param tag A Tag enum. Usually script, link, meta.
 25  
      */
 26  
     public Header(Tags tag) {
 27  5
         this();
 28  5
         this.tag = tag;
 29  5
     }
 30  
 
 31  
 
 32  
     /**
 33  
      * Returns a clone of the header element object.
 34  
      *
 35  
      * @return Header object.
 36  
      */
 37  
     @Override
 38  
     public Header clone() {
 39  1
         return (Header) super.clone();
 40  
     }
 41  
 
 42  
     @Override
 43  
     public void setValue(String value) {
 44  48
         super.setValue(value);
 45  48
         setContent(value);
 46  48
     }
 47  
 
 48  
 
 49  
     /**
 50  
      * Renders the Header.
 51  
      *
 52  
      * @return The header element as a html string.
 53  
      */
 54  
     @Override
 55  
     public String toString() {
 56  
 
 57  78
         if (swapWith != null) {
 58  0
             return swapWith.toString();
 59  
         }
 60  
 
 61  78
         if (Tags.script == tag || Tags.style == tag) {
 62  28
             return super.toString() + getContent() + "</" + tag + '>';
 63  
         }
 64  50
         return super.toString();
 65  
     }
 66  
 }