All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jadex.xml.stax.JadexXMLReporterWrapper Maven / Gradle / Ivy

Go to download

Jadex XML is an XML data binding framework for Java and also for other representations. The main idea of Jadex XML is that neither the XML-Schema on the one side nor the Java classes on the other side should define other binding. Instead, a separate mapping between both is used as a mediation. This allows designing the XML representation independent of the Java side but still being able to connect both as desired. This idea was first put forward by the JiBX data binding framework. Jadex XML pushes it further by combining it with the configuration by exception principle. The framework can detect obvious correspondences between both sides automatically and only needs configuration information when translations are necessary. The configuration information is currently specified directly in form of Java configuration classes.

There is a newer version: 4.0.267
Show newest version
package jadex.xml.stax;

import javax.xml.stream.Location;
import javax.xml.stream.XMLStreamException;

/**
 * Wraps a jadex.xml.stax.XMLReporter Object to provide the
 * javax.xml.stream.XMLReporter API.
 */
public class JadexXMLReporterWrapper implements javax.xml.stream.XMLReporter
{
	// -------- attributes --------

	private jadex.xml.stax.XMLReporter reporter;

	// -------- constructors --------

	/**
	 * Constructor
	 * 
	 * @param reporter
	 *            The reporter to be wrapped.
	 */
	public JadexXMLReporterWrapper(jadex.xml.stax.XMLReporter reporter)
	{
		this.reporter = reporter;
	}

	// -------- methods --------
	/**
	 * Report the desired message in an application specific format. Only
	 * warnings and non-fatal errors should be reported through this interface.
	 * Fatal errors should be thrown as XMLStreamException.
	 * 
	 * @param message
	 *            the error message
	 * @param errorType
	 *            an implementation defined error type
	 * @param relatedInformation
	 *            information related to the error, if available
	 * @param location
	 *            the location of the error, if available
	 * @throws XMLStreamException
	 */
	public void report(String message, String errorType, Object relatedInformation, Location location) throws XMLStreamException
	{
		try
		{
			reporter.report(message, errorType, relatedInformation, StaxLocationWrapper.fromLocation(location));
		} 
		catch(Exception e)
		{
			throw new XMLStreamException(e);
		}
	}

	/**
	 * Wraps a reporter object.
	 * 
	 * @param reporter
	 * @return wrapped XMLReporter
	 */
	public static javax.xml.stream.XMLReporter fromXMLReporter(jadex.xml.stax.XMLReporter reporter)
	{
		return reporter==null? null: new JadexXMLReporterWrapper(reporter);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy