Coverage Report - org.apache.myfaces.shared_impl.test.ClassElementHandler
 
Classes in this File Line Coverage Branch Coverage Complexity
ClassElementHandler
0%
0/28
0%
0/8
1.8
 
 1  
 /*
 2  
  *  Licensed to the Apache Software Foundation (ASF) under one
 3  
  *  or more contributor license agreements.  See the NOTICE file
 4  
  *  distributed with this work for additional information
 5  
  *  regarding copyright ownership.  The ASF licenses this file
 6  
  *  to you under the Apache License, Version 2.0 (the
 7  
  *  "License"); you may not use this file except in compliance
 8  
  *  with the License.  You may obtain a copy of the License at
 9  
  * 
 10  
  *  http://www.apache.org/licenses/LICENSE-2.0
 11  
  * 
 12  
  *  Unless required by applicable law or agreed to in writing,
 13  
  *  software distributed under the License is distributed on an
 14  
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  *  KIND, either express or implied.  See the License for the
 16  
  *  specific language governing permissions and limitations
 17  
  *  under the License.
 18  
  */
 19  
 package org.apache.myfaces.shared_impl.test;
 20  
 
 21  
 import java.util.List;
 22  
 import java.util.ArrayList;
 23  
 
 24  
 import org.xml.sax.Attributes;
 25  
 import org.xml.sax.SAXException;
 26  
 import org.xml.sax.helpers.DefaultHandler;
 27  
 
 28  
 /**
 29  
  * @see AbstractClassElementTestCase
 30  
  * @author Dennis Byrne
 31  
  */
 32  
 
 33  
 public class ClassElementHandler extends DefaultHandler
 34  
 {
 35  
     
 36  
     private boolean clazz ;
 37  0
     private List elementName = new ArrayList();
 38  0
     private List className = new ArrayList();
 39  
     private StringBuffer buffer ;
 40  
     
 41  0
     public ClassElementHandler(){
 42  
         
 43  0
         elementName.add("component-class");
 44  0
         elementName.add("tag-class");
 45  0
         elementName.add("renderer-class");
 46  0
         elementName.add("validator-class");
 47  0
         elementName.add("converter-class");
 48  0
         elementName.add("action-listener");
 49  0
         elementName.add("navigation-handler");
 50  0
         elementName.add("variable-resolver");
 51  0
         elementName.add("property-resolver");
 52  0
         elementName.add("phase-listener");
 53  
         
 54  0
     }
 55  
 
 56  
     public void characters(char[] ch, int start, int length)
 57  
     throws SAXException
 58  
     {
 59  0
         if (clazz)
 60  
         {
 61  0
             String string = new String(ch, start, length);
 62  0
             if(string != null)
 63  
             {
 64  0
                 buffer.append(string.trim());
 65  
             }
 66  
         }
 67  0
     }
 68  
     
 69  
     public void startElement(
 70  
             String ns, String local, String qName, Attributes atts) 
 71  
             throws SAXException
 72  
     {
 73  
        
 74  0
          clazz = elementName.contains(qName);
 75  
          
 76  0
          if(clazz)
 77  0
              buffer = new StringBuffer();
 78  
         
 79  0
     }
 80  
 
 81  
     public void endElement(String ns, String local, String qName) 
 82  
         throws SAXException
 83  
     {
 84  
         
 85  0
         if(clazz){
 86  0
             className.add(buffer.toString());
 87  0
             clazz = false;
 88  
         }
 89  
         
 90  0
     }
 91  
 
 92  
     public List getClassName()
 93  
     {
 94  0
         return className;
 95  
     }
 96  
     
 97  
 }