OSDN Git Service

20170128
[rapideact/rapideact.git] / com / rapide_act / DataAccessObjects.java
index 5897f38..5ad5d61 100644 (file)
@@ -61,57 +61,10 @@ public class DataAccessObjects{
        private byte [] colBytes = null;
        private Blob colBlob = null;
        private Clob colClob = null;
-       private int recCount = 0;
-       private InputStream is = null;
-       private ByteArrayOutputStream baos = null;
-       private boolean isQuotation = true;
-       private boolean isMask = false;
-       private boolean isInclMaskCols = false;
-       private boolean isExclMaskCols = false;
-       private String inclMaskCols = null;
-       private String exclMaskCols = null;
        private String tbName = null;
-       private String nullMark = "";
-       private String lnSprtr = System.getProperty("line.separator");
-       private String delimiter = "\t";
-       private char singleByteChr = '*';
-       private char doubleByteChr = '\81\96';
-       private String maskPtn = "ALT";
-       private static final int MASK_PTN_ALL = 0;
-       private static final int MASK_PTN_ALT = 1;
-       private static final int MASK_PTN_EDGE = 2;
-       private static final String [] MASK_PTN = {"ALL", "ALT", "EDGE"};
-       private static final int USER = 0;
-       private static final int PASS = 1;
-       private static final int URL = 2;
-       private static final int DRIVER = 3;
-       private static final int OUTPUT = 4;
-       private static final int INPUT = 5;
-       private static final int LINESEP = 6;
-       private static final int INLINESEP = 7;
-       private static final int FILENCODE = 8;
-       private static final int NULLMARK = 9;
-       private static final int DELIMITER = 10;
-       private static final int TBLSQL = 11;
-       private static final int TBLKEYSQL = 12;
-       private static final int ORDER = 13;
-       private static final int QUOTATION = 14;
-       private static final int BATCOUNT = 15;
-       private static final int INCLTAB = 16;
-       private static final int EXCLTAB = 17;
-       private static final int INCLCOL = 18;
-       private static final int EXCLCOL = 19;
-       private static final int INCLCOLMASK = 20;
-       private static final int EXCLCOLMASK = 21;
-       private static final int SBYTEMASKCHR = 22;
-       private static final int DBYTEMASKCHR = 23;
-       private static final int MASKPTN = 24;
-       private static final int PROPFILE = 25;
-       private static final String [] PROP_KEY = { "us","pw","url","dr","out","in","ls","ils","fe","nm",
-                                                                                               "dm","ts","tks","od","qt","bc","it","et","ic","ec",
-                                                                                               "icm","ecm","smc","dmc","mp","pf"};
-       private static final int KEYS = 26;
-       private String [] prop_val = null;      
+       private int recCount = 0;
+       private CmnProperty cp = null;
+
        DataAccessObjects(String _user, String _pass, String _url, String _driver){
                user = _user;
                pass = _pass;
@@ -119,6 +72,14 @@ public class DataAccessObjects{
                driver = _driver;
        }
 
+       DataAccessObjects(CmnProperty _cp){
+               cp = _cp;
+               user = cp.user;
+               pass = cp.pass;
+               url = cp.url;
+               driver = cp.driver;
+       }
+
        public Connection connect() throws Exception{
 
                try {
@@ -298,20 +259,6 @@ public class DataAccessObjects{
                tbName = _tbName;
        }
 
-       public void setPropVal(String[] _prop_val) throws Exception{
-               prop_val = _prop_val;
-               if(!CmnUtils.isEmpty(prop_val[LINESEP]))lnSprtr = CmnUtils.getLineSeparator(prop_val[LINESEP]);
-               if(!CmnUtils.isEmpty(prop_val[NULLMARK]))nullMark = prop_val[NULLMARK];
-               if(!CmnUtils.isEmpty(prop_val[QUOTATION]) && prop_val[QUOTATION].toUpperCase().equals("N"))isQuotation = false;
-               if(!CmnUtils.isEmpty(prop_val[INCLCOLMASK]))isInclMaskCols = true;
-               if(!CmnUtils.isEmpty(prop_val[EXCLCOLMASK]))isExclMaskCols = true;
-               if(isInclMaskCols || isExclMaskCols)isMask = true;
-               if(!CmnUtils.isEmpty(prop_val[SBYTEMASKCHR]))singleByteChr = prop_val[SBYTEMASKCHR].charAt(0);
-               if(!CmnUtils.isEmpty(prop_val[DBYTEMASKCHR]))doubleByteChr = prop_val[DBYTEMASKCHR].charAt(0);
-               if(!CmnUtils.isEmpty(prop_val[MASKPTN]))maskPtn = prop_val[MASKPTN];
-               if(!CmnUtils.isEmpty(prop_val[DELIMITER]))delimiter = CmnUtils.getDelimiter(prop_val[DELIMITER]);
-       }
-
        public ResultSet getResultSet() throws Exception{
                return rst;
        }
@@ -353,31 +300,31 @@ public class DataAccessObjects{
 
                                                if (colString != null) {
                                                        if (i == _firstCol){
-                                                               if(isQuotation){
+                                                               if(cp.isQuotation){
                                                                        if (_firstCol == _lastCol){
-                                                                               _pw.print("\"" + colString + "\"" + lnSprtr);
+                                                                               _pw.print("\"" + colString + "\"" + cp.lineSeparator);
                                                                        } else {
                                                                                _pw.print("\"" + colString);
                                                                        }
                                                                } else {
                                                                        if (_firstCol == _lastCol){
-                                                                               _pw.print(colString + lnSprtr);
+                                                                               _pw.print(colString + cp.lineSeparator);
                                                                        } else {
                                                                                _pw.print(colString);
                                                                        }
                                                                }
                                                                
                                                        } else if (i == _lastCol){
-                                                               if(isQuotation){
-                                                                       _pw.print("\"" + delimiter + "\"" + colString + "\"" + lnSprtr);
+                                                               if(cp.isQuotation){
+                                                                       _pw.print("\"" + cp.delimiter + "\"" + colString + "\"" + cp.lineSeparator);
                                                                } else {
-                                                                       _pw.print(delimiter + colString + lnSprtr);
+                                                                       _pw.print(cp.delimiter + colString + cp.lineSeparator);
                                                                }
                                                        } else {
-                                                               if(isQuotation){
-                                                                       _pw.print("\"" + delimiter + "\"" + colString);
+                                                               if(cp.isQuotation){
+                                                                       _pw.print("\"" + cp.delimiter + "\"" + colString);
                                                                } else {
-                                                                       _pw.print(delimiter + colString);
+                                                                       _pw.print(cp.delimiter + colString);
                                                                }
                                                        }
                                                        
@@ -385,30 +332,30 @@ public class DataAccessObjects{
 
                                                } else {
                                                        if (i == _firstCol){
-                                                               if(isQuotation){
+                                                               if(cp.isQuotation){
                                                                        if (_firstCol == _lastCol){
-                                                                               _pw.print("\"" + nullMark + "\"" + lnSprtr);
+                                                                               _pw.print("\"" + cp.nullMark + "\"" + cp.lineSeparator);
                                                                        } else {
-                                                                               _pw.print("\"" + nullMark);
+                                                                               _pw.print("\"" + cp.nullMark);
                                                                        }
                                                                } else {
                                                                        if (_firstCol == _lastCol){
-                                                                               _pw.print(nullMark + lnSprtr);
+                                                                               _pw.print(cp.nullMark + cp.lineSeparator);
                                                                        } else {
-                                                                               _pw.print(nullMark);
+                                                                               _pw.print(cp.nullMark);
                                                                        }
                                                                }
                                                        } else if (i == _lastCol){
-                                                               if(isQuotation){
-                                                                       _pw.print("\"" + delimiter + "\"" + nullMark + "\"" + lnSprtr);
+                                                               if(cp.isQuotation){
+                                                                       _pw.print("\"" + cp.delimiter + "\"" + cp.nullMark + "\"" + cp.lineSeparator);
                                                                } else {
-                                                                       _pw.print(delimiter + nullMark + lnSprtr);
+                                                                       _pw.print(cp.delimiter + cp.nullMark + cp.lineSeparator);
                                                                }
                                                        } else {
-                                                               if(isQuotation){
-                                                                       _pw.print("\"" + delimiter + "\"" + nullMark);
+                                                               if(cp.isQuotation){
+                                                                       _pw.print("\"" + cp.delimiter + "\"" + cp.nullMark);
                                                                } else {
-                                                                       _pw.print(delimiter + nullMark);
+                                                                       _pw.print(cp.delimiter + cp.nullMark);
                                                                }
                                                        }
                                                }
@@ -445,26 +392,26 @@ public class DataAccessObjects{
                if (CmnUtils.isColString(_colTypeName)) {
                        colString = _rst.getString(_rec_cnt);
                        if (colString != null) {
-                               if(isQuotation){
+                               if(cp.isQuotation){
                                        colString =colString.trim().replaceAll("\0","").replaceAll("\"","\"\"");
                                } else {
                                        colString =colString.trim().replaceAll("\0","");
                                }
-                               if(isMask){
+                               if(cp.isMask){
                                        if(_colMask==true){
                                                StringBuffer sb = new StringBuffer();
                                                for(int j=0;j<colString.length();j++){
-                                                       if((maskPtn.toUpperCase().equals(MASK_PTN[MASK_PTN_ALT]) && 
+                                                       if((cp.maskPattern.toUpperCase().equals(cp.MASK_PTN[cp.MASK_PTN_ALT]) && 
                                                                        (j % 2) == 1) || 
-                                                          (maskPtn.toUpperCase().equals(MASK_PTN[MASK_PTN_EDGE]) && 
+                                                          (cp.maskPattern.toUpperCase().equals(cp.MASK_PTN[cp.MASK_PTN_EDGE]) && 
                                                                        !(j == 0 || j == colString.length() - 1) ||
-                                                          (maskPtn.toUpperCase().equals(MASK_PTN[MASK_PTN_ALL]))
+                                                          (cp.maskPattern.toUpperCase().equals(cp.MASK_PTN[cp.MASK_PTN_ALL]))
                                                           )
                                                        ){
                                                                        if(CmnUtils.isHankaku(colString.charAt(j))){
-                                                                               sb.append(singleByteChr);
+                                                                               sb.append(cp.singleByteMaskChar);
                                                                        } else {
-                                                                               sb.append(doubleByteChr);
+                                                                               sb.append(cp.doubleByteMaskChar);
                                                                        }
                                                        } else {
                                                                sb.append(colString.charAt(j));