You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by li...@apache.org on 2016/12/08 00:45:33 UTC
[06/38] incubator-trafodion git commit: convert trafci project into
maven project
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/org/trafodion/ci/ParseArguments.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/org/trafodion/ci/ParseArguments.java b/core/conn/trafci/src/org/trafodion/ci/ParseArguments.java
deleted file mode 100644
index 57944a0..0000000
--- a/core/conn/trafci/src/org/trafodion/ci/ParseArguments.java
+++ /dev/null
@@ -1,660 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-package org.trafodion.ci;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-public class ParseArguments
-{
-
- String[] args=null;
- int noOfArgs=0;
- String userName=null;
- String roleName=null;
- String password=null;
- String serverName=null;
- String portNumber=null;
- String dsnName=null;
- String queryStr=null;
- String fileName=null;
- String defaultDsnName=null;
- String defaultPortNumber=null;
- boolean noConnectOption=false; // set to true if noconnection option is specified.
- boolean isLaunchConnect=true;
- boolean autoLogin=false;
- boolean dfm=false;
- /*-------------------------------------------------------------------------------**
- The isLaunchConnect flag is set to true when connection args are validated at
- the application launch time to validate the type of args the can be entered
- for example -s and -sql can be entered only at launch.
- **-------------------------------------------------------------------------------*/
- ConsoleReader crObj=null;
- ConsoleWriter cwObj=null;
- static int retryCntProp=0;
- int retryCnt=1;
- String osName=null;
- final String EXIT_PROD_STR = "Exiting " + SessionDefaults.PROD_NAME + " - Please hit <Enter> ... ";
- static
- {
- String loginRetries=null;
-
- //Prompt for n login retries if property set
- loginRetries=System.getProperty ("trafci.loginRetries");
- if (loginRetries!=null)
- if ((retryCntProp = Integer.parseInt(loginRetries.trim())) <= 0)
- retryCntProp = 1;
- }
-
- ParseArguments()
- {
-
- }
-
- ParseArguments(ConsoleReader crObj,ConsoleWriter cwObj)
- {
- this.crObj=crObj;
- this.cwObj=cwObj;
-
- //Prompt for login input retries if in console/interactive mode
- if (crObj.isInteractive())
- this.retryCnt=3;
-
- /*-------------------------------------------------------------------------**
- //Prompt for n login retries if property set
- String loginRetries=System.getProperty ("trafci.loginRetries");
- if (loginRetries!=null)
- if ((this.retryCnt = Integer.parseInt(loginRetries.trim())) <= 0)
- this.retryCnt = 1;
- **-------------------------------------------------------------------------*/
- if (retryCntProp > 0)
- retryCnt = retryCntProp;
-
- }
-
- private void setArgs(String[] args)
- {
- noOfArgs=args.length;
- this.args=args;
- }
-
- public void setDefaults(String dsnName,String portNumber)
- {
- this.defaultDsnName=dsnName;
- this.defaultPortNumber=portNumber;
- }
-
- public String[] validateArgs(String[] args,boolean isLaunchConnect)
- throws InvalidNumberOfArguments, IOException, UserInterruption
- {
-
- osName = System.getProperty("os.name");
- setArgs(args);
- this.isLaunchConnect=isLaunchConnect;
-
- List<String> argsList= new ArrayList<String>(Arrays.asList(args));
-
- //Pre-parse args for special cases
- if (argsList.contains("-version"))
- {
- cwObj.print("JDBC Type 4 Driver Build ID : ");
- cwObj.println(JDBCVproc.getVproc());
- cwObj.print("Command Interface Build ID : ");
- org.trafodion.ci.Vproc.main(args) ;
- cwObj.println("");
- System.exit(0); //any other args included w/version are ignored
- }
-
- //Display argument help if -help argument is passed
- if (argsList.contains("-help"))
- {
- printUsage();
- System.exit(0); //any other args included w/help are ignored
- }
-
-
- // No retries if in query mode
- if (argsList.contains("-q") || argsList.contains("-sql"))
- retryCnt = 1;
-
-
- if (argsList.remove("-noconnect"))
- {
- noConnectOption=true;
- }
-
- if (argsList.remove("-dfm"))
- {
- dfm = true;
- }
-
- /* reset args b/c of -noconnect or -dfm, dont need the if but perhaps a small perf gain? */
- if(dfm || noConnectOption)
- {
- args = null;
- args = new String[argsList.size()];
- //args = (String[])
- argsList.toArray(args);
- noOfArgs = args.length;
- }
-
- // the number of arguments must be an odd number if -noconnect option is specified
- // otherwise it should be an even number
-
- if (noOfArgs % 2 != 0 || noOfArgs > 14)
- {
- printUsage();
- throw new InvalidNumberOfArguments();
- }
-
-
- argsList=null;
-
- //Pre-parsing complete
-
- for (int i=0;i < noOfArgs; i++)
- {
- String option=args[i++].trim();
- String value=args[i].trim();
-
- if (option.equalsIgnoreCase("-u")|| option.equalsIgnoreCase("-user"))
- {
- userName=value;
- }
- else if (option.equalsIgnoreCase("-p")|| option.equalsIgnoreCase("-password"))
- {
- password=value;
- }
- else if (option.equalsIgnoreCase("-r")|| option.equalsIgnoreCase("-role"))
- {
- roleName=value;
- }
- else if (option.equalsIgnoreCase("-h")|| option.equalsIgnoreCase("-host"))
- {
- String[] hostAddr=value.split(":");
- if (hostAddr.length > 0)
- serverName=hostAddr[0];
- else
- serverName="";
-
- String portValue="";
-
- for (int j=1; j < hostAddr.length;j++)
- {
- portValue+=":"+hostAddr[j];
- }
- if (portValue.length() > 0)
- {
- portNumber=portValue;
- }
-
- }
- else if (isLaunchConnect && (option.equalsIgnoreCase("-q")|| option.equalsIgnoreCase("-sql")))
- {
- queryStr=value;
- if (fileName != null)
- {
- cwObj.println("-s|script and -q|sql options must not be specified together.");
- this.printUsage();
- }
- }
- else if (isLaunchConnect &&(option.equalsIgnoreCase("-s")|| option.equalsIgnoreCase("-script")))
- {
- fileName=value;
- if (queryStr != null)
- {
- cwObj.println("-s|script and -q|sql options must not be specified together.");
- this.printUsage();
- }
- }
- /* Instead of -cmd we will implement a set cmdecho <on|off> command
- * and replace -cmd with -DFM which will execute both set lookandfeel mxci and
- * set cmdecho on
- *
- * else if (isLaunchConnect &&(option.equalsIgnoreCase("-cmd")))
- {
- if (value.equalsIgnoreCase("Y"))
- cmdEcho = true;
- }*/
- else
- {
- cwObj.println("Unknown option " + option + " specified.");
- printUsage();
- throw new UnknownHostException();
- }
-
- } //end for
-
- if (!noConnectOption)
- {
- do
- {
-
- if (serverName == null)
- {
- String value= getRequiredArg("Host Name/IP Address: ");
- String[] hostAddr=value.split(":");
- if (hostAddr.length > 0)
- serverName=hostAddr[0];
- else
- serverName="";
- String portValue="";
- for (int j=1; j < hostAddr.length;j++)
- {
- portValue+=":"+hostAddr[j];
- }
- portNumber=null;
- if (portValue.length() > 0)
- {
- portNumber=portValue;
- }
- }
-
-
- try
- {
- if (serverName.trim().equals(""))
- throw new UnknownHostException("Host Name is empty");
- else
- InetAddress.getByName(serverName);
- }
- catch (UnknownHostException uh)
- {
- cwObj.println(SessionDefaults.lineSeperator+"Unknown Host: " + serverName + SessionDefaults.lineSeperator);
- serverName=null;
-
- //Rebuild the argument list to remove the hostname
- args = this.rebuildArgList(args);
- if ((--retryCnt) == 0)
- throw uh;
- }
-
- }while (serverName==null && retryCnt > 0);
- }
-
-
- if (!noConnectOption && userName == null)
- {
- do
- {
- userName=getRequiredArg("User Name: ");
- }
- while (userName.trim().equals(""));
- }
-
- if (!noConnectOption && password == null)
- {
- password=getPassword("Password: ");
- }
-
- if (!noConnectOption && roleName == null)
- {
- roleName=getRequiredArg("Role Name [Primary Role]: ");
-
-
- }
-
- if (portNumber == null)
- {
- portNumber=":"+defaultPortNumber;
- }
-
-
- return args;
-
- }
-
- public String[] validateArgs(String[] args) throws InvalidNumberOfArguments, IOException, UserInterruption
- {
- return (validateArgs(args,false));
- }
-
- private String getRequiredArg(String prompt) throws IOException, UserInterruption
- {
- String value=null;
- String breakConnectPrompt = EXIT_PROD_STR;
- if (!this.isLaunchConnect)
- breakConnectPrompt = "Command Interrupted - Please hit <Enter> ... "+SessionDefaults.lineSeperator;
-
- crObj.setPrompt(breakConnectPrompt,false,false);
- cwObj.print(prompt);
-
- //set retry count to 0 if user hits a Ctrl+C while entering login parameters
- try
- {
- value=crObj.getLine();
- } catch (UserInterruption ui)
- {
- retryCnt = 0;
- throw ui;
- }
- return value;
- }
-
- private void printUsage()
- {
- String os_specific_ci_cmd = "trafci";
-
- String spacedOutLine = SessionDefaults.lineSeperator;
- for (int idx = 0; idx < os_specific_ci_cmd.length(); idx++)
- spacedOutLine += " ";
-
- cwObj.println(SessionDefaults.lineSeperator + os_specific_ci_cmd +
- " -h[ost] <databaseserver:port> " +
- spacedOutLine +
- " -u[ser] <username> -p[assword] <password>" +
- spacedOutLine +
- " -r[ole] <rolename>" +
- spacedOutLine +
- " -s[cript] <scriptfilename> -q|-sql <\"querystring\">" +
- spacedOutLine +
- " -noconnect -version -help" );
-
- cwObj.println(SessionDefaults.lineSeperator+"where:");
- cwObj.println("\t-h[ost] specifies the database server including the port number.");
- cwObj.println("\t-u[ser] specifies a user name to log into a database server.");
- cwObj.println("\t-p[assword] specifies the user's password to log into a database server.");
- cwObj.println("\t-r[ole] specifies the role name associated with the user.");
- cwObj.println("\t-s[cript] specifies the command file used to customize a session.");
- cwObj.println("\t-q|-sql specifies the command to be run in non-interactive mode.");
- cwObj.println("\t-noconnect specifies the session login mode.");
- cwObj.println("\t-version displays the Trafodion Command Interface and JDBC Type 4 Driver versions, then exits.");
- cwObj.println("\t-help displays a list of accepted arguments with descriptions, then exits.");
- cwObj.println("");
-
- }
-
- /*------------------------------------------------------------------**
- ** private String getPassword (String prompt) throws IOException { **
- ** MaskingThread et = new MaskingThread(prompt); **
- ** Thread mask = new Thread(et); **
- ** mask.start(); **
- ** **
- ** String password = ""; **
- ** **
- ** password = crObj.getLine(); **
- ** // stop masking **
- ** et.stopMasking(); **
- ** // return the password entered by the user **
- ** return password; **
- ** } **
- **------------------------------------------------------------------*/
-
- public String getPassword (String prompt) throws IOException, UserInterruption
- {
- String password = "";
- WCIUtils wcs=null;
- boolean isWindows = System.getProperty("os.name").toUpperCase().startsWith("WINDOW");
-
- MaskingThread et = new MaskingThread(prompt);
- Thread mask = new Thread(et);
- mask.start();
-
- // if it is windows envrionment use the dll to disable echo
- if (isWindows)
- {
- try {
- wcs=new WCIUtils();
- wcs.disableEcho();
-
- } catch(Throwable e) { }
-
- }
- crObj.setMaskingThread(et,wcs);
-
- String breakConnectPrompt = EXIT_PROD_STR;
- if (!this.isLaunchConnect)
- breakConnectPrompt = "Command Interrupted - Please hit <Enter> ... "+SessionDefaults.lineSeperator;
-
- crObj.setPrompt(breakConnectPrompt,false,false);
-
-
- try
- {
- password = crObj.getLine();
- }
- catch (Throwable t)
- {
- UserInterruption uie = null;
- if (t instanceof UserInterruption)
- {
- uie =(UserInterruption) t;
- retryCnt = 0;
- }
- else
- uie = new UserInterruption();
-
-
- throw uie;
- }
- finally
- {
-
- // stop masking
- et.stopMasking();
-
- if (isWindows)
- {
- try {
- wcs.enableEcho();
-
- } catch(Exception e) { }
-
- wcs=null;
- }
- cwObj.print(SessionDefaults.lineSeperator);
- }
- // return the password entered by the user
- return password;
- }
-
- public String getInputMask (String prompt, boolean isInputMask) throws IOException, UserInterruption
- {
- String password = "";
- WCIUtils wcs=null;
- boolean isWindows = System.getProperty("os.name").toUpperCase().startsWith("WINDOW");
-
- MaskingThread et = new MaskingThread(prompt);
- Thread mask = new Thread(et);
- mask.start();
-
- // if it is windows envrionment use the dll to disable echo
- if (isWindows)
- {
- try {
- wcs=new WCIUtils();
- wcs.disableEcho();
-
- } catch(Throwable e) { }
- }
- crObj.setMaskingThread(et,wcs);
-
- String breakConnectPrompt = EXIT_PROD_STR;
- if (!this.isLaunchConnect || isInputMask )
- breakConnectPrompt = "Command Interrupted - Please hit <Enter> ... "+SessionDefaults.lineSeperator;
-
- crObj.setPrompt(breakConnectPrompt,false,false);
-
- try
- {
- password = crObj.getLine();
- }
- catch (Throwable t)
- {
- UserInterruption uie = null;
- if (t instanceof UserInterruption)
- {
- uie =(UserInterruption) t;
- retryCnt = 0;
- }
- else
- uie = new UserInterruption();
-
-
- throw uie;
- }
- finally
- {
-
- // stop masking
- et.stopMasking();
-
- if (isWindows)
- {
- try {
- wcs.enableEcho();
-
- } catch(Exception e) { }
-
- wcs=null;
- }
- cwObj.print(SessionDefaults.lineSeperator);
- }
- // return the password entered by the user
-
- return password;
- }
-
-
- public String getInputNomask (String prompt, boolean isNotInputMask) throws IOException, UserInterruption
- {
- String userInput = "";
-
- String breakConnectPrompt = EXIT_PROD_STR;
- if (isNotInputMask)
- breakConnectPrompt = "Command Interrupted - Please hit <Enter> ... ";
-
- crObj.setPrompt(breakConnectPrompt,false,false);
-
- try
- {
- System.out.print( " \r" + prompt );
- userInput = crObj.getLine();
- }
- catch (Throwable t)
- {
- UserInterruption uie = null;
- if (t instanceof UserInterruption)
- {
- uie =(UserInterruption) t;
- retryCnt = 0;
- }
- else
- uie = new UserInterruption();
-
-
- throw uie;
- }
- finally
- {
- cwObj.print(SessionDefaults.lineSeperator);
- }
- // return characters entered by the user
- return userInput;
- }
-
-
- public String[] rebuildArgList(String[] oldArgs)
- {
- int i;
- List<String> argsList= new ArrayList<String> (Arrays.asList (oldArgs));
-
- if (argsList.isEmpty())
- return oldArgs;
-
- String argKey1 = null;
- String argKey2 = null;
- String argKey3 = null;
- String argKey4 = null;
- String argKey5 = null;
- String argKey6 = null;
-
- if (this.userName == null || this.password == null || this.roleName ==null)
- {
- argKey1 = "-u";
- argKey2 = "-p";
- argKey3 = "-user";
- argKey4 = "-password";
- argKey5 = "-r";
- argKey6 = "-role";
- }
- else if (this.dsnName == null)
- {
- argKey1 = "-d";
- argKey3 = "-dsn";
- }
- else if (this.serverName == null)
- {
- argKey1 = "-h";
- argKey3 = "-host";
- }
- else
- return oldArgs;
-
- do
- {
- if (((i = argsList.indexOf(argKey1)) >= 0) ||
- ((i = argsList.indexOf(argKey3)) >= 0) ||
- ((i = argsList.indexOf(argKey5)) >= 0) )
- {
- argsList.remove(i);
- argsList.remove(i);
- }
- }
- while (i > -1);
-
- do
- {
- if ((argKey2 != null) && (((i = argsList.indexOf(argKey2)) >= 0 ) ||
- ((i = argsList.indexOf(argKey4)) >= 0 )) ||
- ((i = argsList.indexOf(argKey6)) >= 0 ))
- {
- argsList.remove(i);
- argsList.remove(i);
- }
- }
- while (i > -1);
-
- String[] newArgs=new String[argsList.size ()];
- argsList.toArray (newArgs);
- return newArgs;
-
- }
-
-
-
- public boolean isAutoLogin()
- {
- return autoLogin;
- }
-
- public void setAutoLogin(boolean autoLogin)
- {
- this.autoLogin = autoLogin;
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/org/trafodion/ci/Parser.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/org/trafodion/ci/Parser.java b/core/conn/trafci/src/org/trafodion/ci/Parser.java
deleted file mode 100644
index a130032..0000000
--- a/core/conn/trafci/src/org/trafodion/ci/Parser.java
+++ /dev/null
@@ -1,1195 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-package org.trafodion.ci;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.ArrayList;
-import java.util.List;
-
-public class Parser
-{
- private String remainderStr=null;
- Pattern filePat=Pattern.compile("^\\s*((\"(\"(?=\")|.)*\")|\\S*)(\\s+(.*)|$)");
- Pattern numberPat=Pattern.compile("^\\s*((-)?\\d+)(\\s+(.*)|$)");
- Pattern paramPat=Pattern.compile("^\\s*(\\??)([a-zA-Z_]\\w*)(\\s+(.*)|$)");
- Pattern keyPat=Pattern.compile("^\\s*(\\S+)(\\s+(.*)|\\z)",Pattern.DOTALL);
- Pattern ignoreCommentsPat=Pattern.compile("(?m)((^--)|^)((((?!--|\').)*)*(\\s*((\'(\'(?=\')|\\\\(?=\')|(?!\').)*\')*(((?!--|\').)*)*)\\s*)*)");
- Pattern pstmtPat=Pattern.compile("^\\s*((\"[a-zA-Z_]\\w*\")|[a-zA-Z_]\\w*)(\\s+(.*)|$)",Pattern.DOTALL);
- Pattern explainPat = Pattern.compile( "(^\\s*(?i)EXPLAIN(\\s+(?i)OPTIONS\\s+\'f\')?)\\s+((\"[a-zA-Z_]\\w*\")|[a-zA-Z_]\\w*)\\s*$",Pattern.DOTALL);
- Pattern valPat=Pattern.compile("^\\s*((\"(\"(?=\")|\\\\(?=\")|.)*?\")|(\\S+))(\\s*(.*)|$)");
- Pattern val2Pat=Pattern.compile("^\\s*((\'(\'(?=\')|\\\\(?=\')|.)*\')+|(\\S+))(\\s+(.*)|$)");
- /**
- * Support _UTF8 for set PARAM
- */
- Pattern paramValuePat=Pattern.compile("^\\s*(((_[iI][sS][oO]88591|_[uU][cC][sS]2|_[uU][tT][fF]8|_[kK][aA][nN][jJ][iI]|_[kK][sS][cC]5601)?(\\s*[xX])?(\'(.*)\'))|(\\S+))(\\s+(.*)|$)");
- Pattern catalogPat=Pattern.compile("(\"(?:[^\"\\\\]|\"\"|\\\\.)*\"|\\S+)(\\s*.*|$)");
- Pattern tabPat=Pattern.compile("^\\s*((\"(\"(?=\")|\\\\(?=\")|.)*?\")|(\\w+));*\\s*(\\.(.*)|$|(,\\s*(?i)[A-Zz-z]*(.*)?$))",Pattern.DOTALL);
- //Pattern paramListPat=Pattern.compile("^\\s*(\\??)((\'(\'(?=\')|\\\\(?=\')|.)*?\')|([^ ,]+))\\s*(,\\s*(.*)|$)",Pattern.DOTALL);
- Pattern paramListPat=Pattern.compile("^\\s*((\'(\'(?=\')|\\\\(?=\')|.)*?\')|([^ ,]+))\\s*(,\\s*(.*)|$)",Pattern.DOTALL);
- Pattern mapListPat=Pattern.compile("^\\s*((\"(\"(?=\")|\\\\(?=\")|.)*?\")*([^,]+))\\s*(,\\s*(.*)|$)",Pattern.DOTALL);
- Pattern exitPat=Pattern.compile("(?i)^\\s*((WITH\\s+(-?\\d+))|(-?\\d+))?(\\s+IF(?!.*THEN.*).+)?$");
- Pattern sectionPat=Pattern.compile("^\\s*\\(\\s*([a-zA-Z_]\\w*)\\s*\\)(\\s*$)");
- Pattern mxciParamPat = Pattern.compile("^\\?(.*)");
- Pattern dbFunctionPat = Pattern.compile("(?i)FN:(\\w+\\((.*)\\))");
- Pattern mapFileFixedWidthColPat = Pattern.compile("^\\s*COLPOS\\((\\d+):(\\d+)\\).*$");
- Pattern envPat=Pattern.compile("%([a-zA-Z]+)(.*)");
- Pattern scriptPat=Pattern.compile("(?i)^\\s*(SRUN)\\s+(.*)");
- Pattern connUserPat=Pattern.compile("([^,/@]+)(.*)");
- Pattern connUserPreparePat=Pattern.compile("(^\".*?\")(.*)");
- Pattern connPassPat=Pattern.compile("^/((\"(\"(?=\")|\\\\(?=\")|.)*?\")|[^@,]*)(@.*$|,.*$|$)");
- Pattern connServerPat=Pattern.compile("^@([^,]+)(,.*$|$)");
- Pattern connDsnPat=Pattern.compile("^,(.+)($)");
- Pattern errPat = Pattern.compile("\\*\\*\\* (ERROR|WARNING)\\[(\\w*)\\](.*)",Pattern.DOTALL);
- Pattern ndcsProductInfo = Pattern.compile("T7970([^ ])*",Pattern.DOTALL);
- Pattern sysInfo = Pattern.compile("Current SYSnn(\\s+(.*))");
- Pattern t4Version= Pattern.compile("T1249_.*[(]R(.[^)]*)");
- Pattern wmsErrPat= Pattern.compile("Unexpected.*(error message = (.*))");
- String showWildCardPattern = "(?<!\\\\)\\*";
- String showWildCardPattern2 = "\\\\\\*";
- String showWildCardPatternChar = "(?<!\\\\)\\?";
- Pattern wordPattern=Pattern.compile("^\\s*(\\w+)(\\s*(.*)|$)");
- Pattern dbProdVersionPat=Pattern.compile("([A-Z]((\\d+)\\.(\\d+))(.*))((is the SUT identifier\\.)|(for NEO no ipms)|(plus integration build(.*)))");
- Pattern condPat = Pattern.compile("^(?i:IF)(\\s|\\n)+((\"(\"(?=\")|\\\\(?=\")|.)*?\")|[^(\\s|\\n|~=|\\^=|!=|<>|>=|<=|>|<|=|==)]+)(\\s|\\n)*(~=|\\^=|!=|<>|>=|<=|>|<|==|=)(\\s|\\n)*((\"(\"(?=\")|\\\\(?=\")|.)*?\")|\\S+)(\\s|\\n)+(?i:THEN)(\\s|\\n)+(.+)\\z", Pattern.DOTALL);
- Pattern delayTimePat = Pattern.compile("(?i)\\s*((-?\\d+)\\s*(((sec(ond)?(s)?)?)|(min(ute)?(s)?)))?");
- String tmpTableName=null;
- String showTableIdxRemainder=null;
- static final String UNKNOWN_ERROR_CODE = "UNKNOWN ERROR CODE";
-
- Pattern patternKeyPat = Pattern.compile("\\s*\\$\\$([a-zA-Z0-9_]+)\\$\\$\\s+(.*)",Pattern.DOTALL);
- Pattern patternValPat = Pattern.compile("\\s*(.*)(\\s*(.*)|$)");
- Pattern containsKeyPat = Pattern.compile("(\\.)?\\$\\$([a-zA-Z0-9_]+)\\$\\$",Pattern.DOTALL);
- Pattern regExpPat = Pattern.compile("\\s*/(.*)/(.*/)",Pattern.DOTALL);
- Pattern regExpVal = Pattern.compile("(.+)/(.*)",Pattern.DOTALL);
-
- // For LDAP
- Pattern errPosPat = Pattern.compile("(.*)\\s+at line \\d+, column (\\d+)(.*)",Pattern.DOTALL);
- Pattern secErrPat = Pattern.compile(".*Details:[^:]*:(.*)", Pattern.DOTALL);
-
- private boolean isTracingOn = Boolean.getBoolean("trafci.enableTrace");
-
-
- Parser() {
- }
- public String getRemainderStr()
- {
- return remainderStr;
- }
- public void setRemainderStr(String remainderStr)
- {
- this.remainderStr=remainderStr;
- }
-
- String getScriptToken()
- {
- Matcher mat=scriptPat.matcher(remainderStr);
- if (mat.find())
- {
- return mat.group(2);
- }
- else
- return null;
- }
-
- String getNextFileToken()
- {
- if (remainderStr == null)
- return null;
- Matcher mat=filePat.matcher(remainderStr);
-
- if (mat.find())
- {
- remainderStr=mat.group(4);
-
- if (mat.group(1) != null)
- {
-
- if (mat.group(1).startsWith("\"") && mat.group(1).endsWith("\""))
- return mat.group(1).substring(1,mat.group(1).length()-1);
- else
- return mat.group(1);
- }
- else
- {
- return null;
- }
- }
- else
- return null;
- }
-
- String getNextSectionToken()
- {
- if (remainderStr == null)
- return null;
- Matcher mat=sectionPat.matcher(remainderStr);
-
- if (mat.find())
- {
- remainderStr=mat.group(2);
-
- if (mat.group(1)!=null)
- {
- return (mat.group(1));
- }
- else
- {
- return null;
- }
- }
- else
- return null;
- }
-
- String getNextNumberToken()
- {
- if (remainderStr == null)
- return null;
-
- Matcher mat=numberPat.matcher(remainderStr);
- if (mat.find())
- {
- remainderStr=mat.group(4);
- return mat.group(1);
- }
- else
- return null;
- }
-
- String getNextKeyToken()
- {
- if (remainderStr == null)
- return null;
-
- Matcher mat=keyPat.matcher(remainderStr);
- if (mat.find())
- {
- remainderStr=mat.group(2);
- return mat.group(1);
- }
- else
- return null;
- }
-
- String lookAtNextToken()
- {
- if (remainderStr == null)
- return null;
-
- Matcher mat=valPat.matcher(remainderStr);
- if (mat.find())
- {
- return mat.group(1);
- }
- else
- return null;
- }
-
- String getNextParamToken()
- {
- if (remainderStr == null)
- return null;
-
- Matcher mat=paramPat.matcher(remainderStr);
- if (mat.find())
- {
- remainderStr=mat.group(3);
- return mat.group(2);
- }
- else
- return null;
- }
-
- String getNextPreparedStmtNameToken()
- {
- if (remainderStr == null)
- return null;
- Matcher mat=pstmtPat.matcher(remainderStr);
- if (mat.find())
- {
- remainderStr=mat.group(3);
-
- if (mat.group(2)!=null)
- {
- return (mat.group(2).substring(1,mat.group(2).length()-1));
- }
- else
- {
- return mat.group(1).toUpperCase();
- }
- }
- else
- return null;
-
- }
-
- public List<String> getNextParamListToken()
- {
- List<String> paramList=null;
- paramList=new ArrayList<String>();
- String paramName=null;
- while (true)
- {
- if ((paramName=getNextParam2Token()) != null)
- {
- paramList.add(paramName);
- }
- else
- {
- break;
- }
- }
-
- return paramList;
- }
-
- public String getNextParam2Token()
- {
-
-
- if (remainderStr == null)
- {
- return null;
- }
- Matcher mat=paramListPat.matcher(remainderStr);
- if (mat.find())
- {
- //System.out.println(mat.group(3));
- remainderStr=mat.group(6);
-
- //showTableIdxRemainder=mat.group(7);
-
- if (mat.group(2) != null)
- {
- return mat.group(2).substring(1,mat.group(2).length()-1);
- }
- else if (mat.group(4) != null)
- {
- return mat.group(4).trim();
- }
- else
- {
- return null;
- }
- }
- else
- {
- if (remainderStr != null)
- {
- String tmpStr=remainderStr.trim();
- remainderStr=null;
- return tmpStr;
- }
- return null;
- }
-
- }
- //dead code. Removed by Kevin Xu
-/*
- boolean matchExplainSyntax(List tokenList)
- {
- if (remainderStr == null)
- return false;
-
- Matcher mat=explainPat.matcher(remainderStr);
- if (mat.find())
- {
- //System.out.println("Return true");
- tokenList.add(mat.group(1));
- if (mat.group(4)!=null)
- {
- tokenList.add(mat.group(4).substring(1,mat.group(4).length()-1));
- }
- else
- {
- tokenList.add(mat.group(3).toUpperCase());
- }
- return true;
-
- }
- //System.out.println("Return False");
- return false;
-
- }
-*/
- // the value can be any word without quotes
- // or any values including special characters enclosed within
- // double quotes
- // if the value is enclosed within double quotes return value should
- // retain the case and remove the double quotes otherwise the return
- // value should have all upper case
- String getNextValueToken()
- {
- if (remainderStr == null)
- return null;
-
- Matcher mat=valPat.matcher(remainderStr);
-
- if (mat.find())
- {
- remainderStr=mat.group(5);
- if (mat.group(2) != null)
- {
- return mat.group(2).substring(1,mat.group(2).length()-1);
- }
- else if (mat.group(4) != null)
- {
- return mat.group(4).toUpperCase();
- }
- else
- {
- return null;
- }
- }
- else
- {
- return null;
- }
- }
-
-
- String getNextQValueToken()
- {
- if (remainderStr == null)
- return null;
-
- Matcher mat=valPat.matcher(remainderStr);
-
- if (mat.find())
- {
- remainderStr=mat.group(5);
- if (mat.group(2) != null)
- {
- return mat.group(2);
- }
- else if (mat.group(4) != null)
- {
- return mat.group(4).toUpperCase();
- }
- else
- {
- return null;
- }
- }
- else
- {
- return null;
- }
- }
-
- String getCatalogToken()
- {
- if (remainderStr == null)
- return null;
-
- Matcher mat=catalogPat.matcher(remainderStr);
-
- if (mat.find())
- {
- remainderStr=mat.group(2);
- if (mat.group(1).startsWith("\"") )
- return mat.group(1);
- else
- return mat.group(1).toUpperCase();
- }
- else
- {
- return null;
- }
- }
-
- /**
- * Gets the value of a parameter (for a set param call). Uses a
- * regular expression to match the input to a grammar/syntax.
- *
- * @param cmdInput if its null uses the remainder string we have
- * stored internally in here.
- * @return Null or a parameter value object (with the charset and input)
- * @since R2.4 SP2
- *
- */
-
- ParamStringObject getParamValue(String cmdInput) {
- boolean setRemainder = false;
-
- try {
-
- /**
- * Check if we any parameter passed -- if not use the remaining
- * input we have. And also remember that we need to set the
- * remainder if there's any input remaining.
- */
- if (null == cmdInput) {
- cmdInput = remainderStr;
- setRemainder = true;
- }
-
-
- /**
- * Check if we have any input to work on.
- */
- if (null == cmdInput)
- return null;
-
-
- if (isTracingOn)
- System.out.println("@@@Trace: getParamValue:: cmd input = " +
- cmdInput);
-
- /**
- * Check if we have a match and get the value for the parameter.
- */
- Matcher mat = paramValuePat.matcher(cmdInput);
-
- if (!mat.find() )
- return null;
-
-
- /**
- * All the unmatched portion is in the eighth group. Use that to
- * set the remainder string IFF we need to do that.
- */
- if (setRemainder)
- remainderStr = mat.group(8);
-
- if (isTracingOn)
- System.out.println("@@@Trace: getParamValue:: remainderStr = " +
- mat.group(8) );
-
-
- /**
- * The seventh group is any simple string values or error cases.
- * If we have a seventh group and its not null return that value.
- * This is match for the (\\S+) component of the regexp.
- */
- String theValue = mat.group(7);
- if (null != theValue)
- return new ParamStringObject(null, null, theValue);
-
-
- /**
- * Otherwise its a charset + hexinput + value type of string.
- * Group 3 is the charset, group 4 is the hex input prefix 'x'
- * and group 5 is the actual String value. Reassemble those.
- */
- ParamStringObject psv = new ParamStringObject(mat.group(3), mat.group(4),
- mat.group(5) );
-
- if (isTracingOn)
- System.out.println("@@@Trace: getParamValue:: theValue = " +
- psv.toString() );
-
- return psv;
-
- } catch(Throwable t) {
- if (isTracingOn) {
- System.out.println("Internal error getting parameter value. " +
- "Details = " + t.getMessage() );
-
- t.printStackTrace();
- }
-
- }
-
- return null;
-
- } /* End of getParamValue method. */
-
- String getNextValueType2Token()
- {
- if (remainderStr == null)
- return null;
-
- Matcher mat=val2Pat.matcher(remainderStr);
-
- if (mat.find())
- {
- remainderStr=mat.group(5);
- if (mat.group(2) != null)
- {
- return mat.group(2).substring(1,mat.group(2).length()-1);
- }
- else if (mat.group(4) != null)
- {
- return mat.group(4).toUpperCase();
- }
- else
- {
- return null;
- }
- }
- else
- return null;
- }
-
-
- boolean hasMoreTokens()
- {
- if (remainderStr == null || remainderStr.trim().length()== 0)
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- //dead code. Removed by Kevin Xu
-/*
- String ignoreCommentsOld(String queryStr)
- {
- if (queryStr != null)
- {
- if (queryStr.indexOf("--") != -1)
- {
- StringBuffer outBuffer=null;
- outBuffer=new StringBuffer();
- Matcher ignoreCommentsPat = this.ignoreCommentsPat.matcher(queryStr);
- while (ignoreCommentsPat.find())
- {
- if (ignoreCommentsPat.group(2) != null)
- {
- //group 2 is not null..dont have to print anything
-
- }
- else if (ignoreCommentsPat.group(4) != null || ignoreCommentsPat.group(6) != null)
- {
- outBuffer.append(ignoreCommentsPat.group(3));
- }
- else
- {
-
- outBuffer.append(ignoreCommentsPat.group(0));
- }
- }
- return outBuffer.toString();
- }
- }
- return queryStr;
- }
-*/
- public List<String> getCSTList(String tablePattern)
- {
- List<String> cstList=null;
- cstList=new ArrayList<String>();
- String tabName=null;
- tmpTableName=null;
- tmpTableName=tablePattern;
- while (true)
- {
- if ((tabName=getNextTableToken(tmpTableName)) != null)
- {
- cstList.add(tabName);
- }
- else
- {
- break;
- }
- }
- return cstList;
- }
-
-
-
- public String getNextTableToken(String tablePattern)
- {
- if (tablePattern == null)
- {
- return null;
- }
- Matcher mat=tabPat.matcher(tablePattern);
-
- if (mat.find())
- {
- tmpTableName=mat.group(6);
-
- showTableIdxRemainder=mat.group(7);
-
- if (mat.group(2) != null)
- {
- return mat.group(2).replaceAll("\"","\\\"");
- }
- else if (mat.group(4) != null)
- {
- return mat.group(4).toUpperCase();
- }
- else
- {
- return null;
- }
- }
- else
- {
- return null;
- }
-
- }
-
- //dead code. Removed by Kevin Xu
-/*
- boolean matchMxciParamPat(String param)
- {
- Matcher mat = mxciParamPat.matcher(param);
- if (mat.find())
- {
- remainderStr = mat.group(1).trim();
- return true;
- }
- else
- {
- remainderStr = null;
- return false;
- }
- }
-*/
- public List<String> splitLines()
- {
- List<String> paramList=null;
- paramList=new ArrayList<String>();
- String paramName=null;
- while (true)
- {
- if ((paramName=getNextToken()) != null)
- {
- paramList.add(paramName);
- }
- else
- {
- break;
- }
- }
-
- return paramList;
- }
-
- public String getNextToken()
- {
-
- if (remainderStr == null)
- {
- return null;
- }
- Matcher mat=mapListPat.matcher(remainderStr);
- if (mat.find())
- {
- remainderStr=mat.group(6);
-
- if (mat.group(1) != null)
- {
- return mat.group(1);
- }
- else
- {
- return null;
- }
- }
- else
- {
- if (remainderStr != null)
- {
- String tmpStr=remainderStr.trim();
- remainderStr=null;
- return tmpStr;
- }
- return null;
- }
-
- }
- //dead code. Removed by Kevin Xu
-/*
- List split(String line)
- {
- List tokList=null;
- tokList=new ArrayList();
- String token=null;
- this.setRemainderStr(line);
-
- while (true)
- {
- if ((token=getNextValueType2Token()) != null)
- {
- tokList.add(token);
- }
- else
- {
- break;
- }
- }
- return tokList;
- }
-
- List matchFixedWidthPattern(String param)
- {
- List posList=null;
- Matcher mat = mapFileFixedWidthColPat.matcher(param);
- if (mat.find())
- {
- posList = new ArrayList();
- posList.add(mat.group(1));
- posList.add(mat.group(2));
-
- }
- return posList;
- }
-
- public String matchDbFnPattern(String str)
- {
- Matcher mat = dbFunctionPat.matcher(str);
- if (mat.find())
- {
- String fnname = mat.group(1);
- String tmp[] = mat.group(2).split(",");
- if (tmp != null)
- str = str.replaceFirst(tmp[0],"?");
- else
- str = str.replaceFirst(fnname,"?");
- return fnname;
- }
- return null;
- }
-
- public String getEnvVarName()
- {
- if (remainderStr == null)
- return null;
- Matcher mat = envPat.matcher(remainderStr);
- if (mat.find())
- {
- remainderStr=mat.group(2);
- return mat.group(1);
- }
- else
- {
- return null;
- }
- }
-*/
- public String getConnArg(String argString)
- {
- if (remainderStr == null || argString==null)
- {
- return null;
- }
- Matcher mat =null;
- if (argString.equalsIgnoreCase("user"))
- {
- mat=connUserPreparePat.matcher(remainderStr.trim());
- if(mat.find())
- {
- String userPrepare = mat.group(1).trim();
- if (userPrepare.indexOf("/") < 0
- && !(userPrepare.indexOf("\"") == 0 && userPrepare
- .lastIndexOf("\"") == userPrepare.length() - 1))
- mat=connUserPat.matcher(remainderStr);
- else
- mat.reset();
- }
- else
- mat=connUserPat.matcher(remainderStr);
- }
- else if (argString.equalsIgnoreCase("pass"))
- mat=connPassPat.matcher(remainderStr);
- else if (argString.equalsIgnoreCase("server"))
- mat=connServerPat.matcher(remainderStr);
- else if (argString.equalsIgnoreCase("dsn"))
- mat=connDsnPat.matcher(remainderStr);
- else
- return null;
-
- if (mat.find())
- {
- remainderStr=mat.group(mat.groupCount());
- if (argString.equalsIgnoreCase("pass") &&
- mat.group(1).startsWith("\"") && mat.group(1).endsWith("\""))
- {
- String password = mat.group(1).substring(1,mat.group(1).length()-1);
- password = password.replaceAll("\\\\\"","\\\"");
- return password;
- }
- if (argString.equalsIgnoreCase("user"))
- {
- String user = mat.group(1).trim();
- if (user.startsWith("\"") && user.endsWith("\""))
- return user.substring(1,user.length()-1);
- }
-
- return mat.group(1);
- }
- else
- {
- return null;
- }
- }
-
- public String getErrorCode(String errStr) {
- Matcher mat = errPat.matcher(errStr);
- if (mat.find())
- return mat.group(2);
- else
- return UNKNOWN_ERROR_CODE;
- }
-
- public String getErrorCode(String errStr, int errCode) {
- Matcher mat = errPat.matcher(errStr);
- if (mat.find())
- return mat.group(2);
- else if (errCode != 0)
- return String.valueOf(errCode);
- else
- return UNKNOWN_ERROR_CODE;
- }
-
- public String getErrorMsg(String errStr)
- {
-
- Matcher mat = errPat.matcher(errStr);
- if (mat.find())
- return mat.group(3).trim();
- else
- return errStr;
- }
-
- public String getNDCSProduct(String vproc)
- {
- Matcher mat = ndcsProductInfo.matcher(vproc);
- if (mat.find())
- {
- return mat.group();
- }
- else
- {
- return null;
- }
- }
- public String getSysInfo(String sysinfo)
- {
-
- Matcher mat = sysInfo.matcher(sysinfo);
- if (mat.find())
- return mat.group(1);
- else
- return null;
- }
-
- public String gett4Version(String verTxt)
- {
-
- Matcher mat = t4Version.matcher(verTxt);
- if (mat.find())
- return mat.group(1);
- else
- return null;
- }
-
- public String getWMSErr(String errTxt)
- {
-
- Matcher mat = wmsErrPat.matcher(errTxt);
- if (mat.find())
- return mat.group(2);
- else
- return errTxt;
- }
-
- /************** Begin Conditional Parser Functions ***************************/
- // group(2) is condition
- // group(6) is operator
- // group(8) is value
- // group(13) is action
-
- public String getConditionalVariable(String txt){
- Matcher mat = condPat.matcher(txt);
-
- if(mat.find())
- {
- return mat.group(2).trim();
- }
- else
- return null;
- }
-
- public String getConditionalOperator(String txt){
- Matcher mat = condPat.matcher(txt);
- if(mat.find())
- return mat.group(6);
- else
- return null;
- }
-
- public String getConditionalValue(String txt){
- Matcher mat = condPat.matcher(txt);
- if(mat.find())
- return mat.group(8);
- else
- return null;
- }
-
- public String getConditionalAction(String txt){
- String action = null;
- Matcher mat = condPat.matcher(txt);
- if(mat.find())
- {
- action = mat.group(13).replaceAll("\\n", " ").trim();
- }
-
- return action;
- }
-
- /************** End Conditional Parser Functions *****************************/
-
- // Identifies the comments in a given SQL query line
- // if a comment string "--" is embedded between single quotes
- // then it is treated as string literal otherwise its a comment
- String ignoreComments(String qryLine)
- {
- String qryLineCopy=qryLine;
- int quoteStartPos=-1; // first single quote position
- int quoteEndPos=-1; // second single quote or end quote position
- int commentPos=-1; // comments position
- int fromIndex=0; // search start position in the querystring for quotes
- int commentFromIndex=0; // search start position in the querystring for comment
- String quoteStr="'";
- String commentStr="--";
-
- while (qryLineCopy !=null)
- {
-
- quoteStartPos=qryLine.indexOf(quoteStr,fromIndex);
- commentPos=qryLine.indexOf(commentStr,commentFromIndex);
-
- // if no comments found return qryLine as it is.
- if (commentPos == -1) return qryLine;
-
- // if no quotes found or if the comment appears before the quote remove the comment portion
- // from the query string and return it
- // else set the fromIndex position to find the ending quote.
- if (quoteStartPos == -1 || quoteStartPos > commentPos) return qryLine.substring(0,commentPos);
- else
- fromIndex=quoteStartPos+1;
-
- quoteEndPos=qryLine.indexOf(quoteStr,fromIndex);
-
- // if no ending quote is found remove the comments portion and return the string
- if (quoteEndPos==-1 && commentPos != -1) return qryLine.substring(0,commentPos);
-
- // if comment begins after ending quote , search for more quotes without resetting commentsPosition
- if (quoteEndPos < commentPos)
- {
- qryLineCopy=qryLine.substring(quoteEndPos+1,qryLine.length());
- fromIndex=quoteEndPos+1;
- continue;
- }
-
- // if comment appears between quotes , search for more quotes and comments and repeat the while loop
- // by resetting comments position
- if (quoteStartPos < commentPos && commentPos < quoteEndPos && qryLine.length()>quoteEndPos+1)
- qryLineCopy=qryLine.substring(quoteEndPos+1,qryLine.length()-1);
-
- fromIndex=quoteEndPos+1;
- commentFromIndex=fromIndex;
-
- }
-
- return qryLine;
-
- }
-
- public String replaceShowPattern(String showPatStr)
- {
- showPatStr = showPatStr.replaceAll(showWildCardPattern, "%");
- showPatStr = showPatStr.replaceAll(showWildCardPatternChar, "_");
- return showPatStr;
-
- }
-
- public String replaceShowPrepPattern(String showPatStr)
- {
- showPatStr = showPatStr.replaceAll(showWildCardPattern, ".*");
- showPatStr = showPatStr.replaceAll(showWildCardPattern2, "*");
- showPatStr = showPatStr.replaceAll(showWildCardPatternChar, "_");
- return showPatStr;
-
- }
-
- String getNextWordToken()
- {
- if(remainderStr == null)
- return null;
-
- Matcher mat=wordPattern.matcher(remainderStr);
- if(mat.find())
- {
- remainderStr=mat.group(2);
- return mat.group(1);
- }
- else
- {
- return null;
- }
- }
-
- String getDbVersion(String sutVer)
- {
- if (sutVer == null)
- return null;
-
- Matcher mat=dbProdVersionPat.matcher(sutVer);
- if(mat.find())
- {
- String minorVersion = mat.group(4);
- if (minorVersion.length() > 1 && minorVersion.startsWith("0"))
- minorVersion = minorVersion.substring(1);
- return mat.group(3) + "." + minorVersion;
- }
- else
- {
- return null;
- }
- }
-
- String formatSutVer(String sutVer)
- {
- if (sutVer == null)
- return "Information not available";
-
- Matcher mat=dbProdVersionPat.matcher(sutVer);
- if(mat.find())
- {
- return mat.group(1);
- }
- else
- {
- return "Information not available";
- }
-
- }
-
- public int getDelayTime(String cmdStr)
- {
- int timeVal=-1;
- Matcher mat = delayTimePat.matcher(cmdStr);
- if (mat.matches())
- {
- if (mat.group(2)!=null)
- {
- try {
- timeVal = Integer.parseInt(mat.group(2)) * 1000;
- }catch (NumberFormatException nfe)
- {
- return -1;
- }
- }
- if (mat.group(8)!=null)
- {
- timeVal = timeVal * 60 ;
- }
-
- }
- return timeVal;
- }
-
-
- public String matchKeyPat(String cmdStr)
- {
- Matcher patMat = containsKeyPat.matcher(cmdStr);
- if (patMat.matches())
- {
- return patMat.group(2);
- }
- return null;
- }
-
- public Matcher getKeyPatternMatcher(String cmdStr)
- {
- Matcher patMat = containsKeyPat.matcher(cmdStr);
- return patMat;
-
- }
-
- public String getPatternKeyPattern()
- {
- Matcher patMat = patternKeyPat.matcher(remainderStr);
- if (patMat.matches())
- {
- remainderStr=patMat.group(2);
- return patMat.group(1);
-
- }
- return null;
- }
-
- public String getPatternValueToken()
- {
- Matcher patMat = patternValPat.matcher(remainderStr);
- if (patMat.matches())
- {
- remainderStr=patMat.group(2);
- return patMat.group(1);
-
- }
- return null;
- }
- public String getRegexpPattern()
- {
- Matcher regExpMat = regExpPat.matcher(remainderStr);
- if (regExpMat.matches())
- {
- remainderStr=regExpMat.group(2);
- return regExpMat.group(1);
-
- }
- return null;
- }
-
- public String getRegexpValue()
- {
- Matcher regExpMat = regExpVal.matcher(remainderStr);
- if (regExpMat.matches())
- {
- remainderStr=regExpMat.group(2);
- return regExpMat.group(1);
-
- }
- return null;
- }
-
-
- public int getErrorPos(String errorMsg)
- {
- Matcher errorPosMat = errPosPat.matcher(errorMsg);
- if (errorPosMat.matches())
- {
- return new Integer(errorPosMat.group(2)).intValue();
- }
- return 0;
- }
-
-
- public String getSECErr(String errTxt)
- {
- Matcher mat = secErrPat.matcher(errTxt);
- if (mat.find())
- return mat.group(1);
- else
- return errTxt;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/org/trafodion/ci/ParserMissingParamException.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/org/trafodion/ci/ParserMissingParamException.java b/core/conn/trafci/src/org/trafodion/ci/ParserMissingParamException.java
deleted file mode 100644
index 314974e..0000000
--- a/core/conn/trafci/src/org/trafodion/ci/ParserMissingParamException.java
+++ /dev/null
@@ -1,42 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-package org.trafodion.ci;
-
-public class ParserMissingParamException extends Exception {
-
- /**
- *
- */
- private static final long serialVersionUID = 6253398014500719153L;
-
- ParserMissingParamException()
- {
-
- }
-
- ParserMissingParamException(String msg)
- {
- super(msg);
- }
-
-}
-
-
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/org/trafodion/ci/Properties/trafciDefaultLookAndFeel.properties
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/org/trafodion/ci/Properties/trafciDefaultLookAndFeel.properties b/core/conn/trafci/src/org/trafodion/ci/Properties/trafciDefaultLookAndFeel.properties
deleted file mode 100644
index d867795..0000000
--- a/core/conn/trafci/src/org/trafodion/ci/Properties/trafciDefaultLookAndFeel.properties
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# @@@ START COPYRIGHT @@@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-# @@@ END COPYRIGHT @@@
-#
-
-WMS_.*=---\ WMS\ operation\ complete.
-SQL_UNKNOWN_CMD=---\ SQL\ operation\ complete.
-SQL_CREATE\ TABLE\ .*\ AS\ SELECT\ .*=---\ @rownum@ row(s)\ inserted.
-SQL_CREATE\ SET\ VOLATILE\ TABLE\ .*\ AS\ SELECT\ .*=---\ @rownum@ row(s)\inserted.
-SQL_CREATE\ SET\ TABLE\ .*\ AS\ SELECT\ .*=---\ @rownum@ row(s)\ inserted.
-SQL_CREATE\ VOLATILE\ TABLE\ .*\ AS\ SELECT\ .*=---\ @rownum@ row(s)\ inserted.
-SQL_DELETE\ .*=---\ @rownum@ row(s)\ deleted.
-SQL_DELETE\ SERVICE\ .*=---\ SQL\ operation\ complete.
-SQL_DELETE\ USER\ .*=---\ SQL\ operation\ complete.
-SQL_DELETE\ DS\ .*=---\ SQL\ operation\ complete.
-SQL_PREPARE\ .*=---\ SQL\ command\ prepared.
-SQL_EXECUTE\ .*=---\ SQL\ operation\ complete.
-SQL_INSERT\ .*=---\ @rownum@ row(s)\ inserted.
-SQL_INS\ .*=---\ @rownum@ row(s)\ inserted.
-SQL_SELECT\ .*=---\ @rownum@ row(s)\ selected.
-SQL_SELECT_LIST_COUNT\ .*=---\ @rownum@ row(s)\ selected. LIST_COUNT was reached.
-SQL_VALUES.*=---\ @rownum@ row(s)\ selected.
-SQL_\\(\\s*SELECT\ .*=---\ @rownum@ row(s)\ selected.
-SQL_\\(\\s*SELECT_LIST_COUNT\ .*=---\ @rownum@ row(s)\ selected. LIST_COUNT was reached.
-SQL_\\(\\s*VALUES.*=---\ @rownum@ row(s)\ selected.
-SQL_SEL\ .*=---\ @rownum@ row(s)\ selected.
-SQL_UPDATE\ .*=---\ @rownum@ row(s)\ updated.
-SQL_UPSERT\ .*=---\ @rownum@ row(s)\ inserted.
-SQL_UPDATE\ STATISTICS\ .*=---\ SQL\ operation\ complete.
-SQL_LOCK\ .*\ FOR\ ACCESS\ INS\ .*=---\ @rownum@ row(s)\ inserted.
-SQL_LOCK\ .*\ FOR\ ACCESS\ INSERT\ .*=---\ @rownum@ row(s)\ inserted.
-SQL_LOCK\ .*\ FOR\ ACCESS\ SEL\ .*=---\ @rownum@ row(s)\ selected.
-SQL_LOCK\ .*\ FOR\ ACCESS\ SELECT\ .*=---\ @rownum@ row(s)\ selected.
-SQL_LOCKING\ .*\ FOR\ ACCESS\ INS\ .*=---\ @rownum@ row(s)\ inserted.
-SQL_LOCKING\ .*\ FOR\ ACCESS\ INSERT\ .*=---\ @rownum@ row(s)\ inserted.
-SQL_LOCKING\ .*\ FOR\ ACCESS\ SEL\ .*=---\ @rownum@ row(s)\ selected.
-SQL_LOCKING\ .*\ FOR\ ACCESS\ SELECT\ .*=---\ @rownum@ row(s)\ selected.
-CS_.*=---\ CS\ operation\ complete.
-SQL_CMDCLOSE=---\ CS\ operation\ complete.
-SQL_WMSCLOSE=---\ WMS\ operation\ complete.
-
-
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/org/trafodion/ci/PrunSummary.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/org/trafodion/ci/PrunSummary.java b/core/conn/trafci/src/org/trafodion/ci/PrunSummary.java
deleted file mode 100644
index f5d93e8..0000000
--- a/core/conn/trafci/src/org/trafodion/ci/PrunSummary.java
+++ /dev/null
@@ -1,119 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-/**
- *
- * Object to handle PRUN summary fields
- *
- */
-package org.trafodion.ci;
-
-public class PrunSummary
-{
-
- private int totalScriptFiles = 0;
- private int totalScriptFilesProcessed = 0;
- private int totalSQLsProcessed = 0;
- private int totalSQLErrors = 0;
- private int totalSQLWarnings = 0;
- private int totalConnections = 0;
- private int totalConnectionFailures = 0;
- private int totalSQLSuccesses = 0;
-
- public int getTotalConnections()
- {
- return totalConnections;
- }
-
- public void setTotalConnections(int totalConnections)
- {
- this.totalConnections = totalConnections;
- }
-
- public int getTotalScriptFiles()
- {
- return totalScriptFiles;
- }
-
- public void setTotalScriptFiles(int totalScriptFiles)
- {
- this.totalScriptFiles = totalScriptFiles;
- }
-
- public int getTotalScriptFilesProcessed()
- {
- return totalScriptFilesProcessed;
- }
-
- public void setTotalScriptFilesProcessed(int totalScriptFilesProcessed)
- {
- this.totalScriptFilesProcessed = totalScriptFilesProcessed;
- }
-
- public int getTotalSQLErrors()
- {
- return totalSQLErrors;
- }
-
- public void setTotalSQLErrors(int totalSQLErrors)
- {
- this.totalSQLErrors = totalSQLErrors;
- }
-
- public int getTotalSQLsProcessed()
- {
- return totalSQLsProcessed;
- }
-
- public void setTotalSQLsProcessed(int totalSQLsProcessed)
- {
- this.totalSQLsProcessed = totalSQLsProcessed;
- }
-
- public int getTotalSQLWarnings()
- {
- return totalSQLWarnings;
- }
-
- public void setTotalSQLWarnings(int totalSQLWarnings)
- {
- this.totalSQLWarnings = totalSQLWarnings;
- }
-
- public int getTotalSQLSuccess()
- {
- return totalSQLSuccesses;
- }
-
- public int getTotalConnectionFailures()
- {
- return totalConnectionFailures;
- }
-
- public void setTotalConnectionFailures(int totalConnectionFailures)
- {
- this.totalConnectionFailures = totalConnectionFailures;
- }
-
- public void setTotalSQLSuccess(int totalSQLSuccesses)
- {
- this.totalSQLSuccesses = totalSQLSuccesses;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/org/trafodion/ci/PrunUserInterruption.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/org/trafodion/ci/PrunUserInterruption.java b/core/conn/trafci/src/org/trafodion/ci/PrunUserInterruption.java
deleted file mode 100644
index 8b7deac..0000000
--- a/core/conn/trafci/src/org/trafodion/ci/PrunUserInterruption.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-package org.trafodion.ci;
-
-public class PrunUserInterruption extends Exception
-{
- /**
- *
- */
- private static final long serialVersionUID = 794988996507793357L;
-
- PrunUserInterruption()
- {
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/org/trafodion/ci/PythonInterface.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/org/trafodion/ci/PythonInterface.java b/core/conn/trafci/src/org/trafodion/ci/PythonInterface.java
deleted file mode 100644
index 7ce827b..0000000
--- a/core/conn/trafci/src/org/trafodion/ci/PythonInterface.java
+++ /dev/null
@@ -1,180 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-package org.trafodion.ci;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.sql.SQLException;
-
-public class PythonInterface
-{
- ConsoleReader crObj=null;
- ConsoleWriter cwObj=null;
- SessionInterface sessIntObj=null;
- Session sessObj=null;
- boolean doTrace=false;
-
- public PythonInterface()
- {
- initialize();
- sessIntObj=new SessionInterface(crObj,cwObj);
-
- String enableTrace=System.getProperty ("trafci.enableTrace");
- if ((enableTrace != null) && enableTrace.trim().equalsIgnoreCase("true"))
- doTrace = true;
-
- }
-
- private void initialize()
- {
- cwObj=new ConsoleWriter();
-
- try
- {
- cwObj.initialize();
- } catch (IOException e1)
- {
- System.out.println("Could not able to initialize the writer"+e1);
- if (doTrace)
- e1.printStackTrace();
- System.exit(1);
- }
- crObj=new ConsoleReader();
-
- try
- {
- crObj.initialize();
- } catch (IOException e1)
- {
- System.out.println("Could not able to initialize the reader"+e1);
- if (doTrace)
- e1.printStackTrace();
- System.exit(1);
- }
- }
-
- public void openConnection(String userName, String password, String serverName, String portNumber, String dsnName)
- {
- String roleName = ""; //primary role
- openConnection(userName, password, roleName, serverName, portNumber, dsnName );
- }
-
- public void openConnection(String userName, String password,String roleName, String serverName, String portNumber, String dsnName)
- {
- try
- {
- sessObj=sessIntObj.createSession(userName,
- password,
- roleName,
- serverName,
- portNumber,
- dsnName,
- SessionDefaults.USERI);
- } catch (FileNotFoundException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (SQLException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InstantiationException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (ClassNotFoundException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- public void executeUI()
- {
- try
- {
- sessIntObj.setQueryOptions(false,null);
- sessIntObj.invokeSession(sessObj);
- } catch (IOException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- public void executeQuery(String qryString)
- {
- try
- {
- sessIntObj.setQueryOptions(true,qryString);
- sessIntObj.invokeSession(sessObj);
- } catch (IOException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- public void executeFile(String fileName)
- {
- try
- {
- sessIntObj.setQueryOptions(false,null);
- sessIntObj.setScriptFile(fileName);
- //sessIntObj.setCaller(SessionDefaults.PYTHI);
- sessIntObj.invokeSession(sessObj);
-
- } catch (IOException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- public void closeConnection()
- {
- if (this.sessIntObj != null)
- {
- if (sessObj.getConnObj() != null)
- {
- try
- {
- sessObj.getConnObj().close();
- } catch (SQLException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- sessObj=null;
- }
- }
- sessIntObj=null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/org/trafodion/ci/Query.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/org/trafodion/ci/Query.java b/core/conn/trafci/src/org/trafodion/ci/Query.java
deleted file mode 100644
index e366a8d..0000000
--- a/core/conn/trafci/src/org/trafodion/ci/Query.java
+++ /dev/null
@@ -1,188 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.ci;
-
-public class Query
-{
- private int queryType=-1 ; // 0 -tool query 1- sql query
- private boolean passThrough=false; // false -for all interface query
- private boolean multiLine=false; // false for all interface query
- private StringBuffer queryText;
- private String rowCount=null; // false if the query does not succeed
- private int queryId=-1;// query identifier
- private boolean trimOut=false;
- private boolean isActive=false;
- private long elapsedTime;
- private String stmtType=null;
- private int statusCode=0; // 0-after successful execution of the query. corresponding error number otherwise
- private String colCount=null;
- private int rsCount=0;
-
- Query() {
- queryText = new StringBuffer();
- }
-
- public void setQueryType(int queryType)
- {
- this.queryType=queryType;
- }
-
- public int getQueryType()
- {
- return this.queryType;
- }
-
- public void setPassThrough(boolean passThrough)
- {
- this.passThrough=passThrough;
- }
-
- public boolean getPassThrough()
- {
- return this.passThrough;
- }
-
- public void setMultiLine(boolean multiLine)
- {
- this.multiLine=multiLine;
- }
-
- public boolean isMultiLine()
- {
- return this.multiLine;
- }
-
- public void setQueryText(String queryText)
- {
- this.queryText.append(queryText);
- }
-
- public void resetQueryText(String queryText)
- {
- this.queryText.replace(0,this.queryText.length(),queryText);
- }
-
- public String getQueryText()
- {
- return this.queryText.toString();
- }
-
- public void setRowCount(String rowCount)
- {
- this.rowCount=rowCount;
- }
-
- public void resetRowCount()
- {
- this.rowCount=null;
- }
-
- public String getRowCount()
- {
- return this.rowCount;
- }
-
- public void setColCount(String colCount)
- {
- this.colCount=colCount;
- }
-
- public String getColCount()
- {
- return this.colCount;
- }
-
- public int getQueryId()
- {
- return queryId;
- }
-
- public void setQueryId(int queryId)
- {
- this.queryId = queryId;
- }
-
- public boolean isTrimOut()
- {
- return trimOut;
- }
-
- public void setTrimOut(boolean trimOut)
- {
- this.trimOut = trimOut;
- }
-
- public boolean isActive()
- {
- return isActive;
- }
-
- public void setActive(boolean isActive)
- {
- this.isActive = isActive;
- }
- public long getElapsedTime()
- {
- return this.elapsedTime;
- }
-
- public void setElapsedTime(long elapsedTime)
- {
- this.elapsedTime=elapsedTime;
- }
-
- public String getStmtType()
- {
- return stmtType;
- }
-
- public void setStmtType(String stmtType)
- {
- this.stmtType = stmtType;
- }
-
- public int getStatusCode()
- {
- return statusCode;
- }
-
- public void setStatusCode(int statusCode)
- {
- this.statusCode = statusCode;
- }
-
- public int getRsCount()
- {
- return rsCount;
- }
-
- public void incrRsCount()
- {
- rsCount++;
-
- }
-
- public void setRsCount(int rsCount)
- {
- this.rsCount = rsCount;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/org/trafodion/ci/QueryUtils.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/org/trafodion/ci/QueryUtils.java b/core/conn/trafci/src/org/trafodion/ci/QueryUtils.java
deleted file mode 100644
index c91edae..0000000
--- a/core/conn/trafci/src/org/trafodion/ci/QueryUtils.java
+++ /dev/null
@@ -1,37 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.ci;
-
-public class QueryUtils
-{
- QueryUtils()
- {
- }
-
-
- public boolean isGetStatsCmd(Query qryObj)
- {
- if (qryObj.getQueryText().matches("(?i)(?s)get\\s+statistics.*") )
- return true;
- return false;
- }
-}