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

org.daisy.pipeline.html.impl.HtmlDocumentBuilder_SPI Maven / Gradle / Ivy

There is a newer version: 6.3.0
Show newest version
/***************************************************************/
/* This class was generated by ds-to-spi-annotations-processor */
/***************************************************************/

package org.daisy.pipeline.html.impl;

public class HtmlDocumentBuilder_SPI
       implements org.daisy.common.spi.ServiceWithProperties
                , org.daisy.common.xml.DocumentBuilder
{
	
	private static final org.slf4j.Logger spi_log = org.slf4j.LoggerFactory.getLogger(HtmlDocumentBuilder_SPI.class);
	
	private final java.util.Map spi_props;
	private boolean spi_deactivated = false;
	
	private final org.daisy.pipeline.html.impl.HtmlDocumentBuilder delegate;

	public HtmlDocumentBuilder_SPI() {
		delegate = new org.daisy.pipeline.html.impl.HtmlDocumentBuilder();
		spi_log.trace("Creating HtmlDocumentBuilder");
		spi_props = new java.util.HashMap();
		spi_props.put("component.name", "html-document-builder");
		{
			spi_log.trace("Binding org.daisy.common.xml.DocumentBuilder services...");
			// cardinality: 0..n
			int minRef = 0;
			int maxRef = -1;
			int refCount = 0;
			try {
				java.util.Iterator services
					= org.daisy.common.spi.ServiceLoader.load(org.daisy.common.xml.DocumentBuilder.class).iterator();
				while (services.hasNext()) {
					try {
						org.daisy.common.xml.DocumentBuilder service = services.next();
						delegate.setXmlParser(service);
						spi_log.trace("Bound org.daisy.common.xml.DocumentBuilder service: "
						              + service.getClass().getName() + "@"
						              + Integer.toHexString(System.identityHashCode(service)));
						refCount++;
						if (maxRef > 0 && refCount == maxRef)
							break;
					} catch (Throwable e) {
						spi_log.error("Error while binding org.daisy.common.xml.DocumentBuilder service", e);
					}
				}
			} catch (Throwable e) {
				spi_log.error("Error while binding org.daisy.common.xml.DocumentBuilder services", e);
			}
			if (refCount < minRef) {
				spi_log.warn("No org.daisy.common.xml.DocumentBuilder found");
				throw new RuntimeException("No org.daisy.common.xml.DocumentBuilder found");
			} else {
				spi_log.trace("Bound " + refCount + " org.daisy.common.xml.DocumentBuilder services.");
			}
		}
		{
			spi_log.trace("Binding javax.xml.transform.URIResolver services...");
			// cardinality: 1..1
			int minRef = 1;
			int maxRef = 1;
			int refCount = 0;
			try {
				java.util.Iterator services
					= org.daisy.common.spi.ServiceLoader.load(javax.xml.transform.URIResolver.class).iterator();
				while (services.hasNext()) {
					try {
						javax.xml.transform.URIResolver service = services.next();
						delegate.setURIResolver(service);
						spi_log.trace("Bound javax.xml.transform.URIResolver service: "
						              + service.getClass().getName() + "@"
						              + Integer.toHexString(System.identityHashCode(service)));
						refCount++;
						if (maxRef > 0 && refCount == maxRef)
							break;
					} catch (Throwable e) {
						spi_log.error("Error while binding javax.xml.transform.URIResolver service", e);
					}
				}
			} catch (Throwable e) {
				spi_log.error("Error while binding javax.xml.transform.URIResolver services", e);
			}
			if (refCount < minRef) {
				spi_log.warn("No javax.xml.transform.URIResolver found");
				throw new RuntimeException("No javax.xml.transform.URIResolver found");
			} else {
				spi_log.trace("Bound " + refCount + " javax.xml.transform.URIResolver services.");
			}
		}
		{
			spi_log.trace("Binding org.xml.sax.EntityResolver services...");
			// cardinality: 1..1
			int minRef = 1;
			int maxRef = 1;
			int refCount = 0;
			try {
				java.util.Iterator services
					= org.daisy.common.spi.ServiceLoader.load(org.xml.sax.EntityResolver.class).iterator();
				while (services.hasNext()) {
					try {
						org.xml.sax.EntityResolver service = services.next();
						delegate.setEntityResolver(service);
						spi_log.trace("Bound org.xml.sax.EntityResolver service: "
						              + service.getClass().getName() + "@"
						              + Integer.toHexString(System.identityHashCode(service)));
						refCount++;
						if (maxRef > 0 && refCount == maxRef)
							break;
					} catch (Throwable e) {
						spi_log.error("Error while binding org.xml.sax.EntityResolver service", e);
					}
				}
			} catch (Throwable e) {
				spi_log.error("Error while binding org.xml.sax.EntityResolver services", e);
			}
			if (refCount < minRef) {
				spi_log.warn("No org.xml.sax.EntityResolver found");
				throw new RuntimeException("No org.xml.sax.EntityResolver found");
			} else {
				spi_log.trace("Bound " + refCount + " org.xml.sax.EntityResolver services.");
			}
		}
		{
			spi_log.trace("Binding net.sf.saxon.s9api.Processor services...");
			// cardinality: 1..1
			int minRef = 1;
			int maxRef = 1;
			int refCount = 0;
			try {
				java.util.Iterator services
					= org.daisy.common.spi.ServiceLoader.load(net.sf.saxon.s9api.Processor.class).iterator();
				while (services.hasNext()) {
					try {
						net.sf.saxon.s9api.Processor service = services.next();
						delegate.setSaxonProcessor(service);
						spi_log.trace("Bound net.sf.saxon.s9api.Processor service: "
						              + service.getClass().getName() + "@"
						              + Integer.toHexString(System.identityHashCode(service)));
						refCount++;
						if (maxRef > 0 && refCount == maxRef)
							break;
					} catch (Throwable e) {
						spi_log.error("Error while binding net.sf.saxon.s9api.Processor service", e);
					}
				}
			} catch (Throwable e) {
				spi_log.error("Error while binding net.sf.saxon.s9api.Processor services", e);
			}
			if (refCount < minRef) {
				spi_log.warn("No net.sf.saxon.s9api.Processor found");
				throw new RuntimeException("No net.sf.saxon.s9api.Processor found");
			} else {
				spi_log.trace("Bound " + refCount + " net.sf.saxon.s9api.Processor services.");
			}
		}
	}
	
	public void spi_deactivate() {
	}
	
	public java.util.Map spi_getProperties() {
		return spi_props;
	}

	@Override
	public boolean supportsContentType(
		java.lang.String arg1
	) {
		return delegate.supportsContentType(
			arg1
		);
	}

	@Override
	public org.w3c.dom.Document parse(
		org.xml.sax.InputSource arg1
	) throws org.xml.sax.SAXException
	       , java.io.IOException {
		return delegate.parse(
			arg1
		);
	}

	@Override
	public String toString() {
		return delegate.toString();
	}

	@Override
	public int hashCode() {
		return delegate.hashCode();
	}

	@Override
	public boolean equals(Object o) {
		return delegate.equals(o);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy