Coverage report

  %line %branch
org.apache.jetspeed.rewriter.html.SwingAttributes
0% 
0% 

 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  * 
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  * 
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.jetspeed.rewriter.html;
 18  
 
 19  
 import java.util.Enumeration;
 20  
 
 21  
 import javax.swing.text.MutableAttributeSet;
 22  
 import javax.swing.text.html.HTML;
 23  
 import javax.swing.text.html.HTML.Attribute;
 24  
 
 25  
 import org.apache.jetspeed.rewriter.MutableAttributes;
 26  
 
 27  
 
 28  
 /**
 29  
  * SwingAttributes
 30  
  *
 31  
  * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
 32  
  * @version $Id: SwingAttributes.java 516448 2007-03-09 16:25:47Z ate $
 33  
  */
 34  
 public class SwingAttributes implements MutableAttributes
 35  
 {
 36  
     MutableAttributeSet swingset;
 37  
     
 38  
     public SwingAttributes(MutableAttributeSet swingset)
 39  0
     {
 40  0
         this.swingset = swingset;
 41  0
     }
 42  
     
 43  
     /* (non-Javadoc)
 44  
      * @see org.xml.sax.Attributes#getLength()
 45  
      */
 46  
     public int getLength()
 47  
     {
 48  0
         return swingset.getAttributeCount();
 49  
     }
 50  
     
 51  
     /* (non-Javadoc)
 52  
      * @see org.xml.sax.Attributes#getURI(int)
 53  
      */
 54  
     public String getURI(int index)
 55  
     {
 56  0
         return "";
 57  
     }
 58  
     
 59  
     /* (non-Javadoc)
 60  
      * @see org.xml.sax.Attributes#getLocalName(int)
 61  
      */
 62  
     public String getLocalName(int index)
 63  
     {
 64  0
         Enumeration e = swingset.getAttributeNames();
 65  0
         int ix = 0;
 66  0
         while (e.hasMoreElements())
 67  
         {
 68  0
             Object object = e.nextElement();
 69  0
             if (ix == index)
 70  
             {
 71  0
                 return object.toString();
 72  
             }
 73  0
         }
 74  0
         return null;
 75  
     }
 76  
     
 77  
     /* (non-Javadoc)
 78  
      * @see org.xml.sax.Attributes#getQName(int)
 79  
      */
 80  
     public String getQName(int index)
 81  
     {
 82  0
         return getLocalName(index);
 83  
     }
 84  
     
 85  
     /* (non-Javadoc)
 86  
      * @see org.xml.sax.Attributes#getType(int)
 87  
      */
 88  
     public String getType(int index)
 89  
     {
 90  0
         return "CDATA";
 91  
     }
 92  
     
 93  
     /* (non-Javadoc)
 94  
      * @see org.xml.sax.Attributes#getValue(int)
 95  
      */
 96  
     public String getValue(int index)
 97  
     {
 98  0
         Enumeration e = swingset.getAttributeNames();
 99  0
         int ix = 0;
 100  0
         while (e.hasMoreElements())
 101  
         {
 102  0
             Object object = e.nextElement();
 103  0
             if (ix == index)
 104  
             {
 105  0
                 return (String)swingset.getAttribute(object);
 106  
             }
 107  0
         }
 108  0
         return null;
 109  
     }
 110  
     
 111  
     /* (non-Javadoc)
 112  
      * @see org.xml.sax.Attributes#getIndex(java.lang.String, java.lang.String)
 113  
      */
 114  
     public int getIndex(String uri, String localPart)
 115  
     {
 116  0
         return getIndex(localPart);
 117  
     }
 118  
     
 119  
     /* (non-Javadoc)
 120  
      * @see org.xml.sax.Attributes#getIndex(java.lang.String)
 121  
      */
 122  
     public int getIndex(String qName)
 123  
     {
 124  0
         Enumeration e = swingset.getAttributeNames();
 125  0
         int ix = 0;
 126  0
         while (e.hasMoreElements())
 127  
         {
 128  0
             String name = (String)e.nextElement();
 129  0
             if (name.equalsIgnoreCase(qName))
 130  
             {
 131  0
                 return ix;
 132  
             }
 133  0
         }
 134  0
         return -1;
 135  
     }
 136  
     
 137  
     /* (non-Javadoc)
 138  
      * @see org.xml.sax.Attributes#getType(java.lang.String, java.lang.String)
 139  
      */
 140  
     public String getType(String uri, String localName)
 141  
     {
 142  0
         return "CDATA";
 143  
     }
 144  
     
 145  
     /* (non-Javadoc)
 146  
      * @see org.xml.sax.Attributes#getType(java.lang.String)
 147  
      */
 148  
     public String getType(String qName)
 149  
     {
 150  0
         return "CDATA";
 151  
     }
 152  
     
 153  
     /* (non-Javadoc)
 154  
      * @see org.xml.sax.Attributes#getValue(java.lang.String, java.lang.String)
 155  
      */
 156  
     public String getValue(String uri, String localName)
 157  
     {
 158  0
         return getValue(localName);
 159  
     }
 160  
     
 161  
     /* (non-Javadoc)
 162  
      * @see org.xml.sax.Attributes#getValue(java.lang.String)
 163  
      */
 164  
     public String getValue(String qName)
 165  
     {
 166  0
         Attribute att = HTML.getAttributeKey(qName.toLowerCase());        
 167  0
         return (String)swingset.getAttribute(att);
 168  
     }
 169  
 
 170  
     /* (non-Javadoc)
 171  
      * @see org.apache.jetspeed.cps.rewriter.MutableAttributes#addAttribute(java.lang.String, java.lang.Object)
 172  
      */
 173  
     public void addAttribute(String name, Object value)
 174  
     {
 175  0
         Attribute att = HTML.getAttributeKey(name.toLowerCase());
 176  0
         swingset.addAttribute(att, value);
 177  0
     }
 178  
 
 179  
 }

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