org.ow2.util.plan.reader.ReaderValidationEventHandler Maven / Gradle / Ivy
The newest version!
/**
* OW2 Util
* Copyright (C) 2008 SERLI
* Contact: [email protected]
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* --------------------------------------------------------------------------
* $Id: ReaderValidationEventHandler.java 4389 2008-12-15 13:48:57Z alitokmen $
* --------------------------------------------------------------------------
*/
package org.ow2.util.plan.reader;
import javax.xml.bind.ValidationEvent;
import javax.xml.bind.ValidationEventHandler;
import org.ow2.util.log.Log;
import org.ow2.util.log.LogFactory;
/**
* ValidationEventHandler used by Reader classes.
* @author mleduque
*/
public class ReaderValidationEventHandler implements ValidationEventHandler {
/**
* The logger.
*/
private static Log logger = LogFactory.getLog(ReaderValidationEventHandler.class);
/**
* Tolerance level for parsing errors.
*/
private int laxLevel;
/**
* Constructs a ReaderValidationEventHandler object.
* @param laxLevel Tolerance level for parsing errors.
*/
public ReaderValidationEventHandler(int laxLevel) {
if (laxLevel < 0 || laxLevel > 3) {
throw new IllegalArgumentException("bad value for laxlevel");
}
this.laxLevel = laxLevel;
}
/**
* {@inheritDoc}
* @param event
* @return
*/
public boolean handleEvent(ValidationEvent event) {
if (this.laxLevel < event.getSeverity()) {
logger.error(
"xml file could not be read, message: {0}",
event.getMessage());
return false;
} else {
logger.debug(
"read error, attempting to continue; message: {0}",
event.getMessage());
return true;
}
}
} © 2015 - 2025 Weber Informatics LLC | Privacy Policy