package com.csc.library.report;

import java.util.Vector;

import com.csc.library.utilities.MyLog;
import com.csc.library.utilities.ReportXml;
import com.csc.library.utilities.UProfile;

public class GenMetaJasper {
        private ReportXml reportxml;
        private String dbName, outputPath;
        private ReportMetaData rm;
        private Vector colName,colType,colPrecision,colTypeName;
        private UProfile upf=null;

        public void setUProfile(UProfile upf){
        	upf=this.upf;
        }
        public GenMetaJasper(String reportxml, String dbName,UProfile upf) {
        	this.upf=upf;
            try {
                    this.reportxml = new ReportXml(reportxml,dbName,this.upf);
                    this.dbName = dbName;
                    rm = new ReportMetaData();
                    rm.setDbName(dbName);
                    rm.setUProfile(this.upf);
                    rm.setReportXml(this.reportxml);
                    rm.process();
                    colName = rm.getColumnName();
                    colPrecision = rm.getColumnPrecision();
                    colType=rm.getColumnType();
                    this.initType();
            } catch (Exception e) {
    			MyLog.error(this, this.upf, e);
    		}
        }

        private  void initType(){
                this.colTypeName=new Vector();
                for(int i=0;i<this.colType.size();i++){
                        colTypeName.add(rm.getFieldPropertiesFull((String)colType.elementAt(i)));
                }
        }

        public Vector getFieldList(){
                return this.colName;
        }
        public Vector getFieldType(){
                return this.colTypeName;
        }

        public static void main(String args[]){
                //GenMetaJasper gen=new GenMetaJasper("CS08-CS008","PRDBS10D");
                                      try {
                                                         System.out.println(Class.forName("java.lang.String").getName());
                                                } catch (ClassNotFoundException e) {e.printStackTrace();}
                String a="aaaa__bbbb";
                System.out.println(a.substring(0,a.indexOf("__")));
                System.out.println(a.substring(a.indexOf("__")+2,a.length()));
        }
}