package asandatabasebrowser;

import java.io.*;
import java.util.ArrayList;

/**
 * 固定長ファイルを何とかしようと思ったのだけれど、未完成です。
 * @deprecated	未完成
 * 
 * @author Asan
 */
public class FixLengthViewer {

	ArrayList split(String line) {
		ArrayList list = new ArrayList();
		int start = 0;
		int len = 255;
		int end = start + len;
		String tool_tip_text = line.substring(start, end);
		System.out.println("["+tool_tip_text+"]");
		start += len + 1;
		len = 80;
		end = start + len;
		String app_xml_data = line.substring(start, end);
		System.out.println("["+app_xml_data+"]");
		start += len + 1;
		len = 255;
		end = start + len;
		String data_container_name = line.substring(start, end);
		System.out.println("["+data_container_name+"]");
		start += len + 1;
		len = 16;
		end = start + len;
		String parent_node_id = line.substring(start, end);
		System.out.println("["+parent_node_id+"]");
		start += len + 1;
		len = 255;
		end = start + len;
		String labeling_style_id = line.substring(start, end);
		System.out.println("["+labeling_style_id+"]");
		
		return list;
	}
	ArrayList split(byte[] bytes) {
		ArrayList list = new ArrayList();
		int start = 0;
		int len = 255;
		int end = start + len;
		String tool_tip_text = new String(bytes, start, len);
		System.out.println("["+tool_tip_text+"]");
		start += len + 1;
		len = 80;
		end = start + len;
		String app_xml_data  = new String(bytes, start, len);
		System.out.println("["+app_xml_data+"]");
		start += len + 1;
		len = 255;
		end = start + len;
		String data_container_name  = new String(bytes, start, len);
		System.out.println("["+data_container_name+"]");
		start += len + 1;
		len = 14;
		end = start + len;
		String parent_node_id = new String(bytes, start, len);
		System.out.println("["+parent_node_id+"]");
		start += len + 1;
		len = 255;
		end = start + len;
		String labeling_style_id = new String(bytes, start, len);
		System.out.println("["+labeling_style_id+"]");
		start += len + 1;
		len = 255;
		end = start + len;
		String remarks = new String(bytes, start, len);
		System.out.println("["+remarks+"]");
		start += len + 1;
		len = 15;
		end = start + len;
		String renderling_order = new String(bytes, start, len);
		System.out.println("["+renderling_order+"]");
		start += len + 1;
		len = 17;
		end = start + len;
		String visible_scale_min = new String(bytes, start, len);
		System.out.println("["+visible_scale_min+"]");
		start += len + 1;
		len = 255;
		end = start + len;
		String c_property_type = new String(bytes, start, len);
		System.out.println("["+c_property_type+"]");
		start += len + 1;
		len = 255;
		end = start + len;
		String node_name = new String(bytes, start, len);
		System.out.println("["+node_name+"]");
		start += len + 1;
		len = 255;
		end = start + len;
		String icon_style_id = new String(bytes, start, len);
		System.out.println("["+icon_style_id+"]");
		start += len + 1;
		len = 255;
		end = start + len;
		String style_set_id = new String(bytes, start, len);
		System.out.println("["+style_set_id+"]");
		start += len + 1;
		len = 95;
		end = start + len;
		String visible_scale_max = new String(bytes, start, len);
		System.out.println("v["+visible_scale_max+"]");
		start += len + 1;
		len = 255;
		end = start + len;
		String c_property_table = new String(bytes, start, len);
		System.out.println("["+c_property_table+"]");
		start += len + 1;
		len = 255;
		end = start + len;
		String geometry_style_id = new String(bytes, start, len);
		System.out.println("["+geometry_style_id+"]");
		start += len + 1;
		len = 10;
		end = start + len;
		String node_id = new String(bytes, start, len);
		System.out.println("["+node_id+"]");
		start += len + 1;
		len = 12;
		end = start + len;
		String root_node_id = new String(bytes, start, len);
		System.out.println("["+root_node_id+"]");
		start += len + 1;
		len = 255;
		end = start + len;
		String node_title = new String(bytes, start, len);
		System.out.println("["+node_title+"]");
		start += len + 1;
		len = 80;
		end = start + len;
		String sys_xml_data = new String(bytes, start, len);
		System.out.println("["+sys_xml_data+"]"+end);
		
		return list;

	}
	
	void load(File file) throws IOException {
		BufferedReader reader = null;
		try {
			reader = new BufferedReader(new FileReader(file));
			int count = 0;
			reader.readLine();
			reader.readLine();
			while (reader.ready()) {
				reader.readLine();
				reader.readLine();
				reader.readLine();
				reader.readLine();
				String line1 = reader.readLine();
				String line2 = reader.readLine();
				byte[] bytes = (line1 + line2).getBytes("Shift_JIS");
				split(bytes);
				System.out.println("-----");
				reader.readLine();
				reader.readLine();
				reader.readLine();
				line1 = reader.readLine();
				line2 = reader.readLine();
				bytes = (line1 + line2).getBytes("Shift_JIS");
				split(bytes);
				System.out.println("-----");
				reader.readLine();
				reader.readLine();
				reader.readLine();
				if (count > 10) break;
				count++;
			}
		} 
		finally {
			if (reader != null) reader.close();
		}
	}
}
