// Path: segment/src/main/java/net/loomchild/segment/srx/SrxDocument.java
// public class SrxDocument {
// 
// 	/**
// 	 * Default cascade value.
// 	 */
// 	public static final boolean DEFAULT_CASCADE = true;
// 
// 	private boolean cascade;
// 
// 	private List<LanguageMap> languageMapList;
// 	
// 	private SrxDocumentCache cache;
// 
// 	/**
// 	 * Creates empty document.
// 	 * 
// 	 * @param cascade true if document is cascading
// 	 */
// 	public SrxDocument(boolean cascade) {
// 		this.cascade = cascade;
// 		this.languageMapList = new ArrayList<LanguageMap>();
// 		this.cache = new SrxDocumentCache();
// 	}
// 
// 	/**
// 	 * Creates empty document with default cascade. See {@link #DEFAULT_CASCADE}.
// 	 */
// 	public SrxDocument() {
// 		this(DEFAULT_CASCADE);
// 	}
// 
// 	/**
// 	 * Sets if document is cascading or not.
// 	 * 
// 	 * @param cascade true f document is cascading
// 	 */
// 	public void setCascade(boolean cascade) {
// 		this.cascade = cascade;
// 	}
// 
// 	/**
// 	 * @return true if document is cascading
// 	 */
// 	public boolean getCascade() {
// 		return cascade;
// 	}
// 
// 	/**
// 	 * Add language map to this document.
// 	 * 
// 	 * @param pattern language code pattern
// 	 * @param languageRule
// 	 */
// 	public void addLanguageMap(String pattern, LanguageRule languageRule) {
// 		LanguageMap languageMap = new LanguageMap(pattern, languageRule);
// 		languageMapList.add(languageMap);
// 	}
// 
// 	public List<LanguageMap> getLanguageMapList() {
// 		return languageMapList;
// 	}	
// 
// 	/**
// 	 * If cascade is true then returns all language rules matching given
// 	 * language code. If cascade is false returns first language rule matching
// 	 * given language code. If no matching language rules are found returns
// 	 * empty list.
// 	 * 
// 	 * @param languageCode language code, for example en_US
// 	 * @return matching language rules
// 	 */
// 	public List<LanguageRule> getLanguageRuleList(String languageCode) {
// 		List<LanguageRule> matchingLanguageRuleList = new ArrayList<LanguageRule>();
// 		for (LanguageMap languageMap : languageMapList) {
// 			if (languageMap.matches(languageCode)) {
// 				matchingLanguageRuleList.add(languageMap.getLanguageRule());
// 				if (!cascade) {
// 					break;
// 				}
// 			}
// 		}
// 		return matchingLanguageRuleList;
// 	}
// 
// 	public SrxDocumentCache getCache() {
// 		return cache;
// 	}
// 	
// }
// 
// Path: segment/src/main/java/net/loomchild/segment/srx/SrxParser.java
// public interface SrxParser {
// 
// 	/**
// 	 * Parses SRX document.
// 	 * 
// 	 * @param reader reader from which read the document
// 	 * @return initialized SRX document
// 	 */
// 	public SrxDocument parse(Reader reader);
// 
// }
// 
// Path: segment/src/main/java/net/loomchild/segment/srx/SrxTransformer.java
// public interface SrxTransformer {
// 
// 	/**
// 	 * Transform given SRX document to newest supported version and write it to
// 	 * given writer.
// 	 * 
// 	 * @param reader reader containing SRX document
// 	 * @param writer writer to write transformed SRX document
// 	 * @param parameterMap map containing transformation parameters
// 	 */
// 	public void transform(Reader reader, Writer writer,
// 			Map<String, Object> parameterMap);
// 
// 	/**
// 	 * Transform given SRX document and return Reader containing newest
// 	 * supported version.
// 	 * 
// 	 * @param reader reader containing SRX document
// 	 * @param parameterMap map containing transformation parameters
// 	 * @return reader containing SRX document in newest supported version
// 	 */
// 	public Reader transform(Reader reader, Map<String, Object> parameterMap);
// 
// }


import java.io.Reader;
import java.util.Collections;
import java.util.Map;
import net.loomchild.segment.srx.SrxDocument;
import net.loomchild.segment.srx.SrxParser;
import net.loomchild.segment.srx.SrxTransformer;
package net.loomchild.segment.srx.io;




/**
 * Represents SRX 1.0 parser. Transforms document to SRX 2.0 using
 * {@link Srx1Transformer} and then parses it using {@link Srx2Parser}.
 * 
 * @author loomchild
 */
public class Srx1Parser implements SrxParser {

