// Path: src/main/java/com/savy3/hadoop/hive/serde3/cobol/CobolSerdeException.java
// public class CobolSerdeException extends SerDeException {
// 	/**
// 	 * 
// 	 */
// 	private static final long serialVersionUID = 1L;
// 
// 	public CobolSerdeException() {
// 		super();
// 	}
// 
// 	public CobolSerdeException(String message) {
// 		super(message);
// 	}
// 
// 	public CobolSerdeException(Throwable cause) {
// 		super(cause);
// 	}
// 
// 	public CobolSerdeException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// }


import com.savy3.hadoop.hive.serde3.cobol.CobolSerdeException;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils;
import java.util.*;
package com.savy3.hadoop.hive.serde2.cobol;



public class CobolCopybook {

	List<String> fieldLines;
	List<String> fieldNames;
	List<String> fieldTypes;
	List<Map<String, Integer>> fieldProperties;
	Map<String, Integer> uniqueNames;
	Map<String, Integer> namePrevCol;
	int columnNos, prevColumn;

	public List<Map<String, Integer>> getFieldProperties() {
		return fieldProperties;
	}

	List<TypeInfo> fieldTypeInfos;

	public List<TypeInfo> getFieldTypeInfos() {
		return fieldTypeInfos;
	}

	List<ObjectInspector> fieldOIs;

	public CobolCopybook(String layout) {
		/*
		 * Split the cobol layout seperate lines using ". " as delimiter, space
		 * is also included because dot can also occur in between Picture
		 * clause.
		 */
		layout = layout.replaceAll("[\\t\\n\\r]", " ").replaceAll("( )+", " ").trim();
		this.fieldLines = Arrays.asList(layout.split("\\.\\s"));
		this.fieldNames = new LinkedList<String>();
		this.fieldTypes = new LinkedList<String>();
		this.fieldTypeInfos = new LinkedList<TypeInfo>();
		this.fieldOIs = new LinkedList<ObjectInspector>();
		this.uniqueNames = new HashMap<String, Integer>();
		this.namePrevCol = new HashMap<String, Integer>();
		this.fieldProperties = new ArrayList<Map<String, Integer>>();
		new LinkedList<CobolFieldDecl>();

		try {
			buildLayout();
// Path: src/main/java/com/savy3/hadoop/hive/serde3/cobol/CobolSerdeException.java
// public class CobolSerdeException extends SerDeException {
// 	/**
// 	 * 
// 	 */
// 	private static final long serialVersionUID = 1L;
// 
// 	public CobolSerdeException() {
// 		super();
// 	}
// 
// 	public CobolSerdeException(String message) {
// 		super(message);
// 	}
// 
// 	public CobolSerdeException(Throwable cause) {
// 		super(cause);
// 	}
// 
// 	public CobolSerdeException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// }


// Path: src/main/java/com/savy3/hadoop/hive/serde2/cobol/CobolCopybook.java
import com.savy3.hadoop.hive.serde3.cobol.CobolSerdeException;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils;
import java.util.*;

package com.savy3.hadoop.hive.serde2.cobol;



public class CobolCopybook {

	List<String> fieldLines;
	List<String> fieldNames;
	List<String> fieldTypes;
	List<Map<String, Integer>> fieldProperties;
	Map<String, Integer> uniqueNames;
	Map<String, Integer> namePrevCol;
	int columnNos, prevColumn;

	public List<Map<String, Integer>> getFieldProperties() {
		return fieldProperties;
	}

	List<TypeInfo> fieldTypeInfos;

	public List<TypeInfo> getFieldTypeInfos() {
		return fieldTypeInfos;
	}

	List<ObjectInspector> fieldOIs;

	public CobolCopybook(String layout) {
		/*
		 * Split the cobol layout seperate lines using ". " as delimiter, space
		 * is also included because dot can also occur in between Picture
		 * clause.
		 */
		layout = layout.replaceAll("[\\t\\n\\r]", " ").replaceAll("( )+", " ").trim();
		this.fieldLines = Arrays.asList(layout.split("\\.\\s"));
		this.fieldNames = new LinkedList<String>();
		this.fieldTypes = new LinkedList<String>();
		this.fieldTypeInfos = new LinkedList<TypeInfo>();
		this.fieldOIs = new LinkedList<ObjectInspector>();
		this.uniqueNames = new HashMap<String, Integer>();
		this.namePrevCol = new HashMap<String, Integer>();
		this.fieldProperties = new ArrayList<Map<String, Integer>>();
		new LinkedList<CobolFieldDecl>();

		try {
			buildLayout();
		} catch (CobolSerdeException e) {