Coverage Report - org.apache.xmlrpc.parser.TypeParserImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
TypeParserImpl
38% 
0% 
1,462
 
 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.parser;
 17  
 
 18  
 import org.apache.xmlrpc.XmlRpcException;
 19  
 import org.xml.sax.Locator;
 20  
 import org.xml.sax.SAXException;
 21  
 import org.xml.sax.SAXParseException;
 22  
 
 23  
 
 24  
 /** Abstract base implementation of a {@link org.apache.xmlrpc.parser.TypeParser},
 25  
  * for derivation of subclasses.
 26  
  */
 27  1200
 public abstract class TypeParserImpl implements TypeParser {
 28  
         private Object result;
 29  
         private Locator locator;
 30  
 
 31  
         /** Sets the result object.
 32  
          * @param pResult The result object.
 33  
          */
 34  920
         public void setResult(Object pResult) { result = pResult; }
 35  920
         public Object getResult() throws XmlRpcException { return result; }
 36  
 
 37  
         /** Returns the document locator.
 38  
          * @return Locator object describing the current location within the
 39  
          * document.
 40  
          */
 41  648
         public Locator getDocumentLocator() { return locator; }
 42  1200
         public void setDocumentLocator(Locator pLocator) { locator = pLocator; }
 43  
 
 44  
         /** PI's are by default ignored.
 45  
          */
 46  
         public void processingInstruction(String pTarget, String pData) throws SAXException {
 47  0
         }
 48  
 
 49  
         /** Skipped entities raise an exception by default.
 50  
          */
 51  
         public void skippedEntity(String pName) throws SAXException {
 52  0
                 throw new SAXParseException("Don't know how to handle entity " + pName,
 53  0
                                                                         getDocumentLocator());
 54  
         }
 55  
 
 56  
         public void startPrefixMapping(String pPrefix, String pURI) throws SAXException {
 57  461
         }
 58  
 
 59  
         public void endPrefixMapping(String pPrefix) throws SAXException {
 60  461
         }
 61  
 
 62  
         public void endDocument() throws SAXException {
 63  1200
         }
 64  
 
 65  
         public void startDocument() throws SAXException {
 66  0
         }
 67  
 
 68  
         protected static boolean isEmpty(char[] pChars, int pStart, int pLength) {
 69  0
                 for (int i = 0;  i < pLength;  i++) {
 70  0
                         if (!Character.isWhitespace(pChars[pStart+i])) {
 71  0
                                 return false;
 72  
                         }
 73  
                 }
 74  0
                 return true;
 75  
         }
 76  
 
 77  
         public void characters(char[] pChars, int pOffset, int pLength) throws SAXException {
 78  0
                 if (!isEmpty(pChars, pOffset, pLength)) {
 79  0
                         throw new SAXParseException("Unexpected non-whitespace character data",
 80  0
                                                                                 getDocumentLocator());
 81  
                 }
 82  0
         }
 83  
 
 84  
         public void ignorableWhitespace(char[] pChars, int pOffset, int pLength) throws SAXException {
 85  0
         }
 86  
 }