001    package railo.runtime.text.xml;
002    
003    import org.xml.sax.ErrorHandler;
004    import org.xml.sax.SAXException;
005    import org.xml.sax.SAXParseException;
006    
007    
008    public class ThrowingErrorHandler implements ErrorHandler {
009    
010            private boolean throwFatalError;
011            private boolean throwError;
012            private boolean throwWarning;
013    
014            public ThrowingErrorHandler(boolean throwFatalError,boolean throwError,boolean throwWarning) {
015                    this.throwFatalError=throwFatalError;
016                    this.throwError=throwError;
017                    this.throwWarning=throwWarning;
018            }
019            
020            /**
021             * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
022             */
023            public void error(SAXParseException e) throws SAXException {
024                    if(throwError)throw new SAXException(e);
025            }
026    
027            /**
028             * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
029             */
030            public void fatalError(SAXParseException e) throws SAXException {
031                    if(throwFatalError)throw new SAXException(e);
032            }
033    
034            /**
035             * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
036             */
037            public void warning(SAXParseException e) throws SAXException {
038                    if(throwWarning)throw new SAXException(e);
039            }
040    
041    }