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.commons.io.input.compatibility; 18 19 import java.io.InputStream; 20 21 /** 22 * The XmlStreamReaderException is thrown by the XmlStreamReader constructors if 23 * the charset encoding can not be determined according to the XML 1.0 24 * specification and RFC 3023. 25 * <p> 26 * The exception returns the unconsumed InputStream to allow the application to 27 * do an alternate processing with the stream. Note that the original 28 * InputStream given to the XmlStreamReader cannot be used as that one has been 29 * already read. 30 * </p> 31 */ 32 public class XmlStreamReaderException extends org.apache.commons.io.input.XmlStreamReaderException { 33 34 private static final long serialVersionUID = 1L; 35 36 private final InputStream inputStream; 37 38 /** 39 * Creates an exception instance if the charset encoding could not be 40 * determined. 41 * <p> 42 * Instances of this exception are thrown by the XmlStreamReader. 43 * 44 * @param msg message describing the reason for the exception. 45 * @param bomEnc BOM encoding. 46 * @param xmlGuessEnc XML guess encoding. 47 * @param xmlEnc XML prolog encoding. 48 * @param is the unconsumed InputStream. 49 */ 50 public XmlStreamReaderException(final String msg, final String bomEnc, 51 final String xmlGuessEnc, final String xmlEnc, final InputStream is) { 52 this(msg, null, null, bomEnc, xmlGuessEnc, xmlEnc, is); 53 } 54 55 /** 56 * Creates an exception instance if the charset encoding could not be 57 * determined. 58 * <p> 59 * Instances of this exception are thrown by the XmlStreamReader. 60 * 61 * @param msg message describing the reason for the exception. 62 * @param ctMime MIME type in the content-type. 63 * @param ctEnc encoding in the content-type. 64 * @param bomEnc BOM encoding. 65 * @param xmlGuessEnc XML guess encoding. 66 * @param xmlEnc XML prolog encoding. 67 * @param inputStream the unconsumed InputStream. 68 */ 69 public XmlStreamReaderException(final String msg, final String ctMime, final String ctEnc, 70 final String bomEnc, final String xmlGuessEnc, final String xmlEnc, final InputStream inputStream) { 71 super(msg, ctMime, ctEnc, bomEnc, xmlGuessEnc, xmlEnc); 72 this.inputStream = inputStream; 73 } 74 75 /** 76 * Returns the unconsumed InputStream to allow the application to do an 77 * alternate encoding detection on the InputStream. 78 * 79 * @return the unconsumed InputStream. 80 */ 81 public InputStream getInputStream() { 82 return inputStream; 83 } 84 }