	/**
	 * Transforms document to SRX 2.0 using {@link Srx1Transformer} and default
	 * transformation parameters and parses it using {@link Srx2Parser}.
	 * 
	 * @param reader reader from which read the document
	 * @return initialized SRX document
	 */
	public SrxDocument parse(Reader reader) {
// Path: segment/src/main/java/net/loomchild/segment/srx/SrxDocument.java
// public class SrxDocument {
// 
// 	/**
// 	 * Default cascade value.
// 	 */
// 	public static final boolean DEFAULT_CASCADE = true;
// 
// 	private boolean cascade;
// 
// 	private List<LanguageMap> languageMapList;
// 	
// 	private SrxDocumentCache cache;
// 
// 	/**
// 	 * Creates empty document.
// 	 * 
// 	 * @param cascade true if document is cascading
// 	 */
// 	public SrxDocument(boolean cascade) {
// 		this.cascade = cascade;
// 		this.languageMapList = new ArrayList<LanguageMap>();
// 		this.cache = new SrxDocumentCache();
// 	}
// 
// 	/**
// 	 * Creates empty document with default cascade. See {@link #DEFAULT_CASCADE}.
// 	 */
// 	public SrxDocument() {
// 		this(DEFAULT_CASCADE);
// 	}
// 
// 	/**
// 	 * Sets if document is cascading or not.
// 	 * 
// 	 * @param cascade true f document is cascading
// 	 */
// 	public void setCascade(boolean cascade) {
// 		this.cascade = cascade;
// 	}
// 
// 	/**
// 	 * @return true if document is cascading
// 	 */
// 	public boolean getCascade() {
// 		return cascade;
// 	}
// 
// 	/**
// 	 * Add language map to this document.
// 	 * 
// 	 * @param pattern language code pattern
// 	 * @param languageRule
// 	 */
// 	public void addLanguageMap(String pattern, LanguageRule languageRule) {
// 		LanguageMap languageMap = new LanguageMap(pattern, languageRule);
// 		languageMapList.add(languageMap);
// 	}
// 
// 	public List<LanguageMap> getLanguageMapList() {
// 		return languageMapList;
// 	}	
// 
// 	/**
// 	 * If cascade is true then returns all language rules matching given
// 	 * language code. If cascade is false returns first language rule matching
// 	 * given language code. If no matching language rules are found returns
// 	 * empty list.
// 	 * 
// 	 * @param languageCode language code, for example en_US
// 	 * @return matching language rules
// 	 */
// 	public List<LanguageRule> getLanguageRuleList(String languageCode) {
// 		List<LanguageRule> matchingLanguageRuleList = new ArrayList<LanguageRule>();
// 		for (LanguageMap languageMap : languageMapList) {
// 			if (languageMap.matches(languageCode)) {
// 				matchingLanguageRuleList.add(languageMap.getLanguageRule());
// 				if (!cascade) {
// 					break;
// 				}
// 			}
// 		}
// 		return matchingLanguageRuleList;
// 	}
// 
// 	public SrxDocumentCache getCache() {
// 		return cache;
// 	}
// 	
// }
// 
// Path: segment/src/main/java/net/loomchild/segment/srx/SrxParser.java
// public interface SrxParser {
// 
// 	/**
// 	 * Parses SRX document.
// 	 * 
// 	 * @param reader reader from which read the document
// 	 * @return initialized SRX document
// 	 */
// 	public SrxDocument parse(Reader reader);
// 
// }
// 
// Path: segment/src/main/java/net/loomchild/segment/srx/SrxTransformer.java
// public interface SrxTransformer {
// 
// 	/**
// 	 * Transform given SRX document to newest supported version and write it to
// 	 * given writer.
// 	 * 
// 	 * @param reader reader containing SRX document
// 	 * @param writer writer to write transformed SRX document
// 	 * @param parameterMap map containing transformation parameters
// 	 */
// 	public void transform(Reader reader, Writer writer,
// 			Map<String, Object> parameterMap);
// 
// 	/**
// 	 * Transform given SRX document and return Reader containing newest
// 	 * supported version.
// 	 * 
// 	 * @param reader reader containing SRX document
// 	 * @param parameterMap map containing transformation parameters
// 	 * @return reader containing SRX document in newest supported version
// 	 */
// 	public Reader transform(Reader reader, Map<String, Object> parameterMap);
// 
// }


// Path: segment/src/main/java/net/loomchild/segment/srx/io/Srx1Parser.java
import java.io.Reader;
import java.util.Collections;
import java.util.Map;
import net.loomchild.segment.srx.SrxDocument;
import net.loomchild.segment.srx.SrxParser;
import net.loomchild.segment.srx.SrxTransformer;

package net.loomchild.segment.srx.io;




/**
 * Represents SRX 1.0 parser. Transforms document to SRX 2.0 using
 * {@link Srx1Transformer} and then parses it using {@link Srx2Parser}.
 * 
 * @author loomchild
 */
public class Srx1Parser implements SrxParser {

	/**
	 * Transforms document to SRX 2.0 using {@link Srx1Transformer} and default
	 * transformation parameters and parses it using {@link Srx2Parser}.
	 * 
	 * @param reader reader from which read the document
	 * @return initialized SRX document
	 */
	public SrxDocument parse(Reader reader) {
		SrxTransformer transformer = new Srx1Transformer();