// Path: segment/src/main/java/net/loomchild/segment/util/IORuntimeException.java
// public class IORuntimeException extends RuntimeException {
// 
// 	private static final long serialVersionUID = -6587044052300876023L;
// 
// 	public IORuntimeException(IOException exception) {
// 		super(exception);
// 	}
// 
// 	public void rethrow() throws IOException {
// 		throw (IOException) getCause();
// 	}
// 
// }
// 
// Path: segment/src/main/java/net/loomchild/segment/util/XmlException.java
// public class XmlException extends RuntimeException {
// 
// 	private static final long serialVersionUID = -143693366659133245L;
// 
// 	public XmlException(String message) {
// 		super(message);
// 	}
// 
// 	public XmlException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// 
// 	public XmlException(Throwable cause) {
// 		super(cause);
// 	}
// 
// }


import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.loomchild.segment.util.IORuntimeException;
import net.loomchild.segment.util.XmlException;
package net.loomchild.segment.srx.io;



/**
 * Represents SRX version.
 * Responsible for retrieving SRX version from a reader without modifying it.
 * @author loomchild
 */
public enum SrxVersion {

	VERSION_1_0("1.0"), VERSION_2_0("2.0");

	private final static int HEADER_BUFFER_LENGHT = 1024;

	private final static Pattern VERSION_PATTERN = Pattern
			.compile("<srx[^>]+version=\"([^\"]+)\"");

	private String versionString;

	private SrxVersion(String versionString) {
		this.versionString = versionString;
	}

	public String toString() {
		return versionString;
	}

	public static SrxVersion parse(String versionString) {
		for (SrxVersion version : SrxVersion.values()) {
			if (version.versionString.equals(versionString)) {
				return version;
			}
		}
// Path: segment/src/main/java/net/loomchild/segment/util/IORuntimeException.java
// public class IORuntimeException extends RuntimeException {
// 
// 	private static final long serialVersionUID = -6587044052300876023L;
// 
// 	public IORuntimeException(IOException exception) {
// 		super(exception);
// 	}
// 
// 	public void rethrow() throws IOException {
// 		throw (IOException) getCause();
// 	}
// 
// }
// 
// Path: segment/src/main/java/net/loomchild/segment/util/XmlException.java
// public class XmlException extends RuntimeException {
// 
// 	private static final long serialVersionUID = -143693366659133245L;
// 
// 	public XmlException(String message) {
// 		super(message);
// 	}
// 
// 	public XmlException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// 
// 	public XmlException(Throwable cause) {
// 		super(cause);
// 	}
// 
// }


// Path: segment/src/main/java/net/loomchild/segment/srx/io/SrxVersion.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.loomchild.segment.util.IORuntimeException;
import net.loomchild.segment.util.XmlException;

package net.loomchild.segment.srx.io;



/**
 * Represents SRX version.
 * Responsible for retrieving SRX version from a reader without modifying it.
 * @author loomchild
 */
public enum SrxVersion {

	VERSION_1_0("1.0"), VERSION_2_0("2.0");

	private final static int HEADER_BUFFER_LENGHT = 1024;

	private final static Pattern VERSION_PATTERN = Pattern
			.compile("<srx[^>]+version=\"([^\"]+)\"");

	private String versionString;

	private SrxVersion(String versionString) {
		this.versionString = versionString;
	}

	public String toString() {
		return versionString;
	}

	public static SrxVersion parse(String versionString) {
		for (SrxVersion version : SrxVersion.values()) {
			if (version.versionString.equals(versionString)) {
				return version;
			}
		}
		throw new XmlException("Unrecognized SRX version: "