Coverage Report - org.apache.xmlrpc.serializer.TypeSerializerImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
TypeSerializerImpl
100% 
100% 
1,667
 
 1  
 /*
 2  
  * Copyright 1999,2005 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.xmlrpc.serializer;
 17  
 
 18  
 import org.xml.sax.Attributes;
 19  
 import org.xml.sax.ContentHandler;
 20  
 import org.xml.sax.SAXException;
 21  
 import org.xml.sax.helpers.AttributesImpl;
 22  
 
 23  
 
 24  
 /** Abstract base implementation of a type serializer.
 25  
  */
 26  110
 public abstract class TypeSerializerImpl implements TypeSerializer {
 27  1
         protected static final Attributes ZERO_ATTRIBUTES = new AttributesImpl();
 28  
         /** Tag name of a value element.
 29  
          */
 30  
         public static final String VALUE_TAG = "value";
 31  
 
 32  
         protected void write(ContentHandler pHandler, String pTagName, String pValue) throws SAXException {
 33  507
                 write(pHandler, pTagName, pValue.toCharArray());
 34  507
         }
 35  
 
 36  
         protected void write(ContentHandler pHandler, String pTagName, char[] pValue) throws SAXException {
 37  507
                 pHandler.startElement("", TypeSerializerImpl.VALUE_TAG, TypeSerializerImpl.VALUE_TAG, ZERO_ATTRIBUTES);
 38  507
                 if (pTagName != null) {
 39  395
                         pHandler.startElement("", pTagName, pTagName, ZERO_ATTRIBUTES);
 40  
                 }
 41  507
                 pHandler.characters(pValue, 0, pValue.length);
 42  507
                 if (pTagName != null) {
 43  395
                         pHandler.endElement("", pTagName, pTagName);
 44  
                 }
 45  507
                 pHandler.endElement("", TypeSerializerImpl.VALUE_TAG, TypeSerializerImpl.VALUE_TAG);
 46  507
         }
 47  
 
 48  
         protected void write(ContentHandler pHandler, String pLocalName, String pQName,
 49  
                                                  String pValue) throws SAXException {
 50  129
                 pHandler.startElement("", TypeSerializerImpl.VALUE_TAG, TypeSerializerImpl.VALUE_TAG, ZERO_ATTRIBUTES);
 51  129
                 pHandler.startElement(XmlRpcWriter.EXTENSIONS_URI, pLocalName, pQName, ZERO_ATTRIBUTES);
 52  129
                 char[] value = pValue.toCharArray();
 53  129
                 pHandler.characters(value, 0, value.length);
 54  129
                 pHandler.endElement(XmlRpcWriter.EXTENSIONS_URI, pLocalName, pQName);
 55  129
                 pHandler.endElement("", TypeSerializerImpl.VALUE_TAG, TypeSerializerImpl.VALUE_TAG);
 56  129
         }
 57  
 }