// Path: segment/src/main/java/net/loomchild/segment/util/Util.java
// public static XMLReader getXmlReader(Schema schema) {
// 	try {
// 		SAXParserFactory parserFactory = SAXParserFactory.newInstance();
// 		parserFactory.setValidating(false);
// 		parserFactory.setNamespaceAware(true);
// 		if (schema != null) {
// 			parserFactory.setSchema(schema);
// 		}
// 		SAXParser saxParser = parserFactory.newSAXParser();
// 		XMLReader xmlReader = saxParser.getXMLReader();
// 		xmlReader.setEntityResolver(new IgnoreDTDEntityResolver());
// 		return xmlReader;
// 	} catch (ParserConfigurationException e) {
// 		throw new XmlException("SAX Parser configuration error.", e);
// 	} catch (SAXException e) {
// 		throw new XmlException("Error creating XMLReader.", e);
// 	}
// }


import static net.loomchild.segment.util.Util.getXmlReader;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.transform.Source;
import javax.xml.transform.sax.SAXSource;
import javax.xml.validation.Schema;
import org.xml.sax.InputSource;
	public void marshal(Writer writer, Object object) {
		try {
			marshaller.marshal(object, writer);
		} catch (JAXBException e) {
			throw new XmlException("JAXB marshalling error", e);
		}
	}

	/**
	 * Writes given object to a file with given name validating it.
	 * @param fileName
	 * @param object
	 */
	public void marshal(String fileName, Object object) {
		try {
			Writer writer = Util.getWriter(Util.getFileOutputStream(fileName));
			marshal(writer, object);
			writer.close();
		} catch (IOException e) {
			throw new IORuntimeException(e);
		}
	}

	/**
	 * Retrieves object from given reader validation the input.
	 * @param reader
	 * @return object
	 */
	public Object unmarshal(Reader reader) {
		try {
// Path: segment/src/main/java/net/loomchild/segment/util/Util.java
// public static XMLReader getXmlReader(Schema schema) {
// 	try {
// 		SAXParserFactory parserFactory = SAXParserFactory.newInstance();
// 		parserFactory.setValidating(false);
// 		parserFactory.setNamespaceAware(true);
// 		if (schema != null) {
// 			parserFactory.setSchema(schema);
// 		}
// 		SAXParser saxParser = parserFactory.newSAXParser();
// 		XMLReader xmlReader = saxParser.getXMLReader();
// 		xmlReader.setEntityResolver(new IgnoreDTDEntityResolver());
// 		return xmlReader;
// 	} catch (ParserConfigurationException e) {
// 		throw new XmlException("SAX Parser configuration error.", e);
// 	} catch (SAXException e) {
// 		throw new XmlException("Error creating XMLReader.", e);
// 	}
// }


// Path: segment/src/main/java/net/loomchild/segment/util/Bind.java
import static net.loomchild.segment.util.Util.getXmlReader;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.transform.Source;
import javax.xml.transform.sax.SAXSource;
import javax.xml.validation.Schema;
import org.xml.sax.InputSource;

	public void marshal(Writer writer, Object object) {
		try {
			marshaller.marshal(object, writer);
		} catch (JAXBException e) {
			throw new XmlException("JAXB marshalling error", e);
		}
	}

	/**
	 * Writes given object to a file with given name validating it.
	 * @param fileName
	 * @param object
	 */
	public void marshal(String fileName, Object object) {
		try {
			Writer writer = Util.getWriter(Util.getFileOutputStream(fileName));
			marshal(writer, object);
			writer.close();
		} catch (IOException e) {
			throw new IORuntimeException(e);
		}
	}

	/**
	 * Retrieves object from given reader validation the input.
	 * @param reader
	 * @return object
	 */
	public Object unmarshal(Reader reader) {
		try {
			Source source = new SAXSource(Util.getXmlReader(), new InputSource(