00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one 00003 * or more contributor license agreements. See the NOTICE file 00004 * distributed with this work for additional information 00005 * regarding copyright ownership. The ASF licenses this file 00006 * to you under the Apache License, Version 2.0 (the 00007 * "License"); you may not use this file except in compliance 00008 * with the License. You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, 00013 * software distributed under the License is distributed on an 00014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 00015 * KIND, either express or implied. See the License for the 00016 * specific language governing permissions and limitations 00017 * under the License. 00018 */ 00019 package org.apache.xmlrpc.parser; 00020 00021 import org.xml.sax.SAXException; 00022 import org.xml.sax.SAXParseException; 00023 00024 00027 public class BooleanParser extends AtomicParser { 00028 protected void setResult(String pResult) throws SAXException { 00029 String s = pResult.trim(); 00030 if ("1".equals(s)) { 00031 super.setResult(Boolean.TRUE); 00032 } else if ("0".equals(s)) { 00033 super.setResult(Boolean.FALSE); 00034 } else { 00035 throw new SAXParseException("Failed to parse boolean value: " + pResult, 00036 getDocumentLocator()); 00037 } 00038 } 00039 }